FFMPEG 附加文件作为元数据
FFMPEG attach file as metadata
我有一组图像,我想使用 ffmpeg 将其转换为视频。以下命令工作得很好:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 testout.mkv
我在二进制文件中有一些元数据,我想将其附加到视频中。我尝试执行以下操作,但它给了我一个错误:
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
如果有人能向我解释我做错了什么就太好了:)
您需要正确指定流
示例:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile \
-metadata:s:t mimetype=application/octet-stream testout.mkv
此命令将为所有附件 (t
) 流 (s
) 设置元数据。如果您有多个附件,并且元数据不同,那么您必须更具体一些,例如:
-metadata:s:t:0 mimetype=text/plain \
-metadata:s:t:1 mimetype=application/gzip
这会将第一个附件的元数据设置为 mimetype=text/plain
,将第二个附件的元数据设置为 mimetype=application/gzip
。请记住,流索引从 0
开始,因此第一个流标记为 0
.
你的命令有什么问题
使用 -metadata:s:2
(似乎是从文档中逐字复制的)设置第三个流的元数据,无论流类型如何(因为没有说明符),但您的输出仅包含两个流.
附件:None
您可能会看到这样的内容:
Output #0, matroska, to 'output.mkv':
...
Stream #0:1: Attachment: none
Metadata:
filename : 2ceb-1916-56bb-3e10
mimetype : application/octet-stream
Attachment: none
不是说没有附件,而是没有与之关联的格式,可以忽略。
另见
Stream specifiers and the ffmpeg
documentation 在 -attach
、-metadata
和 -map_metadata
上了解更多详情。
我有一组图像,我想使用 ffmpeg 将其转换为视频。以下命令工作得很好:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 testout.mkv
我在二进制文件中有一些元数据,我想将其附加到视频中。我尝试执行以下操作,但它给了我一个错误:
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
如果有人能向我解释我做错了什么就太好了:)
您需要正确指定流
示例:
ffmpeg -y -i frames/%06d.png -c:v huffyuv -pix_fmt rgb24 -attach mybinaryfile \
-metadata:s:t mimetype=application/octet-stream testout.mkv
此命令将为所有附件 (t
) 流 (s
) 设置元数据。如果您有多个附件,并且元数据不同,那么您必须更具体一些,例如:
-metadata:s:t:0 mimetype=text/plain \
-metadata:s:t:1 mimetype=application/gzip
这会将第一个附件的元数据设置为 mimetype=text/plain
,将第二个附件的元数据设置为 mimetype=application/gzip
。请记住,流索引从 0
开始,因此第一个流标记为 0
.
你的命令有什么问题
使用 -metadata:s:2
(似乎是从文档中逐字复制的)设置第三个流的元数据,无论流类型如何(因为没有说明符),但您的输出仅包含两个流.
附件:None
您可能会看到这样的内容:
Output #0, matroska, to 'output.mkv':
...
Stream #0:1: Attachment: none
Metadata:
filename : 2ceb-1916-56bb-3e10
mimetype : application/octet-stream
Attachment: none
不是说没有附件,而是没有与之关联的格式,可以忽略。
另见
Stream specifiers and the ffmpeg
documentation 在 -attach
、-metadata
和 -map_metadata
上了解更多详情。