[FFmpeg-devel] Removing limit on frame extraction

Opaskar, Mark US SSA mark.opaskar
Fri Apr 9 20:14:37 CEST 2010


I need help transforming a hack into a safe piece of code that I can submit as a change.

My problem: I'm extracting I-frames from an MPEG using the command line interface with a line like this:

ffmpeg -i <infile> -intra -r 14/<duration> -f image2 <outfile>_%03d.jpg

If the video from which I'm extracting the frames runs over 280 seconds, I'm stopped by a 0.05 Hz minimum on the frame rate. (You can test this with shorter videos using "-r 1/21".)

My solution/hack: I removed lines 359-362 from libavcodec/mpegvideo_enc.c - the limit goes away, and I can now extract frames from longer videos.

While this works for my use case, my guess is that this breaks something in video conversion. (The removed check involves video bitrate. While not important for extracting JPEGs, I'm guessing it's a big deal for video.) I'm thinking the right thing to do is add logic to ignore the check when the output format is image2, instead of removing the check altogether.

So my questions are:

(1)    Am I right?

(2)    Is libavcodec/mpegvideo_enc.c the right place to insert this alternate path?

(3)    If so, what's the most elegant way to check the format here?

(4)    If not, where should I be looking instead?

Regarding (3), I'm about to try (avctx->codec->id ==CODEC_ID_LJPEG || avctx->codec->id == CODEC_ID_MJPEG), but I'm not sure that'll work. Even if it does, I would still like answers to the other questions, just to make sure I'm doing this right.

(Apologies if I've missed something in the developer rules for how to present this. I'm sure I have, given that this is the first time I've needed to.)

(Also - up until now, I've been hacking up a 0.5.0.X version. I'm currently working on compiling 0.5.1 to get caught up, but I haven't seen anything in the code to make me think my problem has gone away between releases. If it has, let me know, and I'll dutifully slink off ...)


Mark Opaskar
BAE Systems EI&S - C3I Systems
(858) 592-1723 (Desk)
mark.opaskar at baesystems.com<mailto:mark.opaskar at baesystems.com>

More information about the ffmpeg-devel mailing list