0

I am using ffmpeg to speed up and slow down parts where the talker is talking and being silent. To do this I run something like this(the code below[more exactly the filter part, the rest is the same] is an example, not my exact code):
cmd /c ffmpeg -i Soon.mp4 -filter_complex "[0:v]trim=0:2,setpts=PTS-STARTPTS[v1];[0:v]trim=2:5,setpts=2*(PTS-STARTPTS)[v2];[0:v]trim=5:6,setpts=PTS-STARTPTS[v3];[0:a]atrim=0:2,asetpts=PTS-STARTPTS[a1];[0:a]atrim=2:5,asetpts=PTS-STARTPTS,atempo=0.5[a2];[0:a]atrim=5:6,asetpts=PTS-STARTPTS[a3];[v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1" -vcodec libx264 -crf 10 -preset ultrafast -profile:v baseline -shortest -tune:v stillimage -pix_fmt yuv420p -colorspace:v "bt709" -color_primaries:v "bt709" -color_trc:v "bt709" -color_range:v "tv" output.mp4
I added some optimisations to make it faster and they do work, but the amount of time needed for "Stream mapping" does not change. My problem with it is not the amount of time it takes but the fact that it gets progressively slower as each iterations of codes like this are run. At start it takes 20 secs but towards the end it takes close to a minute, I thought maybe it gets cluttered so I added "cmd /c" to pretty much restart the console, but no change. How do I change this?

How stream mapping looks in one of the iterations.

Stream mapping:
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:0 (h264) -> trim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  Stream #0:1 (aac) -> atrim:default
  concat -> Stream #0:0 (libx264)
  concat -> Stream #0:1 (aac)
Press [q] to stop, [?] for help```
Bambi2k21
  • 15
  • 7
  • What do you mean by "it gets progressively slower as each iterations of codes like this are run" There is no mention of how the ffmpeg command runs multiple times? Does it help if you explicitly use `split` filter? – kesh Aug 29 '22 at 15:56
  • I first get a txt with all of the times when the speaker is silent and by using that and something like the code from the example above, I give ffmpeg information of where it should speed up and slow down, but because there are many times of where the speaker is silent, the code is to big for running in cmd or powershell so I break it into manageable parts. And then run them in a loop. – Bambi2k21 Aug 29 '22 at 18:26
  • You may want to add your powershell script to the post. It sounds like one run of ffmpeg is ok. Are you extending the output file in the loop or creating a bunch of partial outputs then run ffmpeg for the one last time to concatenate all the pieces? – kesh Aug 29 '22 at 18:31
  • The latter. Also it doesn't matter if I use cmd or powershell the result is the same. – Bambi2k21 Aug 29 '22 at 18:43

0 Answers0