1

For the project that I'm working on I have to cut some parts of same video with some subtitles. So I made a bash file that executes multiple ffmpeg commands like this.

ffmpeg -i input.mp4 -vf scale="w=640:h=-2",drawtext="fontfile=/usr/share/fonts/truetype/msttcorefonts/verdana.ttf: textfile='1.txt': fontcolor=white: fontsize=20: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=((h-text_h)/2)+90:" -ss 00:00:45.674 -to 00:00:50.093 -async 1 ./out/1.mp4

ffmpeg -i input.mp4 -vf scale="w=640:h=-2",drawtext="fontfile=/usr/share/fonts/truetype/msttcorefonts/verdana.ttf: textfile='2.txt': fontcolor=white: fontsize=20: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=((h-text_h)/2)+90:" -ss 00:00:49.344 -to 00:00:52.971 -async 1 ./out/2.mp4

but it fast for first times (start) of the input file, it gets slower if I want to start seeking from middle or near end of input. So it gets nearly 7-8 minutes for 22. minute of the input file...

ffmpeg -i input.mp4 -vf scale="w=640:h=-2",drawtext="fontfile=/usr/share/fonts/truetype/msttcorefonts/verdana.ttf: textfile='226.txt': fontcolor=white: fontsize=20: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=((h-text_h)/2)+90:" -ss 00:22:23.345 -to 00:22:25.846 -async 1 ./out/226.mp4

Anybody knows better way to do that? Can I do that without seeking file each time? (Because it seems this is a seeking problem to me....)

1 Answer 1

2

Use ss/to as input options. This seeks at the demuxer stage, which is much faster.

ffmpeg -ss 00:22:23.345 -to 00:22:25.846 -i input.mp4 ...

You'll need a very recent build of ffmpeg (> Nov 19 2017)

6
  • I have already, should I move them before input file as parameter to executable?
    – tanaydin
    Commented Jan 4, 2018 at 15:48
  • -ss must be before the input file to be applied at the read-stage like the example shows
    – sebix
    Commented Jan 4, 2018 at 15:51
  • I'll try to build with recent source... Current ffmpeg under ubuntu is not accepting like this.
    – tanaydin
    Commented Jan 4, 2018 at 15:53
  • -ss as demuxer option is old, but -to wasn't implemented till the date stated.
    – Gyan
    Commented Jan 4, 2018 at 16:02
  • 1
    Use the git version from johnvansickle.com/ffmpeg
    – Gyan
    Commented Jan 4, 2018 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.