amplifier
amplifier

Reputation: 1833

Concatenating audio and video files without encoding using ffmpeg

I have 2 files: video.webm - contains ONLY video audio.webm - contains ONLY audio

I try to merge them into one without encoding with python-ffmpeg

video = ffmpeg.input('video.webm').video
audio = ffmpeg.input('audio.webm').audio
concatenated = ffmpeg.concat(video, audio, v=0, a=1)
concatenated.output('output.webm', vcodec='copy", acodec='copy').run()

but on output call I get

Stream specifier ':v' in filtergraph description [0:v][1:a]concat=a=1:n=2:v=0[s0] matches no streams.

What I want to do is to make it work as

ffmpeg -i "video.webm" -i "audio.webm" -c copy -map 0:v -map 1:a -shortest output.webm

does. The command gives me output file in 10 sec. I'd like to do the same, but by means of python-ffmpeg.

Upvotes: 0

Views: 2023

Answers (1)

Dietrich Epp
Dietrich Epp

Reputation: 213228

“Concatenate” means making one stream run after the other, but you want to merge both streams at the same time. So, remove the ffmpeg.concat step, and just pass both streams into one call to ffmpeg.output:

video = ffmpeg.input('video.webm').video
audio = ffmpeg.input('audio.webm').audio
ffmpeg.output(
    video,
    audio,
    'output.webm',
    vcodec='copy',
    acodec='copy',
).run()

Upvotes: 3

Related Questions