FORUMS: list search recent posts

Grabbing JPG from AVI

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Dmitry Kaflik
Grabbing JPG from AVI
on Jan 19, 2011 at 9:47:59 am

Hello,

i`m using ffmpeg to convert some frames of video file to image.
ffmpeg -y -i akisora.mp4 -an -ss 00:00:45 -r 1 -f mjpeg -vcodec mjpeg -vframes 1 "test.jpg"

The problem is that if i try to extract frame from the end of file its take a lot of time and i need to get about 100-1000 frames from video file. If i run ffmpeg 100-1000 times its every time going to parse video from the begining to reach pointed time (for example -ss 00:00:45).

So my question: is there any way to point ffmpeg to the list of frames that i need to extract, so it cat do extraction in one-pass?


Return to posts index

Michael Rampe
Re: Grabbing JPG from AVI
on Jan 19, 2011 at 9:43:10 pm

[Dmitry Kaflik] "The problem is that if i try to extract frame from the end of file its take a lot of time and i need to get about 100-1000 frames from video file. If i run ffmpeg 100-1000 times its every time going to parse video from the begining to reach pointed time (for example -ss 00:00:45)."

It is all about where you put the -ss flag.

If you put it after the input, FFmpeg reads every frame up until the one you need. (as in your example) AFAIK, this is required if the frame you want to export is not an I frame.

If you put it before the input, such as:

ffmpeg -y -ss 00:00:45 -i akisora.mp4 -an -r 1 -f mjpeg -vcodec mjpeg -vframes 1 "test.jpg"

FFmpeg will only read the frame you specified and thus do the output almost instantly. Unfortunately, you will lose accuracy with this method because for me it only exports the closest I frame. (I have also read reports that for some other users, this method will produce a grey output frame if it is on a P or a B frame.)

[Dmitry Kaflik] "So my question: is there any way to point ffmpeg to the list of frames that i need to extract, so it cat do extraction in one-pass?"

One way which would be fast and accurate, if you are exporting 1000 stills, is simply export the whole movie to stills and keep the ones you need. A simple shell script should be able to achieve this. This way, FFmpeg will only read through the file once and you can delete the unnecessary ones.

Michael


Return to posts index

michael greene
Re: Grabbing JPG from AVI
on May 16, 2011 at 8:07:20 pm

Michael-
I'm looking to grab individual frames coming off a webcam that's streaming mjpeg and inspect the images with my own software. The idea is to grab a frame, do some processing, loop back and grab another frame, do some more processing.

I don't care what happens to the frames that come along while I'm processing. I just want the latest complete, decoded image coming off the webcam. By "de-coded image" I mean a bitmap format like Windows' BMP format that allocates 3 bytes per color pixel or 1 byte per bw pixel.

Is there a way to configure ffmpeg to do that?

Thanks.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]