FFMPEG附加文件作为元数据 [英] FFMPEG attach file as metadata

查看:253
本文介绍了FFMPEG附加文件作为元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组图像,我想使用ffmpeg转换为视频。以下命令工作正常:

I have a set of images which I want to convert to a video using ffmpeg. The following command works perfectly fine:

ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 testout.mkv

我有一个二进制文件中的一些元数据,我想附加视频。我试着做以下,但它给我一个错误:

I have some meta data in a binary file which I want to attach with the video. I tried doing the following, but it gives me an error:

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

这是错误:

[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

如果有人可以向我解释我做错了什么,这将是美好的:)

It would be wonderful if somebody can explain to me what am I doing wrong :)

推荐答案

你需要要正确指定您的流



示例:

You need to specify your stream properly

Example:

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

此命令将为所有附件( t )流设置元数据(<$ c $ ç>取值)。如果您有多个附件,并且元数据不同,则必须更具体,例如:

This command will set the metadata for all attachment (t) streams (s). If you have more than one attachment, and the metadata are different, then you will have to be more specific, such as:

-metadata:s:t:0 mimetype=text/plain \
-metadata:s:t:1 mimetype=application/gzip

这将把第一个附件的元数据设置为 mimetype = text / plain ,第二个为的mimetype =应用/ gzip的。请记住,流索引从 0 开始,所以第一个蒸汽被标记为 0

This will set the metadata for the first attachment as mimetype=text/plain, and the second as mimetype=application/gzip. Remember that the stream index starts at 0, so the first steam is labeled 0.

使用 -metadata:s:2 无论流类型(因为没有说明符都存在),但是您的输出只包含两个流,所以设置第三个流的元数据。

Using -metadata:s:2 (which appears to have been copied verbatim from the documentation) sets the metadata for the third stream, regardless of stream type (because no specifier is present), but your output only contained two streams.

您可能会看到以下内容:

You may see something like this:

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

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

Attachment: none does not mean that there is no attachment, but that there is no format associated with it, so it can be ignored.

流说明符 ffmpeg 文档 -attach -metadata -map_metadata 更多细节。

Stream specifiers and the ffmpeg documentation on -attach, -metadata, and -map_metadata for more details.

这篇关于FFMPEG附加文件作为元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆