0

When I try cutting a video, it outputs an empty stream (262 byte video with 0s duration). Would appreciate any insight, thanks.

Command used: ffmpeg -i /path/to/long/video.mp4 -ss 37.69 -t 4.96 -c copy /path/to/short/video.mp4

However, when I the following (more inaccurate) command, it outputs a video. This video also has some problems, as the last frame is repeated several times, making the video one second longer (with a frozen image for one second).

ffmpeg -ss 37.69 -i /path/to/long/video.mp4 -t 4.96 -c copy /path/to/short/video.mp4

ffmpeg version: ffmpeg version 3.4.6-0ubuntu0.18.04.1

The outputs for the two commands are:

First command:

  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --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-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --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-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/proj/vondrick/datasets/HowTo100M/video/Cars_&_Other_Vehicles/Motorcycles/52907/video_nVbIUDjzWY4.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    creation_time   : 2015-06-26T00:39:04.000000Z
  Duration: 00:07:14.40, start: 0.000000, bitrate: 244 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2015-06-26T00:39:04.000000Z
      handler_name    : VideoHandler
Output #0, mp4, to '/proj/vondrick/datasets/HowTo100M/cropped_video/Cars_&_Other_Vehicles/Motorcycles/52907/nVbIUDjzWY4/video_000000_p.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], q=2-31, 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      creation_time   : 2015-06-26T00:39:04.000000Z
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Second command:

ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --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-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --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-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/proj/vondrick/datasets/HowTo100M/video/Cars_&_Other_Vehicles/Motorcycles/52907/video_nVbIUDjzWY4.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    creation_time   : 2015-06-26T00:39:04.000000Z
  Duration: 00:07:14.40, start: 0.000000, bitrate: 244 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2015-06-26T00:39:04.000000Z
      handler_name    : VideoHandler
Output #0, mp4, to '/proj/vondrick/datasets/HowTo100M/cropped_video/Cars_&_Other_Vehicles/Motorcycles/52907/nVbIUDjzWY4/video_000000_3.mp4':
  Metadata:
    major_brand     : dash
    minor_version   : 0
    compatible_brands: iso6avc1mp41
    encoder         : Lavf57.83.100
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], q=2-31, 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc (default)
    Metadata:
      creation_time   : 2015-06-26T00:39:04.000000Z
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  159 fps=0.0 q=-1.0 Lsize=     159kB time=00:00:04.95 bitrate= 263.0kbits/s speed=1.89e+03x    
video:158kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.909119%
dscv
  • 3
  • 2
  • What happens when you convert the times to a timecode? I usually cut like this `-ss 00:00:37 -t 00:00:04`. if you need to cut to a specific frame there are other options with ffmpeg but it takes longer because it seeks frame-by-frame. You could also try the `-to` option instead if timecodes are too much work https://superuser.com/a/141343/875181 – chrisbyte Dec 16 '19 at 22:05
  • Using the timecode format you propose I get the same result, this is, the output stream is empty – dscv Dec 16 '19 at 22:12
  • Does this answer your question? [Cutting the videos based on start and end time using ffmpeg](https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg) – szatmary Dec 16 '19 at 23:55

1 Answers1

0

Two issues:

  1. 3.4 is old. Update to a recent build before doing anything else. For Linux you can download or compile.

  2. Cuts are not guaranteed to be accurate when using stream copy mode (-c copy) with H.264 and other similar formats because it will need to include all of the other frames necessary to decode the segment. So either cut on keyframes or re-encode by removing -c copy.

llogan
  • 87,794
  • 21
  • 166
  • 190