decoder/ffmpeg: skip _scan_stream() if no audio stream was found
This commit is contained in:
parent
3fe2f7337c
commit
8c3be4a5f0
@ -473,10 +473,11 @@ static void
|
|||||||
FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream,
|
FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream,
|
||||||
const tag_handler &handler, void *handler_ctx)
|
const tag_handler &handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
|
assert(audio_stream >= 0);
|
||||||
|
|
||||||
FfmpegScanDictionary(format_context.metadata, &handler, handler_ctx);
|
FfmpegScanDictionary(format_context.metadata, &handler, handler_ctx);
|
||||||
if (audio_stream >= 0)
|
FfmpegScanMetadata(*format_context.streams[audio_stream],
|
||||||
FfmpegScanMetadata(*format_context.streams[audio_stream],
|
handler, handler_ctx);
|
||||||
handler, handler_ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0)
|
||||||
@ -691,6 +692,10 @@ FfmpegScanStream(AVFormatContext &format_context,
|
|||||||
if (find_result < 0)
|
if (find_result < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const int audio_stream = ffmpeg_find_audio_stream(format_context);
|
||||||
|
if (audio_stream < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (format_context.duration != (int64_t)AV_NOPTS_VALUE) {
|
if (format_context.duration != (int64_t)AV_NOPTS_VALUE) {
|
||||||
const auto duration =
|
const auto duration =
|
||||||
SongTime::FromScale<uint64_t>(format_context.duration,
|
SongTime::FromScale<uint64_t>(format_context.duration,
|
||||||
@ -698,8 +703,7 @@ FfmpegScanStream(AVFormatContext &format_context,
|
|||||||
tag_handler_invoke_duration(&handler, handler_ctx, duration);
|
tag_handler_invoke_duration(&handler, handler_ctx, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = ffmpeg_find_audio_stream(format_context);
|
FfmpegScanMetadata(format_context, audio_stream, handler, handler_ctx);
|
||||||
FfmpegScanMetadata(format_context, idx, handler, handler_ctx);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user