commit 34c61ad383eeb4cf1f90f8928cc3c8fd59b84081 parent 2f95b077fa65305312d3b05373d434e151874a64 Author: Alexander Kojevnikov <alexander@kojevnikov.com> Date: Wed, 7 Sep 2011 21:29:03 +0800 Fix duration for certain video files Diffstat:
M | src/spek-audio.c | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/spek-audio.c b/src/spek-audio.c @@ -83,7 +83,14 @@ SpekAudioContext * spek_audio_open (const gchar *file_name) { cx->bits_per_sample = cx->codec_context->bits_per_coded_sample; } cx->channels = cx->codec_context->channels; - cx->duration = cx->stream->duration * av_q2d (cx->stream->time_base); + if (cx->stream->duration != AV_NOPTS_VALUE) { + cx->duration = cx->stream->duration * av_q2d (cx->stream->time_base); + } else if (cx->format_context->duration != AV_NOPTS_VALUE) { + cx->duration = cx->format_context->duration / (double) AV_TIME_BASE; + } else { + cx->error = _("Unknown duration"); + return cx; + } if (cx->channels <= 0) { cx->error = _("No audio channels"); return cx;