On date Sunday 2011-10-23 22:16:02 +0200, Thomas Kühnel encoded: > Updated.
> From a4c08b589b9ae51c79e63a875ec9d316d86627bf Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Thomas=20K=C3=BChnel?= <[email protected]> > Date: Fri, 23 Sep 2011 22:51:42 +0200 > Subject: [PATCH 3/3] avprobe: Print frame-based metadata > > --- > avprobe.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- > doc/avprobe.texi | 7 +++++++ Also check this: http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/129683 In this patch I was trying to show audio data information (like in the original sourceforge/ffprobe), but it was not working fine (I needed to find a clean way to free references to the corresponding AVFrames, and it was leaking IIRC). I suppose a simpler approach may consist into simply forgetting about audio, avoid all the buffer management crazyness and only show video frames, the long term clean&sweet approach will consist into putting audio data in AVFrame and unify audio/video API (and possibly even subtitiles, in a far distant bright future). > 2 files changed, 51 insertions(+), 3 deletions(-) > > diff --git a/avprobe.c b/avprobe.c > index 99ec1aa..0991f8b 100644 > --- a/avprobe.c > +++ b/avprobe.c > @@ -35,6 +35,7 @@ const int program_birth_year = 2007; > static int do_show_format = 0; > static int do_show_packets = 0; > static int do_show_streams = 0; > +static int do_show_frames = 0; > > static int show_value_unit = 0; > static int use_value_prefix = 0; > @@ -150,14 +151,51 @@ static void show_packet(AVFormatContext *fmt_ctx, > AVPacket *pkt) > printf("[/PACKET]\n"); > } > > +static int show_frame(AVFormatContext *fmt_ctx, AVPacket *pkt) > +{ > + AVFrame picture; > + int got_picture = 0; Nit: s/picture/frame/ for consistency > + char val_str[128]; > + AVDictionaryEntry *tag = NULL; > + AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec; > + > + if (dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || > + avcodec_decode_video2(dec_ctx, &picture, &got_picture, pkt) <= 0 || > + !got_picture) > + return got_picture; > + > + printf("[FRAME]\n"); > + printf("key_frame=%d\n", picture.key_frame); > + printf("pts=%s\n", ts_value_string (val_str, sizeof(val_str), > picture.pts)); there's more tasty meat you can show here (check again my original patch) > + > + while ((tag = av_dict_get(picture.metadata, "", tag, > AV_DICT_IGNORE_SUFFIX))) > + printf("TAG:%s=%s\n", tag->key, tag->value); > + printf("[/FRAME]\n"); > + > + return got_picture; > +} > + > static void show_packets(AVFormatContext *fmt_ctx) > { > AVPacket pkt; > + int i; > > av_init_packet(&pkt); > > - while (!av_read_frame(fmt_ctx, &pkt)) > - show_packet(fmt_ctx, &pkt); > + while (!av_read_frame(fmt_ctx, &pkt)) { > + if (do_show_packets) > + show_packet(fmt_ctx, &pkt); > + if (do_show_frames) > + show_frame(fmt_ctx, &pkt); > + av_destruct_packet(&pkt); > + } > + av_init_packet(&pkt); > + pkt.data = NULL; > + pkt.size = 0; > + for (i = 0; i < fmt_ctx->nb_streams; i++) { > + pkt.stream_index = i; > + while (show_frame(fmt_ctx, &pkt)); > + } This is not entirely obvious, add a notice telling that this is required for flushing frames cached in the decoder. [...] _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
