How do I extract a screenshot from a video in the

2019-04-15 03:19发布

问题:

I'd like to be able to take a screenshot of an MPEG recorded using the iPhone camera at set intervals.

I've seen a few ways to do this; namely compiling and using FFmpeg (Using FFMPEG library with iPhone SDK for video encoding), however it seems it's quite difficult to comply with the LGPL (http://ffmpeg.org/legal.html) for commercial use.

This term of the contract pretty much makes it useless to us:

Q: Is it perfectly alright to incorporate the whole FFmpeg core into my own commercial product?

A: You might have a problem here. There have been cases where companies have used FFmpeg in their products. These companies found out that once you start trying to make money from patented technologies, the owners of the patents will come after their licensing fees. Notably, MPEG LA is vigilant and diligent about collecting for MPEG-related technologies.

Is there any other way? - or simply by accessing the rendering layer of an MPEG am I going to be "making money from patented technologies"?

As usual - any help on this would be greatly appreciated.

Cheers!

回答1:

Yes, you can do it - if I am not wrong, since iOS 3.2... at least for the videos you have on your library. After loading the movie on your MPMoviePlayerController object, do this

UIImage *aThumbnail = [player thumbnailImageAtTime:timeCode timeOption:MPMovieTimeOptionExact];

//timeCode is a time within de video length, for example: 3.12 seconds.
//player is the MPMoviePlayerController object.


回答2:

Unfortunately there is no official way to grab image frames from the camera in realtime.

I encourage you to file a bug report / feature request with Apple. Many people want this. If many people request a specific feature then they might consider to actually put this in.