0

I'm trying to extract 3 hours and a half from a MKV file 15Gb big whose total duration is around 12:48:00. The final goal is to have the audio synchronized with video on this extracted segment but I'm cutting it because what comes before is not of my interest.

I'm using this command

sudo ffmpeg -i input.mkv -ss 08:57:00 -to 12:48:30 output.mkv

but after ffmpeg starts it stays for ages at this point (I waited for 20 minutes)

frame=    0 fps=0.0 q=0.0 size=       5kB time=00:00:00.00 bitrate=N/A

at 95% CPU (RAM is 8Gb but I never go below 20% of free RAM) till I eventually kill the process. I have no problem with other video files up to 30 minutes so this is the first time I'm using ffmpeg to process with huge videos.

Below a more detailed output

axl@server:/test$ sudo ffmpeg -i input.mkv -ss 08:57:00 -to 12:48:30 output.mkv
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from 'input.mkv':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 12:48:41.43, start: 0.000000, bitrate: 2638 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      DURATION        : 12:48:41.433000000
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 12:48:41.365000000
File 'output.mkv' already exists. Overwrite ? [y/N] y
[libx264 @ 0x1266f40] using SAR=1/1
[libx264 @ 0x1266f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
[libx264 @ 0x1266f40] profile High, level 4.0
[libx264 @ 0x1266f40] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'output.mkv':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 1k tbn, 30 tbc (default)
    Metadata:
      DURATION        : 12:48:41.433000000
      encoder         : Lavc56.60.100 libx264
    Stream #0:1: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 12:48:41.365000000
      encoder         : Lavc56.60.100 libvorbis
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=0.0 size=       5kB time=00:00:00.00 bitrate=N/A

Is there any better option to accomplish my task with ffmpeg? Shall I have a different approach in just extracting that part of the video?

5
  • Try ffmpeg -ss 08:57:00 -to 12:48:30 -i input.mkv -c copy output.mkv (mind the order) or ffmpeg -ss 08:57:00 -i input.mkv -to 03:51:30 -c copy output.mkv (mind the order); btw it's 3 hours 51 minutes 30 seconds of video instead of 3.5 hours, right?
    – Tom Yan
    Apr 8, 2021 at 5:25
  • There's also mkvtoolnix (either with GUI or mkvmerge), although I'm not sure if it can skipping outputting the unwanted pieces.
    – Tom Yan
    Apr 8, 2021 at 5:28
  • @TomYan: thanks! ffmpeg -ss 08:57:00 -i input.mkv -to 03:51:30 -c copy output.mkv did the trick. Apr 8, 2021 at 8:38
  • Indeed frame=417295 fps=5522 q=-1.0 Lsize= 4468576kB time=03:51:41.38 bitrate=2633.3kbits/s Apr 8, 2021 at 8:39
  • @TomYan: I answered my own post but maybe you may want to put your suggestion as answer. Let me know :-) Apr 8, 2021 at 8:55

1 Answer 1

0

Thanks to Tom Yan; the order matters (though I always thouth that ss and to could just be referred to input file)

ffmpeg -ss 08:57:00 -i input.mkv -to 03:51:30 -c copy output.mkv

You must log in to answer this question.

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