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

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

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 - add 3 audio streams to video

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

How to append 2 seconds of silence to an existing movie MP4 with ffmpeg?

I would like to append 2 seconds of silence to an existing video using ffmpeg.
I would like to keep the last frame displayed while the 2 seconds of video playsback not a black screen.
Thank you.
Use the tpad and apad filters:
ffmpeg -i input.mp4 -filter_complex "[0:v]tpad=stop_mode=clone:stop_duration=2[v];[0:a]apad=pad_dur=2[a]" -map "[v]" -map "[a]" output.mp4
A faster, but less compatible method is to stream copy the video and use the apad filter if your player and output container format supports dissimilar stream durations:
ffmpeg -i input.mp4 -filter_complex "[0:a]apad=pad_dur=2[a]" -map 0:v -map "[a]" -c:v copy output.mp4
If in doubt use the first command.

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

ffmpeg merge silent video with another video+audio

I want to create, in a single command, a video from 3 sources:
a silent background video;
a smaller video to be overlayed (same length of 1), KEEPING its AUDIO;
a PNG logo to be overlayed
I can create the video but cannot get the audio track. I don't understand if -vf is supposed to work in this case. This is what I've tried to do :
ffmpeg.exe -y -i MASTER_SILENT_VIDEO.mp4 -vf "movie=SMALLER_VIDEO_WITH_AUDIO.flv, scale=320:-1[inner];movie=MY_LOGO.png[inner2]; [in][inner] overlay=800:480,amerge [step1]; [step1][inner2] overlay=30:30 [out]" completed.mp4
The "amerge" filter should do the audio merging job, but of course it doesn't work. I've found similar questions involving -map or filtergraph but they refer to mixing a video source and an audio source; I tried several filtergraph examples without success. Any idea?
overlay one video over other using audio from one input
Use -filter_complex, eliminate the movie source filters, and explicitly define output streams with -map:
ffmpeg -y -i main.mp4 -i overlay_with_audio.flv -i logo.png -filter_complex
"[1:v]scale=320:-1[scaled];
[0:v][scaled]overlay=800:480[bg];
[bg][2:v]overlay=30:30,format=yuv420p[video]"
-map "[video]" -map 1:a -movflags +faststart
output.mp4
You may have to provide additional options to the overlay filters depending on the length of the inputs and how you want overlay to react, but because you did not provide the complete console output from your command I had to make a generic, less efficient, and possibly incorrect example.
overlay one video over other merging audio from both inputs
ffmpeg -y -i main.mp4 -i overlay_with_audio.flv -i logo.png -filter_complex
"[1:v]scale=320:-1[scaled];
[0:v][scaled]overlay=800:480[bg];
[bg][2:v]overlay=30:30,format=yuv420p[video];
[0:a][1:a]amerge=inputs=2[audio]"
-map "[video]" -map "[audio]" -ac 2 -movflags +faststart
output.mp4
I'm assuming both inputs are stereo and that you want a stereo output. Also see FFmpeg Wiki: Audio channel Manipulation - 2 × stereo → stereo.

Resources