Linux ffmpeg 将 avi 拆分为具有已知帧速率的帧
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3917601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ffmpeg split avi into frames with known frame rate
提问by Myx
I posted this as comments under this related thread. However, they seem to have gone unnoticed =(
我将此作为评论发布在此相关主题下。然而,他们似乎没有注意到=(
I've used
我用过
ffmpeg -i myfile.avi -f image2 image-%05d.bmp
to split myfile.avi
into frames stored as .bmp
files. It seemed to work except not quite. When recording my video, I recorded at a rate of 1000fps
and the video turned out to be 2min29sec
long. If my math is correct, that should amount to a total of 149,000 framesfor the entire video. However, when I ran
拆分myfile.avi
为存储为.bmp
文件的帧。它似乎工作,但不完全。录制视频时,我以 的速度录制,结果1000fps
视频很2min29sec
长。如果我的数学是正确的,那么整个视频的总帧数应该为149,000 帧。然而,当我跑
ffmpeg -i myfile.avi -f image2 image-%05d.bmp
I only obtained 4472 files. How can I get the original 149k frames?
我只获得了 4472 个文件。如何获得原始的 149k 帧?
I also tried to convert the frame rate of my original AVI to 1000fps by doing
我还尝试通过执行将原始 AVI 的帧速率转换为 1000fps
ffmpeg -i myfile.avi -r 1000 otherfile.avi
but this didn't seem to fix my concern.
但这似乎并没有解决我的担忧。
采纳答案by Dat Chu
ffmpeg -i myfile.avi -r 1000 -f image2 image-%07d.png
I am not sure outputting 150k bmp files will be a good idea. Perhaps png is good enough?
我不确定输出 150k bmp 文件是否是个好主意。也许png足够好?
回答by CBee
Part one of your math is good, the 2 minutes and 29 seconds is about 149 seconds. With 1000 fps that makes 149000 frames. However your output filename only has 5 positions for the number where 149000 has 6 positions, so try "image-%06d.bmp".
你的数学第一部分很好,2 分 29 秒大约是 149 秒。以 1000 fps 制作 149000 帧。但是,您的输出文件名只有 5 个位置,其中 149000 有 6 个位置,因此请尝试“image-%06d.bmp”。
Then there is the disk size: Do your images fit on the disk? With bmp every image uses its own size. You might try to use jpeg pictures, they compress about 10 times better.
然后是磁盘大小:您的图像是否适合磁盘?使用 bmp,每个图像都使用自己的大小。您可能会尝试使用 jpeg 图片,它们的压缩效果要好 10 倍左右。
Another idea: If ffmpeg does not find a (reasonable) frame rate, it drops to 25 or 30 frames per second. You might need to specify it. Do so for both source and target, see the man page (man ffmpeg
on unix):
另一个想法:如果 ffmpeg 没有找到(合理的)帧速率,它会下降到每秒 25 或 30 帧。您可能需要指定它。对源和目标都这样做,请参阅手册页(man ffmpeg
在 unix 上):
To force the frame rate of the input file (valid for raw formats
only) to 1 fps and the frame rate of the output file to 24 fps:
ffmpeg -r 1 -i input.m2v -r 24 output.avi
For what it's worth: I use ffmpeg -y -i "video.mpg" -sameq "video.%04d.jpg"
to split my video to pictures. The -sameq is to force the jpeg in a reasonable quality, the -y is to avoid allow overwrite questions. For you:
值得一提的是:我ffmpeg -y -i "video.mpg" -sameq "video.%04d.jpg"
习惯将视频拆分为图片。-sameq 是强制 jpeg 具有合理的质量,-y 是为了避免允许覆盖问题。为你:
ffmpeg -y -r 1000 -i "myfile.avi" -sameq "image.%06d.jpg"
ffmpeg -y -r 1000 -i "myfile.avi" -sameq "image.%06d.jpg"
回答by Kalliope
I think, there is a misconception here: the output of a HS video system is unlikely to have an output frame rate of 1000 fps but something rather normal as 30 (or 50/60) fps. Apart from overloading most video players with this kind of speed it would be counterproductive to show the sequence in the same speed as it was recorded. Basically: 1 sec @ 1000 fps input is something like 33 sec @ 30 fps output.
我认为,这里有一个误解:HS 视频系统的输出不太可能具有 1000 fps 的输出帧速率,但 30(或 50/60)fps 的输出帧速率相当正常。除了以这种速度使大多数视频播放器过载之外,以与录制的速度相同的速度显示序列会适得其反。基本上:1 秒 @ 1000 fps 输入类似于 33 秒 @ 30 fps 输出。
Was the duration of the scene recorded really 2:29 min (resulting in a video ~82 min at normal rate) or took it about 4.5 sec (4472 frames) which is 2:29 min in normal playback?
场景的持续时间是否真的记录了 2:29 分钟(导致视频在正常速率下约为 82 分钟),还是录制了大约 4.5 秒(4472 帧),即正常播放时的 2:29 分钟?