0

I've managed to put together an ffmpeg filter complex which:

  1. Scales an FBI warning (fbi.mp4) to the size ($w:$h) of a training video (train.mp4).
  2. Pads the FBI warning so it's centered.
  3. Concats the FBI warning and training video together.
  4. 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:

  1. 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).

  2. (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
1
  • I think you might be missing -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.
    – sup
    Jul 25, 2015 at 18:32

1 Answer 1

2

I also had the same issue, I have a way where I am able to append audio back to this filter,simply add

[0:a]aresample=44100;

It will resample audio at 44100 Hz(Change this value as per need) but Yes audio will now be there.Hope it helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .