[FFmpeg-user] Replacing an audio stream in an MP4

Dan Bridges dosdan at gmail.com
Mon May 7 03:56:03 EEST 2018


I'm a heavy user of the Vegas 12 video editor. I record junior soccer
matches with 2 cameras and two extra ext. sound recorders. Sometimes I
notice a mixing balance problem in a rendered MP4 and need just to
replace a remixed version of the audio stream in the MP4. Vegas won't
output just a raw AAC file. But it will output a MP4 containing just the
audio.

So what I want to do is create a Windows desktop icon of a batchfile
where I can drag-and-drop an affected MP4. The batchfile will then look
for the presence of "replacement.mp4", the AAC-only MP4,  in the same
directory as the affected MP4. (I'll always use the same name for the
fixed audio file.)  If found, it will then perform the following
sequence of FFMPEG commands (using "test.mp4" as an example of an 
AVC+AAC MP4 which needs to have its audio stream replaced):

ffmpeg -i test.mp4 -an -c:v copy  test.h264
ffmpeg -i replacement.mp4 -vn -c:a copy replacement.aac
ffmpeg -i test.h264 -i replacement.aac -c copy test_replacement.mp4

The compression formats and stream indices will always be the same so I
don't need to do any checking for that.

1. Is this the most efficient way to perform this task?  Could I mux the
AVC stream in test.mp4 with the AAC stream in replacement.mp4 without
first demuxing them. That is, could this all be performed in one FFMPEG
command?

2. I get these warnings during the muxing:

"Timestamps are unset in a packet for stream 0. This is deprecated and
will stop working in the future. Fix your code to set the timestamps
properly" 

and a lot of "pts has no value". The audio appears to be in sync in the
18 minute clip I produced, so I don't think these warning are
significant here. What do you think?

1 minutes versions of test.mp4 (720p50) and replacement.mp4 are
available here:

https://dl.dropboxusercontent.com/s/z7a7dh1dgqohx17/test.mp4
https://dl.dropboxusercontent.com/s/s6cax255fugc3ny/replacement.mp4

Dan.










More information about the ffmpeg-user mailing list