[FFmpeg-user] Mix a video with an audio file
Michael Koch
astroelectronic at t-online.de
Sun Jan 19 23:09:47 EET 2020
Am 19.01.2020 um 21:56 schrieb Paul B Mahol:
> On 1/19/20, Michael Koch <astroelectronic at t-online.de> wrote:
>> Am 19.01.2020 um 21:01 schrieb Paul B Mahol:
>>> On 1/19/20, Michael Koch <astroelectronic at t-online.de> wrote:
>>>> Hello,
>>>>
>>>> I've just found a problem that can be reproduced as follows:
>>>>
>>>> Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
>>>> played.
>>>>
>>>> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y
>>>> video.mp4
>>>>
>>>>
>>>> Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
>>>> at t=3s. The file is ok when played.
>>>>
>>>> ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
>>>> -y audio.wav
>>>>
>>>>
>>>> Step 3: Combine both files into one video, and the audio sources shall
>>>> be mixed:
>>>>
>>>> ffmpeg -i video.mp4 -i audio.wav -filter_complex
>>>> "[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
>>>>
>>>> The output video has the correct length 6s, but I don't understand why
>>>> the 1kHz tone disappears after 4s and the last 2s are silence.
>>>>
>>>> The console output is below.
>>> Can not reproduce using nut container.
>> When I change the output filename to out.nut, then it works as expected
>> (but with terrible image quality). Why doesn't it work with mp4 output?
> Use different video encoder. Who knows?
When I add -c:v mpeg4 then it works fine.
When I add -c:v libx264 then the audio output is 2s too short.
Is it a bug, or is something wrong with my command line?
Michael
More information about the ffmpeg-user
mailing list