首页 > 解决方案 > 使用ffmpeg从视频中提取帧 - 标题问题?

问题描述

我想将来自相机陷阱的 .AVI 文件转换为单个帧,最好使用 ffmpeg。到目前为止,我还没有成功。

我尝试过的最简单的方法是尝试定位问题,这是(我想要所有帧,我的测试文件是 test.avi):

ffmpeg -i test.avi output_%04d.png

它失败并显示以下控制台消息:

[avi @ 0x559fb596f8c0] unknown stream type 73647578
[avi @ 0x559fb596f8c0] Something went wrong during header parsing, tag [0][0]id has size 338702712, I will ignore it and try to continue anyway.
[mjpeg @ 0x559fb59709e0] No JPEG data found in image
    Last message repeated 100 times
[avi @ 0x559fb596f8c0] decoding for stream 0 failed
[avi @ 0x559fb596f8c0] Could not find codec parameters for stream 0 (Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[avi @ 0x559fb596f8c0] Could not find codec parameters for stream 1 (Video: none (JUNK / 0x4B4E554A), none, 11025x22050): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, avi, from 'test.avi':
  Duration: 00:00:10.50, start: 0.000000, bitrate: 28129 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
    Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc
Stream mapping:
  Stream #0:1 -> #0:0 (? (?) -> png (native))
Decoder (codec none) not found for input stream #0:1

实际视频持续时间为 10 秒(例如,当使用 vlc 读取时,这确实是在相机陷阱上编程的视频长度。ffmpeg 表示持续时间为 10.50 秒,并表示标头解析存在问题(见上文) .

尽管看过很多 ffmpeg 'convert video to frames' 帖子,但我不知道如何排序。任何提示将不胜感激,谢谢。

标签: imagevideoffmpeg

解决方案


如果您查看错误消息,您将看到该文件有 2 个视频流。

Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), none(bt470bg/unknown/unknown), 1280x720, 20.01 fps, 20.01 tbr, 20.01 tbn, 20.01 tbc
Stream #0:1: Video: none (JUNK / 0x4B4E554A), none, 11025x22050, 11025 tbr, 11025 tbn, 11025 tbc

ffmpeg 正在尝试读取第二个:

Stream mapping:
  Stream #0:1 -> #0:0 (? (?) -> png (native))

您可以使用-map 0:0选择第一个流。


推荐阅读