[Libav-user] Reading exif data from jpeg programmatically
battistel at gmail.com
Wed Oct 22 18:52:51 CEST 2014
> Last I checked which was quite awhile ago, the EXIF was only available in
> a successfully decoded frame and the frames metadata.
> I mentioned this also long ago and while it does possibly make sense for
> multi-frame files, it does not make much sense for a single frame jpeg file.
> I don't know if this is still the case because I don't use ffmpeg for
> single frame jpegs still. It may have improved but don't know.
I tried with your advice, but no success. frame->metadata is null
This is the code I used for the test (there is no error checking for
int ret = 0;
AVFormatContext *fmt_ctx = NULL;
ret = avformat_open_input(&fmt_ctx, "C:\\tmp\\still\\p.jpg", NULL, NULL);
ret = avformat_find_stream_info(fmt_ctx, NULL);
AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams->codec->codec_id);
ret = avcodec_open2(fmt_ctx->streams->codec, codec, NULL);
pkt.data = NULL;
pkt.size = 0;
ret = av_read_frame(fmt_ctx, &pkt);
AVFrame* frame = avcodec_alloc_frame();
int got_pict = 0;
ret = avcodec_decode_video2(fmt_ctx->streams->codec, frame,
pkt.data = NULL; // request flush
pkt.size = 0;
while (!got_pict && ret >= 0);
// TAGS reading
AVDictionaryEntry *tag = NULL;
while (tag = av_dict_get(frame->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))
printf("%s=%s\n", tag->key, tag->value);
Could someone please help me finding what's wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user