The scale
filter can do this :
if you want resize your input video to specific size such as 640x480 regardless of it's size and Aspect Ratio, then:
ffmpeg -i INPUT -filter_complex [0:v]scale=640:480[Scaled] -map [Scaled] OUTPUT
.
but, not preserving Aspect Ratio may result ugly videos. so if you want resize your input video and preserve Aspect Ratio, then specify one of dimensions and put -2
for other:
ffmpeg -i INPUT -filter_complex [0:v]scale=-2:480[Scaled] -map [Scaled] OUTPUT
.
(and 3.) Concatenating multiple streams can be done by concat
filter:
Below command will merge three video sreams (will drop audio streams if thay exist):
ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex [0:v][1:v][2:v]concat=n=3:v=1:a=0[Merged] -map [Merged] OUTPUT
.
The whole command that do for you, will be something like below:
ffmpeg -i VideoBefore.mp4 -i MainVideo.mp4 -i VideoAfter.mp4 -i Audio.mp3 -filter_complex [1:v]scale=-2:480,setsar=sar=1[Scaled];[0:v][Scaled][2:v]concat=n=3:v=1:a=0[Merged] -map [Merged] -map 3:a OUTPUT.mp4
Important note : The concat
filter documentation says : All corresponding streams must have the same parameters in all segments; the filtering system will automatically select a common pixel format for video streams, and a common sample format, sample rate and channel layout for audio streams, but other settings, such as resolution, must be converted explicitly by the user. The SAR
(Sample Aspect Ratio) attribute is 1:1 often. but scale
filter will change it. and we need to change it again to be equal to other streams. the setsar
filter do it.
Does concatenating work for you? If so, you could simply concat file 1 and 2, and then concat file 3 with the result from the first operation. To mux audio in, combine the complete video file with an audio track using the
-map
option, and-c copy
. Maybe you can [edit] your question and show us what exactly you have. I just found concatenating to be a little difficult. Especially if it's MP4 or MKV, and the bitstreams are of the same format, you might want to look into MP4box or mkvtoolnix for file concatenation instead of FFmpeg. – slhck – 2012-11-25T10:12:34.1735Ah, great! Can you post the correct answer below, please? This way, others can benefit from the solution; you can even accept the answer – slhck – 2012-11-26T05:19:36.193