[英]How to extract an Image from a video file in qt?
I want to extract an image (First frame) form a video file in qt. 我想从qt的视频文件中提取图像(第一帧)。 I used ffmpeg application to extract a frame, it gives extact result what I need, but ffmpeg is a seperate application, which overloads process. 我使用ffmpeg应用程序提取了一个框架,它给出了我需要的确切结果,但是ffmpeg是一个单独的应用程序,使过程超载。 So I want to make it as static linking. 所以我想使其成为静态链接。 Is it possible make static link to ffmpeg , is there is any statick library available for extracting frame from video or are there any other ways to extract frame from video? 是否可以建立到ffmpeg的静态链接,是否有任何statick库可用于从视频中提取帧,或者是否有其他方法可从视频中提取帧? I dont want to use Qt phonon, because it physically opens a phonon dialog and then take a scrrenshot. 我不想使用Qt声子,因为它实际上会打开一个声子对话框,然后进行scrrenshot。 I want the extracting process should happenin background. 我希望提取过程应在后台进行。
Thanks in Advance 提前致谢
You have two choices : either via ffmpeg
API, or via ffmpeg
executable. 您有两种选择:通过ffmpeg
API或通过ffmpeg
可执行文件。 Basically 基本上
Executable Approach: quick and dirty, not that bad if done correctly, but not very flexible 可执行方法:快速又肮脏,如果正确完成,还算不错,但不是很灵活
Call ffmpeg executable via QProcess and then read the processed data from disk. 通过QProcess调用ffmpeg可执行文件,然后从磁盘读取已处理的数据。 You need to construct ffmpeg command lines parameters from your own parameters; 您需要根据自己的参数构造ffmpeg命令行参数。 be able to capture the result (failed\\succeeded) and . 能够捕获结果(失败\\成功)和。
API Approach: long term, clean but require significant amount of work at beginning API方法:长期,清洁,但在开始时需要大量工作
Personally I will recommend to stick with the executable approach unless you don't mind taking a week to learn ffmpeg API
. 我个人建议不要使用可执行方法,除非您不介意花一个星期来学习ffmpeg API
。
OpenCV has a built-in videocapture API , which actually wraps avcodec, easier to work with -in case you dont want to mess with avcodec. OpenCV具有内置的视频捕获API ,该API实际上可以包装avcodec,使用起来更容易-如果您不想弄乱avcodec。
EDIT: Data conversion . 编辑: 数据转换 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.