Changes between Initial Version and Version 1 of Ticket #9910
- Timestamp:
- Sep 7, 2022, 1:23:14 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #9910 – Description
initial v1 3 3 Lets have some (300 sec) long video with 10s keyframe interval (600 / 60), to demonstrate both trim accuracy and performance: 4 4 5 ``` 5 {{{ 6 6 ffmpeg -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 }}} 8 8 9 9 Lets cut this video accurately at time 282 (4:42) to 293 (4:53) so neither of the time points is keyframe: 10 10 11 ``` 11 {{{ 12 12 ffmpeg -i source.mkv -ss 282 -to 293 -c:v libx264 -preset ultrafast -y out1.mkv 13 13 // takes 14.8 sec to complete 14 ``` 14 }}} 15 15 16 ``` 16 {{{ 17 17 ffmpeg -i source.mkv -vf trim=start=282:end=293 -c:v libx264 -preset ultrafast -y out2.mkv 18 18 // takes 14.7 sec to complete 19 ``` 19 }}} 20 20 21 ``` 21 {{{ 22 22 ffmpeg -i source.mkv -vf "select=between(t\,282\,293)" -c:v libx264 -preset ultrafast -y out3.mkv 23 23 // takes 15.1 sec to complete 24 ``` 24 }}} 25 25 26 26 Now 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: 27 27 28 ``` 28 {{{ 29 29 ffmpeg -ss 282 -to 293 -i source.mkv -output_ts_offset 282 -c:v copy -y out4-tmp.mkv 30 30 ffmpeg -filter_complex "movie=out4-tmp.mkv,select=gte(t\,282)*lt(t\,293),setpts=PTS-STARTPTS" -c:v libx264 -preset ultrafast -y out4.mkv 31 31 // takes 0 + 2.4 sec to complete 32 ``` 32 }}} 33 33 34 34 I 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.


