[Libav-user] How can we extract frames from a video stream in MPEG-4 AVC format

Amir Rouhi-Rmit amir.rouhi at rmit.edu.au
Fri Apr 8 03:06:29 CEST 2011


Hi Carson

My goal is extracting  Frames from MPEG-4 AVC video in form of I-Frames.

To achieving my goal, I currently uses JM software ( Opensource MPEG-4 AVC
software from ITU-T). This software input is raw video format in YUV or RGB.
That’s why I need this type of video.

When I input a raw video to software, I will be enable to ask the software
to retrieve any video started from frame-x to frame-y. So I just select one
frame and the output would be just a video containing one i-frame.

But I am looking for another tools (I hope FFMPEG or X.264) that enable me
directly extract the framed in form of videos in 1 frame length, from the
main video. The source and the output videos should be in MPEG-4 AVC format.

Regarding extracting pictures from videos, I should say it is not in my
interest. The below command cand do it for you by FFMPEG:

ffmpeg -i src.avi -r 1 -s WxH -f image2 dst-%03d.jpeg

The above command extract one video frame per second (-r 1, if –r 0.1 then
one image every 10 sec if video) from source video and will output them in
files named `dst-001.jpeg', `dst-002.jpeg', etc. Images can be rescaled to
fit the new WxH .

Regards

Amir


On Thu, Apr 7, 2011 at 3:26 PM, Carson Harper <carsonharper at gmail.com>wrote:

> Hey Amir,
>
> Could you tell us a little bit more about what you want to do with the
> "raw" YUV or RGB data? For instance, do you want to save those individual
> frames as still images (BMP, PNG...) or are you wanting to transcode them
> for use in another video stream?
>
> If you want to just save to disk try-
>
> ffmpeg -f image2 </path/to/your/video.mp4> frame_%06d.png
>
> See here<http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs> for
> some other useful CLI stuff.
>
> I recently went through the tutorials listed above and came up with a C++
> routine that convert's the first video stream from an input file to a vector
> of ImageMagick objects, but it would be trivial to adapt it to something
> else.
>
> You mentioned having random access to frames by selecting frame number,
> which is something I'll need to write eventually anyways, but this may work
> for you as a lazy solution. I mostly deal with small/short video clips which
> is why I can get aways with loading the whole video into memory.
>
> I tried to tweak a few things to make it easier to understand, but you
> will definitely still need to change things to get it to work for you.
> Obviously, I'm throwing my own custom exceptions etc... You could return an
> array of (int8_t *) if you don't want to use the ImageMagick stuff, and then
> just play with the raw data from there.
>
> Hope this helps,
>
> CH
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>


-- 
Amir H. Rouhi
PhD Student/ CSIT RMIT University
Room: 14-09-04
rouhi_amirhossein at student.rmit.edu.au
amir.rouhi at rmit.edu.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110408/b7d278fb/attachment.html>


More information about the Libav-user mailing list