On Wed, Dec 10, 2008 at 11:36 AM, Smart, Gary <[EMAIL PROTECTED]> wrote:
> Thank you very much - that speeds things up enormously!
>
> It would seem, though, that for some formats (e.g. on my m2v files) this
> field is not populated?  If you happen to know... is this a result of me
> badly converting mp4 to iframe only m2v using ffmpeg OR does m2v not
> have this information?
>
Please don't top post.

That said, some formats don't give this information in the header and
so FFMPEG doesn't know  it when it reads the heade,r and FFMPEG
doesn't walk through the file to count the frames for you.

That said, you can guesstimate the number of video frames yourself
without actually decoding the frames by reading in each packet and
checking some standard fields on the AVCodecContext structure.

The pseudo code is:
- open file
- get stream info to find out which streams are audio, video, etc.
- open the codecs (don't worry; you won't actually decode).
- Read each packet in, and in the AVPacket check the stream index to
see if it's video or audio.
  - For video, assume 1 packet == 1 frame
  - For audio, assume 1 packet == (packet size /
(AVCodecContext->frame_size * AVCodecContext->channels*2))
- close file

Of course, this won't work for a streamed file or a protocol where you
can't read to the end, but hopefully it'll get you some of the way
there.

Hope that helps.

- Art
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to