Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
ffmpeg merging of stream tracks does not behave has expected when first stream has both audio & video tracks. #3935
Comments
|
Just for reference, you'll get the command line used for ffmpeg if you add the
|
|
Excellent. Well I'd then suggest that after "-c copy" the following be added:
I'd take a crack at it myself but after having a peek at the code it seems some dev more familiar with the modular structure should drop it in. Assuming of course this is deemed "a good idea" (tm). |
|
Since we have usually told users to use |
|
Whoops!! Reversed the order for legibility but of course forgot to switch the 0 & 1 which is what ffmpeg really cares about. I.E. you are correct:
|
|
Thank you for the report. Type By the way, if you want to post code here in the issue tracker, enclose the code in single backticks, as in
or use fenced code blocks. |
It is an excellent feature to integrate ffmpeg muxing/merging (actually technically copying I guess) of audio and video tracks from separate streams. Really a necessity in the DASH era. However, not knowing the exact syntax being passed to ffmpeg, there seem to be certain assumptions made as the the track content when asking for "-f video+audio" to merge streams. This results in unexpected behavior.
Specifically if the first stream you want the video from has an audio track as well, the second stream's audio track is not copied in. E.G. "-f 22+141" does not result in the audio track being replaced in 22.
Curiously the hack of swapping to "-f audio+video" works, albeit with the side effect of naming the output with a .m4a extension. E.G. "-f 141+22" replaces the audio track in 22 with 141.
Of note is that the existing command does work properly if the second stream has both audio and video track. I.E. it copies in the audio only from the second stream and uses the video from the first. E.G. "-f 137+22" works as expected.
It seems that a more robust command syntax needs to be passed to ffmpeg to allow for mixed tracks on both the audio and video source and at least grab the first one of each when merging.
E.G.
I might also suggest the "-shortest" flag be used but that's possibly moot given the infinitesimal savings unless it occasionally prevents some odd audio or video overhang artifacts at the end.