nessger.blogg.se

Ffmpeg filter complex
Ffmpeg filter complex













ffmpeg filter complex ffmpeg filter complex

It works if you set this option to "shortest".īut this doesn't explain why the -shortest option doesn't work.įfmpeg -i input.mp4 -i song.m4a -lavfi amix=duration=shortest null -map -map -y output.mp4Įven with that command -shortest is still not actually getting triggered when adding duration=shortest to amix, because all that's doing is shortening the m4a back to the original video's audio stream, which is likely the same length as the video itself, so it's still reverting to default behaviour. Combine both files (-shortest should work here but it does not)įfmpeg -i input.mp4 -i song.m4a -lavfi amix null -map -map -shortest -y output.mp4 The issue can be easily recreated by anyone using these commands (courtesy of Michael Koch):įfmpeg -f lavfi -i testsrc2 -f lavfi -i sine=2000 -t 5 -y input.mp4įfmpeg -f lavfi -i sine=500 -t 10 -y song.m4a I'm using a self-compiled FFmpeg build on Linux (using the most recent Git version as of writing this) but I can confirm I can also recreate the issue with the official Linux AND Windows builds as well, even when using different audio and video files too. I guess my question is why is -shortest made redundant when combining both audio and video filters in a single -filter_complex argument? Is this a bug, or the intended behaviour? How can I get it to work as intended with just one -filter_complex?

ffmpeg filter complex

Using the above 2 commands results in a 20-second long video as intended. Same with if I remove the video filters entirely:įfmpeg -i input.mp4 -i song.m4a -filter_complex amix -map -map 0:v -shortest output.mp4 When I separate the audio and video filters into 2 separate -filter_complexs, it works as intended (doing this was also the solution given in the issue a linked at the top):Īmix -filter_complex pad=height=ceil(ih/2)*2:width=ceil(iw/2)*2 \ However, in the command above, -shortest seems to be not working entirely. To ensure that the output file does not become 8 minutes long, I'm using the -shortest option, which should make FFmpeg stop encoding once it hits the shortest audio/video stream. I want to mix both the audio streams together, so that the first 20 seconds of song.m4a plays alongside the original audio of input.m4a. Input.mp4 is only about 20 seconds long, but song.m4a is about 8 minutes long.

ffmpeg filter complex

I'm using the following command to mix the audio of input.mp4 with song.m4a and ensure that the dimensions of my output file are even numbers:įfmpeg -i input.mp4 -i song.m4a -filter_complex \Īmix pad=height=ceil(ih/2)*2:width=ceil(iw/2)*2 \ Pretty much the exact same issue was described ​here several years ago, but the 'solution' given, while it works, is more inconvenient and doesn't explain why the actual command in question does not work.















Ffmpeg filter complex