使用ffmpeg提取特定帧的列表 [英] Extract list of specific frames using ffmpeg

查看:592
本文介绍了使用ffmpeg提取特定帧的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在视频上使用ffmpeg提取特定帧的列表,并以其帧号表示.因此,可以说我只想从"test_video.mp4"中提取一帧,确切地说是帧号150.我可以使用以下命令

I'm trying to use ffmpeg on a video to extract a list of specific frames, denoted by their frame numbers. So lets say I want to extract just one frame from 'test_video.mp4', frame number 150 to be exact. I can use the following command

ffmpeg -i test_video.mp4 -vf "select=gte(n\, 150)" -vframes 1 ~/test_image.jpg

但是,如果我想精确显示帧列表,例如[100, 110, 127, 270, 300],该怎么办?我一直在浏览此页面( https://ffmpeg.org/ffmpeg-filters.html #select_002c-aselect ),可以看到有一些方法可以根据帧数,时间戳等的奇偶校验提取多个帧,但是我找不到执行所需操作的语法.

But what if I want to exact a list of frames, such as [100, 110, 127, 270, 300]? I have been looking at this page (https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect) and can see that there are ways to extract multiple frames based on parity of frame number, timestamps, etc, but I can't find the syntax for doing what I need to do.

理想情况下,我会根据命名约定out_image%03d.jpg提取给定帧的列表,其中%03d被给定帧号代替,尽管时间戳也可以工作.

Ideally I would extract the list of given frames under the naming convention out_image%03d.jpg where the %03d is replaced by the given frame number, although a timestamp would also work.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

使用

ffmpeg -i in.mp4 -vf select='eq(n\,100)+eq(n\,184)+eq(n\,213)' -vsync 0 frames%d.jpg

FFmpeg主要是定时视频(即具有诸如帧速率或采样速率之类的循环速率)的媒体的处理器.它假定输出的速率应与源的速率相同.如果提供的框架不足,则除非被告知不重复,否则它将重复.添加-vsync 0,在这种情况下,它告诉它禁止重复.

FFmpeg is primarily a processor of timed video i.e. media with a cycle rate such as framerate or sample rate. It assumes that the output should be at the same rate as the source. If inadequate frames are supplied, it duplicates unless told not to. -vsync 0 is added which, in this case, tells it to suppress duplication.

这篇关于使用ffmpeg提取特定帧的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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