Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mux two video/audio streams into one using ffmpeg

Tags:

ffmpeg

I have two videos v1.flv and v2.flv and would like to create v3.flv which contains video stream from v1.flv and "mixed" audio streams from v1.flv and v2.flv. Is something like this possible using ffmpeg command? Thanks.

like image 541
Aleksandar Vucetic Avatar asked Feb 25 '23 09:02

Aleksandar Vucetic


1 Answers

I think it isn't a good idea to use ffmpeg to mix the audio tracks; Using sox is a better idea.

You could use it as follows:

  1. Extract the audio from v1.flv and v2.flv using ffmpeg:

    ffmpeg -i v1.flv -vn -acodec copy v1.mp3

    ffmpeg -i v2.flv -vn -acodec copy v2.mp3

  2. Mix the audio tracks using sox, something like this (not tested):

    sox -M v1.mp3 v2.mp3 v3.mp3

  3. Multiplex audio and video using ffmpeg. Try the following (also not tested):

    ffmpeg -i v1.flv -i v3.mp3 -vcodec copy -acodec copy v3.flv

If the commands aren't exactly right, hopefully the idea is clear.

like image 146
The Bndr Avatar answered Mar 03 '23 06:03

The Bndr