Changes between Initial Version and Version 1 of Ticket #9910


Ignore:
Timestamp:
Sep 7, 2022, 1:23:14 PM (4 years ago)
Author:
Jozef Chutka
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9910 – Description

    initial v1  
    33Lets have some (300 sec) long video with 10s keyframe interval (600 / 60), to demonstrate both trim accuracy and performance:
    44
    5 ```
     5{{{
    66ffmpeg -filter_complex "smptehdbars=size=1920x1080:rate=60,drawtext=fontfile=c\\:/Windows/Fonts/arial.ttf:timecode=00\\:00\\:00.00:rate=60:fontsize=300:fontcolor=white:x=(w-tw)/2:y=10*h/100:box=1:boxcolor=0x00000000@1" -t 300 -c:v libx264 -x264-params keyint=600 -preset ultrafast -y source.mkv
    7 ```
     7}}}
    88
    99Lets cut this video accurately at time 282 (4:42) to 293 (4:53) so neither of the time points is keyframe:
    1010
    11 ```
     11{{{
    1212ffmpeg -i source.mkv -ss 282 -to 293 -c:v libx264 -preset ultrafast -y out1.mkv
    1313// takes 14.8 sec to complete
    14 ```
     14}}}
    1515
    16 ```
     16{{{
    1717ffmpeg -i source.mkv -vf trim=start=282:end=293 -c:v libx264 -preset ultrafast -y out2.mkv
    1818// takes 14.7 sec to complete
    19 ```
     19}}}
    2020
    21 ```
     21{{{
    2222ffmpeg -i source.mkv -vf "select=between(t\,282\,293)" -c:v libx264 -preset ultrafast -y out3.mkv
    2323// takes 15.1 sec to complete
    24 ```
     24}}}
    2525
    2626Now here is the two step much faster accurate trim, in first step lets create inaccurate intermediate file, and fix the accurancy in the second step:
    2727
    28 ```
     28{{{
    2929ffmpeg -ss 282 -to 293 -i source.mkv -output_ts_offset 282 -c:v copy -y out4-tmp.mkv
    3030ffmpeg -filter_complex "movie=out4-tmp.mkv,select=gte(t\,282)*lt(t\,293),setpts=PTS-STARTPTS" -c:v libx264 -preset ultrafast -y out4.mkv
    3131// takes 0 + 2.4 sec to complete
    32 ```
     32}}}
    3333
    3434I believe the internal seeking within `trim` and `select` filters is much slower then the one used by `-ss (before `-i`)`. If the video is fast-seeked in first step, even though inaccurately, it can be fixed in the second step.