PyAV
PyAV copied to clipboard
added coded_picture_number property to VideoFrame
Added information about picture number in bitstream order. Some times frames can be in broken order, for example 1, 2, 3...12, 14, 13, 15, 16.... And coded_picture_number
possible way to detect it.
Thanks for this.
Looking at the FFmpeg code though, I can't find where this is actually set except in h.264. Do you know how reliable this is globally?
Looking at these:
$ grep -IR --include '*.c' coded_picture_number vendor/ffmpeg-4.2
vendor/ffmpeg-4.2/libavutil/frame.c: dst->coded_picture_number = src->coded_picture_number;
vendor/ffmpeg-4.2/fftools/ffprobe.c: print_int("coded_picture_number", frame->coded_picture_number);
vendor/ffmpeg-4.2/libavcodec/ratecontrol.c: s->current_picture_ptr->f->coded_picture_number,
vendor/ffmpeg-4.2/libavcodec/mpegvideo.c: s->coded_picture_number = s1->coded_picture_number;
vendor/ffmpeg-4.2/libavcodec/mpegvideo.c: s->coded_picture_number = 0;
vendor/ffmpeg-4.2/libavcodec/mpegvideo.c: pic->f->coded_picture_number = s->coded_picture_number++;
vendor/ffmpeg-4.2/libavcodec/h264_slice.c: h->coded_picture_number = h1->coded_picture_number;
vendor/ffmpeg-4.2/libavcodec/h264_slice.c: pic->f->coded_picture_number = h->coded_picture_number++;
vendor/ffmpeg-4.2/libavcodec/snowenc.c: s->current_picture->coded_picture_number = avctx->frame_number;
vendor/ffmpeg-4.2/libavcodec/snowenc.c: s->m.current_picture.f->coded_picture_number = avctx->frame_number;
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->reordered_input_picture[0]->f->coded_picture_number =
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->coded_picture_number++;
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->reordered_input_picture[0]->f->coded_picture_number =
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->coded_picture_number++;
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->reordered_input_picture[i + 1]->f->coded_picture_number =
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: s->coded_picture_number++;
vendor/ffmpeg-4.2/libavcodec/mpegvideo_enc.c: if (!s->current_picture.f->coded_picture_number)
vendor/ffmpeg-4.2/libavcodec/mpeg12enc.c: time_code = s->current_picture_ptr->f->coded_picture_number +
vendor/ffmpeg-4.2/libavcodec/mpeg12enc.c: s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
vendor/ffmpeg-4.2/doc/examples/demuxing_decoding.c: video_frame_count++, frame->coded_picture_number);
It only looks like h.264
and mpeg
set it while decoding.
In the case with dvd (.vob)
format it also has information.
As for webm
- it always contains 0
(zeros).
Those are container formats, and it is the codec that sets that attribute. DVDs are MPEG2 IIRC, so that makes sense.
I don't have much knowledge in this domain area. If you would describe specific cases for verification, I can check, and if necessary, add tests.
@mikeboers How about those updates? Is there a chance for this PR?
This needs unit tests.
This PR is so basic, and nothing has happened for so long. I don't think it's worth keeping it open anymore.
@WyattBlue please note that code is wrong anyway as the underlying stuff got deprecated. https://github.com/FFmpeg/FFmpeg/commit/22960783978d9e0b6d4a4ed21f503bd24662aa7e