2

I'm trying to use ffmpeg to import three files, two videos and one audio. I want to slow down the first video, then replace its audio with the audio file, then add a video onto the end of the result.

Here's what I have so far, and it definitely doesn't work. I'm having a hard time using two filters to get my slow motion and concat together.

ffmpeg -i /Users/dailyops/Desktop/source0.mp4 -i /Users/dailyops/Desktop/music.m4a -i /Users/dailyops/Desktop/outro.mp4 -vf [0:v]setpts=3*PTS [v0] -filter_complex [v0][1:a:0][2:v:0][2:a:0]concat=n=2:v=1:a=1[v1][a] -map [v1] -map [a] -shortest -vcodec libx264 -preset ultrafast -crf 22 -pix_fmt yuv420p -r 29.97 /Users/dailyops/Desktop/output1.mp4

Is this at all close to workable?

The command results in the following:

ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --disable-lzma --enable-nonfree --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/dailyops/Desktop/source0.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2017-04-15T07:07:08.000000Z
  Duration: 00:03:20.81, start: 0.000000, bitrate: 1081 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 951 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2017-04-15T07:07:08.000000Z
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2017-04-15T07:07:08.000000Z
      handler_name    : ISO Media file produced by Google Inc.
[aac @ 0x7fb2718a9800] Assuming an incorrectly encoded 7.1 channel layout instead of a spec-compliant 7.1(wide) layout, use -strict 1 to decode according to the specification instead.
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/dailyops/Desktop/music.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2015-12-16T22:35:44.000000Z
    iTunSMPB        :  00000000 00000DFD 0000034B 00000000000B0EB8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
  Duration: 00:00:16.53, start: 0.081202, bitrate: 243 kb/s
    Stream #1:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 7.1, fltp, 241 kb/s (default)
    Metadata:
      creation_time   : 2015-12-16T22:35:44.000000Z
      handler_name    : Core Media Audio
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/dailyops/Desktop/outro.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2017-07-04T19:21:14.000000Z
    encoder         : HandBrake 1.0.7 2017040900
  Duration: 00:00:06.06, start: 0.000000, bitrate: 1153 kb/s
    Stream #2:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1036 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2017-07-04T19:21:14.000000Z
      handler_name    : VideoHandler
    Stream #2:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 112 kb/s (default)
    Metadata:
      creation_time   : 2017-07-04T19:21:14.000000Z
      handler_name    : Stereo
[NULL @ 0x7fb272000000] Unable to find a suitable output format for '[v0]'
[v0]: Invalid argument
1
  • @slhck Okay, I rearranged setpts and also amended my initial post with the full resulting output in Terminal. What am I missing? Also, thank you! Jul 5, 2017 at 15:26

1 Answer 1

2

There is no need for a separate -vf filter; you can do everything with -filter_complex. (In fact, you have to, when you want to use that output further, as is the case with v0.)

When you construct a -filter_complex command, put it in quotes. The same goes for the output labels when using -map. Otherwise your shell might interpret those characters before ffmpeg sees them.

ffmpeg -i /Users/dailyops/Desktop/source0.mp4 \
-i /Users/dailyops/Desktop/music.m4a \
-i /Users/dailyops/Desktop/outro.mp4 \
-filter_complex "[0:v]setpts=3*PTS[v0]; \
[v0][1:a:0][2:v:0][2:a:0]concat=n=2:v=1:a=1[v1][a]" \
-map "[v1]" -map "[a]" \
-shortest -vcodec libx264 -preset ultrafast -crf 22 -pix_fmt yuv420p -r 29.97 \
/Users/dailyops/Desktop/output1.mp4
1
  • Perfect! Exactly what I needed! I was having troubles passing from one filter to the next. I'm still new to ffmpeg, so I wasn't quite sure how to accomplish that. Thank you good sir! Jul 5, 2017 at 19:29

You must log in to answer this question.

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