ffmpeg - add 3 audio streams to video - audio

I have the following problem.
In the folder there is video.mp4 file (contain 1 audio stream). There are also 3 different files audio1.wav, audio2.wav, audio3.wav. These files I need to 'attach' as multi stream to the video file - so the user can choose the audio language in VLC player or similar. Result must be one audio at the time - no mixing it all together.
Now, I've done it via Premiere Pro with multitrack (quicktime export to mov), and then I run a script to change audio stream names to correspond with the audio language (iso 639-2 ) and output the mp4 file. All works well, but I wonder if there is simple way to do everything via ffmpeg ( .bat script ). I have a working script for replacing audio in the video, but I need to add few additional .wav to the video file as separate audio tracks.
Any help will be appreciated!

To add a new audio track into an existing video with audio, use
the -i parameter to specify all the input files (original video and additional audios)
the -map option to manually select the tracks of each input (https://trac.ffmpeg.org/wiki/Map)
in your case,
-map 0 to copy all streams from the input #0 (video)
-map 1:a to include all audio streams from input#1 file (audio1)
-map 2:a to include all audio streams from input#2 file (audio2)
and so on
and
-shortest to crop the output to the shortest input
and additionally you may want to use
-c:v copy to copy the video stream without reencoding.
so, try this (line split for readability)
ffmpeg -i video.mp4 -i input1.mp3 -i input2.mp3
-map 0 -map 1:a -map 2:a
-c:v copy -shortest
output.mp4
and (addording to your comment) adding metadata for the audio tracks
ffmpeg -i video.mp4 -i input1.mp3 -i input2.mp3
map 0 -map 1:a -map 2:a
-metadata:s:a:0 language=eng
-metadata:s:a:1 language=ger
-metadata:s:a:2 language=fra
-disposition:a:0 default
-c:v copy -shortest
output.mp4

Related

How can I merge two audio tracks into one track but have one louder than the other?

I have a mkv file with an audio track (raw AAC file with ADTS headers) and I would like to merge it with another audio file that has my comments on it (AAC m4a file recorded with my phone.
I know I can merge both audio files in one track with te following command:
ffmpeg -i input.mkv -i audio.m4a -i audio.aac -filter_complex
"[1][2]amix=inputs=2[a]" -map 0:v -map "[a]" -c:a:1 aac copy test.mkv
However I would like my voice (audio.m4a) to be around 40% louder than the original audio (audio.acc). How can i do that?

ffmpeg concat discards audio stream

What I want to achieve
I have two input videos which I do want to concatenate using ffmpeg.
Issue
The input videos contain two stereo audio channels:
after concatenation, the second audio stream is lost:
steps to reproduce
The Command I used is
ffmpeg -f concat -i list.txt -c:a copy -c:v copy demuxed.mp4
Additional Information
The Console Output shows the second audio stream in input properly:
The Output settings also show that there is only one audio output stream. But I want to have the exact same settings in to out, just concatenated:
Assuming that all input videos have matching audio streams, add mapping.
ffmpeg -f concat -i list.txt -map 0:v -map 0:a -c:a copy -c:v copy demuxed.mp4
See http://ffmpeg.org/ffmpeg.html#Stream-selection, especially the section on automatic stream selection for details on how ffmpeg selects streams.

Merge 2 Files (audio and Video), with BITC and watermark in FFMPEG

I need to write ffmpeg profile to merge to merge video and audio files, and swap audio in video file from audio file, add BITC , and implement watermark from network location.
Can do it separately, but as I`m not FFMPEG expert, hard for me to combine all of above together.
Any advise would be appreciate.
Best regards all
Use the overlay filter for the watermark and the drawtext filter for the burnt-in timecode:
ffmpeg -i video.mp4 -i audio.mp3 -i watermark.png -filter_complex "[0:v:0]drawtext=fontfile=/usr/share/fonts/TTF/DejaVuSansMono.ttf:timecode='01\:23\:45\:00':r=25:x=(w-text_w)/2:y=h-text_h-20:fontsize=20:fontcolor=white:box=1:boxborderw=4:boxcolor=black[bg];[1][bg]overlay=W-w-10:H-h-12:format=auto[v]" -map "[v]" -map 1:a -shortest output.mp4

How to extract specific audio track (track 2) from mp4 file using ffmpeg?

I am working on a mp4 file (36017P.mp4) in which I want to extract Track 2 -[English] using ffmpeg.
I tried with the following command on terminal but it seems to extract Track 1 - [English]:
ffmpeg -i 36017P.mp4 filename.mp3
Problem Statement:
I am wondering what changes I need to make in the ffmpeg command above so that it extract Track 2 -[English] from mp4 file.
The -map option will do what you want. Below in -map 0:a:1 the 0 refers to the first (and only) input file. a refers to the audio channels and the next number - 1 here - selects a specific audio stream, starting from 0:
ffmpeg -i 36017P.mp4 -map 0:a:0 filename1.mp3
ffmpeg -i 36017P.mp4 -map 0:a:1 filename2.mp3
ffmpeg -i 36017P.mp4 -map 0:a:2 filename3.mp3
ffmpeg -i 36017P.mp4 -map 0:a:3 filename4.mp3
For further details, see section 5.11 Advanced options in the ffmpeg docs.

ffmpeg - remuxing a TS file with multiple audio streams

Hi newbie ffmpeg user here with ffmpeg v3.2.4 on a Win7 Ultimate x64 PC.
I have a number of .TS files which I'm trying to remux to .MP4. In addition to the video stream and the usual audio stream, some have two audio streams, where the first is a Narrative (NAR) stream and the second is the actual audio content I want. When remuxing using the command line
ffmpeg -i input.ts -c copy output.mp4
ffmpeg uses the NAR stream instead of the second audio stream. How do I get it to use the second audio stream instead please?
Many thanks
Alan
To copy all streams
ffmpeg -i input.ts -map 0 -c copy output.mp4
To copy all audio streams
ffmpeg -i input.ts -map 0:v -map 0:a -c copy output.mp4
To copy only 2nd audio stream
ffmpeg -i input.ts -map 0:v -map 0:a:1 -c copy output.mp4

Resources