FFMPEG附加文件作为元数据

ahm*_*adh 13 ffmpeg attachment

我有一组图像,我想使用ffmpeg转换为视频.以下命令完全正常:

ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 testout.mkv
Run Code Online (Sandbox Code Playgroud)

我在二进制文件中有一些元数据,我想附加视频.我尝试了以下操作,但它给了我一个错误:

ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile -metadata:s:2 mimetype=application/octet-stream testout.mkv
Run Code Online (Sandbox Code Playgroud)

这是错误:

[matroska @ 0x656460] Codec for stream 1 does not use global headers but container format requires global headers
[matroska @ 0x656460] Attachment stream 1 has no mimetype tag and it cannot be deduced from the codec id.
Output #0, matroska, to 'testout.mkv':
  Metadata:
    encoder         : Lavf56.33.101
    Stream #0:0: Video: huffyuv (HFYU / 0x55594648), rgb24, 640x640, q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.39.100 huffyuv
    Stream #0:1: Attachment: none
    Metadata:
      filename        : 2ceb-1916-56bb-3e10
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> huffyuv (native))
  File 2ceb-1916-56bb-3e10 -> Stream #0:1
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Run Code Online (Sandbox Code Playgroud)

如果有人能向我解释我做错了什么会很棒:)

llo*_*gan 7

您需要正确指定您的流

例:

ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile \
-metadata:s:t mimetype=application/octet-stream testout.mkv
Run Code Online (Sandbox Code Playgroud)

此命令将设置所有attachment(t)流(s)的元数据.如果您有多个附件,并且元数据不同,那么您必须更具体,例如:

-metadata:s:t:0 mimetype=text/plain \
-metadata:s:t:1 mimetype=application/gzip
Run Code Online (Sandbox Code Playgroud)

这会将第一个附件的元数据设置为mimetype=text/plain,而第二个附件设置为mimetype=application/gzip.请记住,流索引始于0,因此标记了第一个流0.

你的命令出了什么问题

使用-metadata:s:2(似乎已从文档中逐字复制)设置第三个流的元数据,而不管流类型(因为没有说明符),但您的输出只包含两个流.

附件:无

你可能会看到这样的事情:

Output #0, matroska, to 'output.mkv':
...
    Stream #0:1: Attachment: none
    Metadata:
      filename        : 2ceb-1916-56bb-3e10
      mimetype        : application/octet-stream
Run Code Online (Sandbox Code Playgroud)

Attachment: none 并不意味着没有附件,但没有与之关联的格式,因此可以忽略它.

另见

流符ffmpeg文件-attach,-metadata-map_metadata更多的细节.