简体   繁体   中英

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. I used ffmpeg application to extract a frame, it gives extact result what I need, but ffmpeg is a seperate application, which overloads process. 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? I dont want to use Qt phonon, because it physically opens a phonon dialog and then take a scrrenshot. I want the extracting process should happenin background.

Thanks in Advance

You have two choices : either via ffmpeg API, or via ffmpeg executable. 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. You need to construct ffmpeg command lines parameters from your own parameters; be able to capture the result (failed\\succeeded) and .

API Approach: long term, clean but require significant amount of work at beginning

  • Obtain ffmpeg dynamic librairies (avcodec, etc..)
  • Follow a tutorial on how ffmpeg API is used. Dranger is the most well known, and there is an updated version . Careful, learning curve ahead
  • incorporate that in your Qt App (pro config, wrapper around your ffmpeg functionality, etc..)
  • Build the static library version. I leave it last because I can be annoying, especially if you are on windows (hope you are not)

Personally I will recommend to stick with the executable approach unless you don't mind taking a week to learn 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.

EDIT: Data conversion .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM