7

I have a video of 5s length. The final video should be 60s long. The resulting video should be a "ping pong" loop, meaning my 5s should be played back and forth until the 60s are reached.

Does someone know the ffmpeg magic to do this?

My ffmpeg version:

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.3.0 (clang-703.0.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
2
  • "ping pong" you mean played forwards, then backwards, then forwards etc? – DavidPostill Jun 15 '16 at 10:46
  • @DavidPostill yes exactly :) – soupdiver Jun 15 '16 at 11:23
13

Use

ffmpeg -i input.mp4 \
       -filter_complex "[0]reverse[r];[0][r]concat,loop=5:250,setpts=N/25/TB" output.mp4

In loop=5:250, 5 is number of loops, 250 isframe rate x double length of clip. The setpts is applied to avoid frame drops, and the value 25 should be replaced with the framerate of the clip.

5
  • Trying this I get: [AVFilterGraph @ 0x7fdd02c16900] No such filter: 'loop' On this thread video.stackexchange.com/questions/12905/… it is mentioned that the loop filter only applies for images/gifs? – soupdiver Jun 16 '16 at 11:04
  • 1
    Looks like you have an old version. The loop filter was added in mid-Feb. – Gyan Jun 16 '16 at 11:28
  • I added info about my ffmpeg version – soupdiver Jun 16 '16 at 11:44
  • 1
    Loop filter was added on Feb 18, and your binary's codebase is Feb 14. You'll need a recent nightly. – Gyan Jun 16 '16 at 11:49
  • I am using compile 'com.writingminds:FFmpegAndroid:0.3.2' in android but error [AVFilterGraph @ 0xab008040] No such filter: 'loop' how i am resolve – Er. Arjun saini Apr 5 '18 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.