I've managed to put together an ffmpeg filter complex which:
- Scales an FBI warning (fbi.mp4) to the size ($w:$h) of a training video (train.mp4).
- Pads the FBI warning so it's centered.
- Concats the FBI warning and training video together.
- Stamps the content with a rotated watermark (image.png).
The following works on silent videos (*see version information for ffmpeg below):
ffmpeg -y -i fbi.mp4 -i train.mp4 -i $img -filter_complex "
[0:v] scale=$w:-1 [fbi_sca];
[fbi_sca] pad=$w:$h:($w-iw)/2:($h-ih)/2 [fbi_pad];
[fbi_pad][1:v] concat=n=2:v=1 [concat];
[2:v] rotate=-PI/4:c=none:ow=rotw(iw):oh=roth(ih) [rotate];
[concat][rotate] overlay=(W-w)/2+110:(H-h)/2-90 [out]
" -map [out] -codec:a copy -c:v libx264 final.mp4
My questions are as follows:
Can someone rewrite the above command / filter_complex to:
Automatically get the width and height of the training video (train.mp4) without first having to probe it, parse it, and fill the variables $w and $h (it's okay if I have to do this in a separate step, but I'd prefer not to).
(More importantly) Account for both video and audio in the training video such that:
a. The filter is agnostic about which streams, 1 or 0, the video and audio appear in.
b. I can use the same complex for training videos that have no audio track only a video track.
c. The train.mp4 audio begins in the right place in the concatenated output.
*FFMPEG VERSION:
$ ffmpeg -version
ffmpeg version N-69568-g21051af Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 18.100 / 54. 18.100
libavcodec 56. 21.102 / 56. 21.102
libavformat 56. 19.100 / 56. 19.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 9.103 / 5. 9.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
-map 0:a
or something like that (depending on which file contains the audio. Well, that is to answer to your title question, I do not know about answers to 1. and 2.