metadata: get embedded cover art from video files using libavformat
Newer version of libavformat can grab cover art, so we'll go ahead and use it. We also need to make sure we don't confuse cover art with a normal video stream.
This commit is contained in:
17
libav.h
17
libav.h
@@ -163,3 +163,20 @@ lav_get_interlaced(AVCodecContext *vc, AVStream *s)
|
|||||||
return (vc->time_base.den ? (s->avg_frame_rate.num / vc->time_base.den) : 0);
|
return (vc->time_base.den ? (s->avg_frame_rate.num / vc->time_base.den) : 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
lav_is_thumbnail_stream(AVStream *s, uint8_t **data, int *size)
|
||||||
|
{
|
||||||
|
#if LIBAVFORMAT_VERSION_INT >= ((54<<16)+(6<<8))
|
||||||
|
if (s->disposition & AV_DISPOSITION_ATTACHED_PIC &&
|
||||||
|
s->codec->codec_id == AV_CODEC_ID_MJPEG)
|
||||||
|
{
|
||||||
|
if (data)
|
||||||
|
*data = s->attached_pic.data;
|
||||||
|
if (size)
|
||||||
|
*size = s->attached_pic.size;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -712,6 +712,7 @@ GetVideoMetadata(const char *path, char *name)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if( video_stream == -1 &&
|
else if( video_stream == -1 &&
|
||||||
|
!lav_is_thumbnail_stream(ctx->streams[i], &video.image, &video.image_size) &&
|
||||||
ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
|
ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
|
||||||
{
|
{
|
||||||
video_stream = i;
|
video_stream = i;
|
||||||
@@ -1530,7 +1531,6 @@ video_no_dlna:
|
|||||||
else
|
else
|
||||||
DPRINTF(E_WARN, L_METADATA, "%s: Unhandled format: %s\n", path, ctx->iformat->name);
|
DPRINTF(E_WARN, L_METADATA, "%s: Unhandled format: %s\n", path, ctx->iformat->name);
|
||||||
}
|
}
|
||||||
lav_close(ctx);
|
|
||||||
|
|
||||||
if( !m.date )
|
if( !m.date )
|
||||||
{
|
{
|
||||||
@@ -1544,6 +1544,7 @@ video_no_dlna:
|
|||||||
|
|
||||||
album_art = find_album_art(path, video.image, video.image_size);
|
album_art = find_album_art(path, video.image, video.image_size);
|
||||||
freetags(&video);
|
freetags(&video);
|
||||||
|
lav_close(ctx);
|
||||||
|
|
||||||
ret = sql_exec(db, "INSERT into DETAILS"
|
ret = sql_exec(db, "INSERT into DETAILS"
|
||||||
" (PATH, SIZE, TIMESTAMP, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION,"
|
" (PATH, SIZE, TIMESTAMP, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION,"
|
||||||
|
Reference in New Issue
Block a user