使用 ffmpeg/mencoder/transcode 等转储视频文件的最后一帧。阿尔
我想抓取视频中的最后帧(.mpg
、.avi
等)并将其转储到图像文件中( .jpg
、.png
等等)。 Toolchain 是一个现代 Linux 命令行,例如 mencoder
、transcode
、ffmpeg
和 c。
干杯, 鲍勃.
I'd like to grab the last frame in a video (.mpg
, .avi
, whatever) and dump it into an image file (.jpg
, .png
, whatever). Toolchain is a modern Linux command-line, so things like mencoder
, transcode
, ffmpeg
&c.
Cheers,
Bob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这不是一个完整的解决方案,但它会为您指明正确的道路。
使用 ffprobe -show_streams IN.AVI 获取视频输入中的帧数。然后,
其中 LAST_FRAME_INDEX 是帧数减一(帧的索引为零),将输出最后一帧。
This isn't a complete solution, but it'll point you along the right path.
Use
ffprobe -show_streams IN.AVI
to get the number of frames in the video input. Thenwhere LAST_FRAME_INDEX is the number of frames less one (frames are zero-indexed), will output the last frame.
我有一个 mp4 / h264 matroska 输入视频文件。上述解决方案都不适合我。 (尽管我确信它们适用于其他文件格式)。
结合samrad上面的答案以及这个很好的答案并提出了这个工作代码:
I have a mp4 / h264 matroska input video file. And none of the above solutions worked for me. (Although I sure they work for other file formats).
Combining samrad's answer above and also this great answer and came up with this working code:
我没有看到提到的一件事是,如果文件包含重复内容,预期的帧计数可能会关闭。如果您计算帧的方法导致图像提取命令返回为空,则这可能是造成混乱的原因。
我开发了一个简短的脚本来解决这个问题。它发布在这里< /a>.
One thing I have not seen mentioned is that the expected frame count can be off if the file contains dupes. If your method of counting frames is causing your image extraction command to come back empty, this might be what is mucking it up.
I have developed a short script to work around this problem. It is posted here.
我无法让纳尔逊的解决方案发挥作用。这对我有用。
https://gist.github.com/samelie/32ecbdd99e07b9d8806f
编辑 (以防万一链接消失,这里是 shellscript — bobbogo):
I couldn't get Nelson's solution to work. This worked for me.
https://gist.github.com/samelie/32ecbdd99e07b9d8806f
EDIT (just in case the link disappears, here is the shellscript—bobbogo):
我发现我必须添加
-vsycn 2
才能使其可靠地工作。以下是我使用的完整命令:如果写入 NFS 文件夹,则结果将非常不一致。因此,我写入
/tmp
,然后在完成后复制该文件。如果没有完成,我会对进程 ID 执行kill -9
。I found that I had to add
-vsycn 2
to get it to work reliably. Here's the full command I use:If you write to a NFS folder then the results will be very inconsistent. So I write to
/tmp
then copy the file once done. If it is not done, I do akill -9
on the process ID.