ffmpeg - 'hevc' 编解码器在复制视频编解码器后更改为 'rawvideo'

ffmpeg - 'hevc' codec changed to 'rawvideo' after copying video codec

我正在尝试将一些使用 hevc 编解码器的 mkv 视频转换为 avi 格式。为此,我 运行 以下命令:

ffmpeg -i input.mkv -vcodec copy -acodec copy out.avi

对于某些视频,此命令没有任何问题。但在某些情况下,视频确实已转换,但我无法在任何视频播放器中播放这些文件。 VLC、SMPlayer、深度影院等多种视频播放器我都试过了

查看转换视频的视频编解码器后,我发现视频编解码器已从 hevc 转换为 rawvideo。 Hers是原视频文件和转换后的视频文件的流信息:

输入文件

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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
[matroska,webm @ 0x561d8e639600] Could not find codec parameters for stream 2 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'PE2_Leopard_4K_hevc_dts.mkv':
  Metadata:
    title           : Planet Earth II S01E01 4K
    encoder         : libebml v1.3.5 + libmatroska v1.4.8
    creation_time   : 2017-10-29T06:31:02.000000Z
  Duration: 00:00:04.22, start: 0.000000, bitrate: 46848 kb/s
    Chapter #0:0: start 0.000000, end 4.216000
    Metadata:
      title           : 00:00:00.000
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS             : 44365437
      BPS-eng         : 44365437
      DURATION        : 00:00:04.212000000
      DURATION-eng    : 00:00:04.212000000
      NUMBER_OF_FRAMES: 101
      NUMBER_OF_FRAMES-eng: 101
      NUMBER_OF_BYTES : 23358403
      NUMBER_OF_BYTES-eng: 23358403
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s16p (default)
    Metadata:
      title           : DTS-HD MA 5.1
      BPS             : 2506995
      BPS-eng         : 2506995
      DURATION        : 00:00:04.214000000
      DURATION-eng    : 00:00:04.214000000
      NUMBER_OF_FRAMES: 395
      NUMBER_OF_FRAMES-eng: 395
      NUMBER_OF_BYTES : 1320560
      NUMBER_OF_BYTES-eng: 1320560
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      title           : English (SDH)
      BPS             : 0
      BPS-eng         : 0
      DURATION        : 00:00:00.000000000
      DURATION-eng    : 00:00:00.000000000
      NUMBER_OF_FRAMES: 0
      NUMBER_OF_FRAMES-eng: 0
      NUMBER_OF_BYTES : 0
      NUMBER_OF_BYTES-eng: 0
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

输出文件

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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
Input #0, avi, from 'out3.avi':
  Metadata:
    title           : Planet Earth II S01E01 4K
    encoder         : Lavf58.29.100
  Duration: 00:00:04.27, start: 0.000000, bitrate: 44226 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 3840x2160, 44803 kb/s, SAR 1:1 DAR 16:9, 47.95 fps, 47.95 tbr, 47.95 tbn, 47.95 tbc
    Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, 5.1(side), fltp, 394 kb/s
    Metadata:
      title           : DTS-HD MA 5.1

命令日志

ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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
[matroska,webm @ 0x55d6eebb8700] Could not find codec parameters for stream 2 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'PE2_Leopard_4K_hevc_dts.mkv':
  Metadata:
    title           : Planet Earth II S01E01 4K
    encoder         : libebml v1.3.5 + libmatroska v1.4.8
    creation_time   : 2017-10-29T06:31:02.000000Z
  Duration: 00:00:04.22, start: 0.000000, bitrate: 46848 kb/s
    Chapter #0:0: start 0.000000, end 4.216000
    Metadata:
      title           : 00:00:00.000
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Metadata:
      BPS             : 44365437
      BPS-eng         : 44365437
      DURATION        : 00:00:04.212000000
      DURATION-eng    : 00:00:04.212000000
      NUMBER_OF_FRAMES: 101
      NUMBER_OF_FRAMES-eng: 101
      NUMBER_OF_BYTES : 23358403
      NUMBER_OF_BYTES-eng: 23358403
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s16p (default)
    Metadata:
      title           : DTS-HD MA 5.1
      BPS             : 2506995
      BPS-eng         : 2506995
      DURATION        : 00:00:04.214000000
      DURATION-eng    : 00:00:04.214000000
      NUMBER_OF_FRAMES: 395
      NUMBER_OF_FRAMES-eng: 395
      NUMBER_OF_BYTES : 1320560
      NUMBER_OF_BYTES-eng: 1320560
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle
    Metadata:
      title           : English (SDH)
      BPS             : 0
      BPS-eng         : 0
      DURATION        : 00:00:00.000000000
      DURATION-eng    : 00:00:00.000000000
      NUMBER_OF_FRAMES: 0
      NUMBER_OF_FRAMES-eng: 0
      NUMBER_OF_BYTES : 0
      NUMBER_OF_BYTES-eng: 0
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Output #0, avi, to 'output.avi':
  Metadata:
    INAM            : Planet Earth II S01E01 4K
    ISFT            : Lavf58.29.100
    Chapter #0:0: start 0.000000, end 4.216000
    Metadata:
      title           : 00:00:00.000
    Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 47.95 tbn, 47.95 tbc (default)
    Metadata:
      BPS             : 44365437
      BPS-eng         : 44365437
      DURATION        : 00:00:04.212000000
      DURATION-eng    : 00:00:04.212000000
      NUMBER_OF_FRAMES: 101
      NUMBER_OF_FRAMES-eng: 101
      NUMBER_OF_BYTES : 23358403
      NUMBER_OF_BYTES-eng: 23358403
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: dts (DTS-HD MA) ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), s16p (default)
    Metadata:
      title           : DTS-HD MA 5.1
      BPS             : 2506995
      BPS-eng         : 2506995
      DURATION        : 00:00:04.214000000
      DURATION-eng    : 00:00:04.214000000
      NUMBER_OF_FRAMES: 395
      NUMBER_OF_FRAMES-eng: 395
      NUMBER_OF_BYTES : 1320560
      NUMBER_OF_BYTES-eng: 1320560
      _STATISTICS_WRITING_APP: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v16.0.0 ('Protest') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2017-10-29 06:31:02
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-10-29 06:31:02
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  101 fps=0.0 q=-1.0 Lsize=   28904kB time=00:00:04.20 bitrate=56322.1kbits/s speed= 119x    
video:22811kB audio:1290kB subtitle:0kB other streams:0kB global headers:1kB muxing overhead: 19.929108%

如何解决这个问题?

不要使用 AVI

AVI 不适用于 HEVC。
使用现代输出容器格式,例如 MP4、MOV 或 MKV。

如果您需要 AVI

解决方法是添加 -vtag hvc1 输出选项。

ffmpeg -i input.mkv -c copy -vtag hvc1 out.avi

或者告诉ffmpegAVI有HEVC视频:

ffmpeg -c:v hevc -i input.avi