[英]How to extract certain frames from a .yuv video file and create a new video using FFmpeg, OpenCV and python?
I have a.yuv video file and a list containing some frame numbers.我有一个 .yuv 视频文件和一个包含一些帧号的列表。 I need to make a new video with the frame numbers in the list and another video with the frame numbers that are not on the list.
我需要用列表中的帧号制作一个新视频,并用不在列表中的帧号制作另一个视频。 How can I do this using FFmpeg and subprocess module in python?
如何使用 FFmpeg 和 python 中的子进程模块来执行此操作? I'm also using OpenCV in the program.
我也在程序中使用 OpenCV。 I need the new videos in both.yuv and.avi formats.
我需要 .yuv 和 .avi 格式的新视频。
Something like this:像这样的东西:
Open the YUV file in `rb` mode.
Open `inlist.yuv` and `notinlist.yuv` in `wb` mode.
Zero frame counter
Repeat until no more data in input file
Read `framesize` bytes
if framenumber in list:
write to "inlist.yuv"
else:
write to "notinlist.yuv"
Increment frame counter
Close files
As Rotem suggests, use ffmpeg
to convert your 2 output files to AVI at the end.正如 Rotem 建议的那样,最后使用
ffmpeg
将您的 2 个 output 文件转换为 AVI。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.