0

Basically I was following https://video.stackexchange.com/a/15701/26767, which states:

This should work faster...

ffmpeg -ss 1:00 -t 5 -i in.mkv -ss 2:00 -t 5 -i in.mkv \
 -filter_complex "[0][1]concat=n=2:v=1:a=1" \ 
 out.mkv

Is it really working? Or how can I make it works for nowadays ffmpeg?

First, I found the command there is incorrect, as I'm getting this:

$ ffmpeg -codec copy -i inp.mp4 clip1.mp4
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Unknown decoder 'copy'

I found this works: ffmpeg -i inp.mp4 -codec copy clip1.mp4

Then when I want to put things together, I got Unknown decoder 'copy' again:

$ ffmpeg -i inp.mp4 -ss 1:09 -t 76 -codec copy -i inp.mp4 -ss 2:55 -codec copy -filter_complex "[0][1]concat=n=2:v=1:a=1" out.mp4
ffmpeg version 4.2.2-1ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-3ubuntu1)
. . .
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'inp.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2018-03-08T18:56:55.000000Z
  Duration: 00:03:46.81, start: 0.000000, bitrate: 3137 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2943 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      creation_time   : 2018-03-08T18:57:03.000000Z
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Unknown decoder 'copy'

How can I make the 5-year-old answer works for nowadays ffmpeg without re-encoding?

0
0

You should put -i in.mkv for the first place. Please try

ffmpeg -i in.mkv -ss 1:00 -t 5 -ss 2:00 -t 5 

I think your code have multiple "-i in.mkv" parts. Remove all but one "-i

Edit: Then I think the easiest way is :

ffmpeg -i in.mkv -ss 1:00 -t 5 -c copy clip1.mkv
ffmpeg -i in.mkv -ss 2:00 -t 5 -c copy clip2.mkv
echo file clip1.mkv >> mylist.txt
echo file clip2.mkv >> mylist.txt
ffmpeg -f concat -i mylist.txt -c copy out.mkv
rm mylist.txt

Just make two clips from the original video "in.mkv" and just concat them in the usual ffmpeg concat way.

1
  • Thanks for the input, Tom. Please note the phrase "when concatenating clips" in the title -- the multiple "-i in.mkv" parts is just for that, as I tried yours but only single clip is cut, not both. Try it yourself, and you'll know. Thanks for the input anyway, and welcome aboard.
    – xpt
    Oct 13 at 21:17

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.