ffmpeg:“无法找到编解码器无的标签”

ffmpeg:“无法找到编解码器无的标签”

为了节省 NAS 空间,我最近使用以下命令压缩了一些智能手机视频:

ffmpeg -hide_banner -y -i in_filename -map 0 -map_metadata 0 -c copy -c:a libvorbis -q:a 4 -c:v libx264 -crf 23 -preset slow -max_muxing_queue_size 4096 -movflags +faststart out_file.mp4

这个过程完美无缺,复制了所有数据流和元数据,并使用指定的编解码器压缩了视频和音频。不幸的是,由于 mp4 容器中不正式支持 vorbis,因此某些播放器无法播放这些文件的声音。因此,我想重新混合这些文件,我仍然可以使用这些文件的原始文件:

ffmpeg -hide_banner -y -i original.mp4 -i compressed.mp4 -map 1:v -map 0:a -map 0:s? -map 0:d? -map 0:t? -map_metadata 0 -c copy out.mp4

这应该

  • 从 ffmpeg 创建的压缩版本中获取所有视频流
  • 从原始文件中提取所有音频流
  • 从原始文件中获取所有字幕、数据和附件流
  • 从原始文件中获取所有元数据

然而,转换失败并出现错误

Could not find tag for codec none in stream #2

由于我已经使用此文件创建了压缩版本,所以我很困惑为什么现在会出现编解码器标签错误。使用-copy_unknown、 或 也-ignore_unknown无济于事。当我再次尝试我的原始命令时,我也会收到此错误,所以我真的很想知道,我最初是如何创建“压缩”文件的。这一定是可能的……

“原始”文件和“压缩”文件的编解码器信息:

Stream #0:2(eng): Data: none (urim / 0x6D697275), 38 kb/s (default)
Stream #0:2(eng): Data: none (stts / 0x73747473), 38 kb/s (default)

仅供参考:我想重新混合现有的压缩视频和原始音频,以加快处理速度并防止生成丢失。作为替代方案,我可以处理原始文件或压缩文件,并分别仅编码视频或音频。但是,就目前情况而言,我无法处理任何一个文件,否则会丢失“数据”流,如果可能的话,我希望避免这种情况。

有什么意见吗?

如果有帮助的话,这里是完整的输出:

ffmpeg -y -i original.mp4 -map 0 -map_metadata 0 -c copy -c:a libvorbis -aq 4 -c:v libx264 -crf 23 -preset slow -max_muxing_queue_size 4096 -movflags +faststart out.mp4
ffmpeg version git-2020-05-04-5767a2e Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200328
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 43.100 / 56. 43.100
  libavcodec     58. 82.100 / 58. 82.100
  libavformat    58. 42.102 / 58. 42.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 80.100 /  7. 80.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'original.mp4':
  Metadata:
    major_brand     : nvr1
    minor_version   : 65537
    compatible_brands: isommp42nvr1
    creation_time   : 2018-10-06T16:49:58.000000Z
    com.android.version: 8.1.0
  Duration: 00:00:33.81, start: 0.000000, bitrate: 20507 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 20022 kb/s, SAR 1:1 DAR 16:9, 29.49 fps, 29.50 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : SoundHandle
    Stream #0:2(eng): Data: none (urim / 0x6D697275), 38 kb/s (default)
    Metadata:
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : MetaHandler
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c:v libx264' will be used.
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 1, only the last option '-c:a libvorbis' will be used.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
[libx264 @ 000001dbc892f140] using SAR=1/1
[libx264 @ 000001dbc892f140] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001dbc892f140] profile High, level 5.0, 4:2:0, 8-bit
[libx264 @ 000001dbc892f140] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 000001dbc988f040] Could not find tag for codec none in stream #2, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Conversion failed!



ffmpeg -y -i compressed.mp4 -map 0 -map_metadata 0 -c copy -c:a libvorbis -aq 4 -c:v libx264 -crf 23 -preset slow -max_muxing_queue_size 4096 -movflags +faststart out.mp4
ffmpeg version git-2020-05-04-5767a2e Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200328
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 43.100 / 56. 43.100
  libavcodec     58. 82.100 / 58. 82.100
  libavformat    58. 42.102 / 58. 42.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 80.100 /  7. 80.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000002c3ca70df00] overread end of atom 'stsd' by 40 bytes
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'compressed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2018-10-06T16:49:58.000000Z
    encoder         : Lavf58.3.100
  Duration: 00:00:33.81, start: 0.000000, bitrate: 10230 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1080x1920 [SAR 1:1 DAR 9:16], 10098 kb/s, 29.50 fps, 29.50 tbr, 15104 tbn, 59 tbc (default)
    Metadata:
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: vorbis (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 88 kb/s (default)
    Metadata:
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : SoundHandler
    Stream #0:2(eng): Data: none (stts / 0x73747473), 38 kb/s (default)
    Metadata:
      creation_time   : 2018-10-06T16:49:58.000000Z
      handler_name    : DataHandler
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option '-c:v libx264' will be used.
Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 1, only the last option '-c:a libvorbis' will be used.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (vorbis (native) -> vorbis (libvorbis))
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
[libx264 @ 000002c3ca7b7440] using SAR=1/1
[libx264 @ 000002c3ca7b7440] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000002c3ca7b7440] profile High, level 5.0, 4:2:0, 8-bit
[libx264 @ 000002c3ca7b7440] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 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=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 000002c3cad94140] Could not find tag for codec none in stream #2, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
[libvorbis @ 000002c3ca74adc0] 32 frames left in the queue on closing
Conversion failed!

进一步阅读 https://trac.ffmpeg.org/ticket/8338 https://trac.ffmpeg.org/ticket/2928 https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-BBCGFJII

答案1

使用:

ffmpeg -i original.mp4 -i compressed.mp4 -map 0 -map -0:v -map 1:v -c copy -movflags +faststart out.mp4

这将复制original.mp4除视频之外的所有流,并且仅复制视频compressed.mp4

答案2

我在 .mov 文件上遇到了类似的问题,并使用以下信息解决了它:https://acassis.wordpress.com/2019/09/28/ffmpeg-conversion-error-could-not-find-tag-for-codec-pcm_s16be/

基本上就是:删除-map 0 -map_metadata 0 -c 复制(我的情况是 -codec,但它与 -c 相同,并且删除 -copy_unknown,尽管在您的情况下您没有使用它)标志,并在转换后检查视频和音频是否正常:如果正常,则它卡在了不需要的数据上!

我正在使用:

ffmpeg -I "moviefiletocompress.mov" -copy_unknown -map_metadata 0 -map 0 -codec copy -tag:v hvc1 -codec:v libx265 -x265-params crf="26" -codec:a aac -preset fast "compressedfile-ffmpeg-h265-crf26.mp4"

然后使用以下方法解决:

ffmpeg -I "moviefiletocompress.mov" -tag:v hvc1 -codec:v libx265 -x265-params crf="26" -codec:a aac -preset fast "compressedfile-ffmpeg-h265-crf26.mp4"

相关内容