如何使用ffmpeg提取视频中第一秒的第一帧? [英] How to extract the very first frame of a second in a video using ffmpeg?
问题描述
我正在尝试从视频中提取一秒钟的第一帧.我尝试了多种方法来实现这一目标,但失败了.这是我尝试的命令.
I am trying to extract the first frame of a second from a video. I have tried different ways to achieve this, but I failed. Here the commands I tried.
ffmpeg -i input.ts -s 400x222 -q:v 3 -start_number 0 -vf fps=1 %d.jpg
稍后,我正在尝试使用特定秒的以下命令再次提取帧.在这里,我提取第210秒的帧.
Later, I am trying to extract the frames again using the below command of that particular second. Here I'm extracting the frames of 210th second.
ffmpeg -ss 210 -i input.ts -s 300x250 -t 1 -start_number 0 images.%d.jpg
我只想提取第二个的开始帧.假设从该特定秒的0.001开始.
I want to extract only the starting frame of the second. Let's say from 0.001 of that particular second.
当我比较第一条命令提取的210秒帧与第二条命令提取的第一帧时完全不同.
When I compare the frame of 210 second extracted by my first command with the first frame extracted by second command are completely different.
为了以后使用,为了避免冲突,我只想提取原始输入视频的第一帧.我尝试使用过去此处中stackoverflow专家告诉过的命令.但是当我运行它时.它仅提取起始帧(仅1帧).
For the later use, to prevent the conflicts I want to extract only the very first frame of the original input video. I tried using the command which was told by stackoverflow experts in the past here. But when I run it. It is only extracting the starting frame(only 1 frame).
如何每秒提取视频的最开始的帧?
How can I extract the very starting frame of the video per every second?
推荐答案
尝试以下命令:
ffmpeg -i input.mp4 -vf "select=between(mod(n\, 25)\, 0\, 0), setpts=N/24/TB" output-%04d.png
您必须在between(mod(n\, 25)\, 0\, 0)
中通过视频帧速率或fps
,我的视频fps是25
,所以我通过25
you have to pass your video framerate or fps
in between(mod(n\, 25)\, 0\, 0)
my video fps is 25
so i pass 25
如果您的fps为60,则必须在between(mod(n\, 60)\, 0\, 0)
if your fps 60 then you have to pass 60 in between(mod(n\, 60)\, 0\, 0)
如果您想每秒1帧5帧,请使用between(mod(n\, 25)\, 0\, 4)
每秒1帧5帧.
also if you want 1st 5 frames of every second then use between(mod(n\, 25)\, 0\, 4)
it will give your 1st 5 frames of every second.
这篇关于如何使用ffmpeg提取视频中第一秒的第一帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!