ffmpeg - 剪切而不重新编码和奇怪的行为:应用程序提供的持续时间超出了 mov/mp4 格式的范围

ffmpeg - 剪切而不重新编码和奇怪的行为:应用程序提供的持续时间超出了 mov/mp4 格式的范围

在 Ubuntu 18.04 中,我经常使用以下命令来修剪视频的一部分,而无需重新编码(这意味着没有任何质量损失)。

ffmpeg -ss 00:06:00 -i DSCF5984.MOV -t 00:07:00 -c copy DSCF5984_A_wszystkie.MOV

不久前我换到了 Ubuntu 22.04。仍然使用相同的摄像机并使用相同的录制格式,当使用上述命令时,我收到了非常奇怪的错误,并且行为是意外的。在这种情况下,mov 文件是 40 秒的文件。我想从第 6 秒开始获取 7 秒的片段(因此从 6 秒到 13 秒)。但事实并非如此,我从文件开头获得了非常短的片段。我甚至不知道它有多长,因为没有视频播放器愿意显示它的长度。可能是 1-2 秒。因此,不仅我收到了这个错误,而且 ffmpeg 也不起作用。理论上,我有适用于 ubuntu 22.04 的最新版本。

ffmpeg 显示的消息

ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'DSCF5984.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2023-08-12T23:07:18.000000Z
    original_format : Digital Camera
    original_format-eng: Digital Camera
    comment         : FUJIFILM DIGITAL CAMERA X-S10
    comment-eng     : FUJIFILM DIGITAL CAMERA X-S10
  Duration: 00:00:40.04, start: 0.000000, bitrate: 105270 kb/s
  Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt709/smpte170m), 3840x2160, 101873 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2023-08-12T23:07:18.000000Z
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
      timecode        : 07:05:54;21
  Stream #0:1(eng): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      creation_time   : 2023-08-12T23:07:18.000000Z
      vendor_id       : [0][0][0][0]
      timecode        : 07:05:54;21
  Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2023-08-12T23:07:18.000000Z
      timecode        : 07:05:54;21
[mov @ 0x55a005fa6e40] Application provided duration: -9223372036854775808 / timestamp: -9223372036854775808 is out of range for mov/mp4 format
[mov @ 0x55a005fa6e40] pts has no value
Output #0, mov, to 'DSCF5984_A_wszystkie.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    comment-eng     : FUJIFILM DIGITAL CAMERA X-S10
    original_format : Digital Camera
    original_format-eng: Digital Camera
    comment         : FUJIFILM DIGITAL CAMERA X-S10
    encoder         : Lavf58.76.100
  Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt709/smpte170m), 3840x2160, q=2-31, 101873 kb/s, 0.03 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2023-08-12T23:07:18.000000Z
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding
      timecode        : 07:05:54;21
  Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, stereo, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      creation_time   : 2023-08-12T23:07:18.000000Z
      vendor_id       : [0][0][0][0]
      timecode        : 07:05:54;21
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   30 fps=0.0 q=-1.0 Lsize=   13475kB time=-00:05:19.97 bitrate=N/A speed=N/A    
video:13191kB audio:282kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019629%

这是错误吗?还是我应该做些不同的事情?我很惊讶,因为我没有更换相机。那么 ffmpeg 中是否有变化?

答案1

-ss当and-t-c copyor一起使用时经常会发生这种情况-codec copy

命令的修改版本:

ffmpeg -ss 00:06:00 -i DSCF5984.MOV -t 00:07:00 -c:a copy DSCF5984_A_wszystkie.MOV

取自Behroozfar 的回答

相关内容