On 10/15/2012 03:55 PM, Anton Khirnov wrote: > > On Mon, 8 Oct 2012 13:38:59 -0400, Justin Ruggles <justin.rugg...@gmail.com> > wrote: >> Also, only use parser duration if it is greater than zero. >> --- >> libavformat/utils.c | 4 ++++ >> 1 files changed, 4 insertions(+), 0 deletions(-) >> >> diff --git a/libavformat/utils.c b/libavformat/utils.c >> index e74afb8..ff8b971 100644 >> --- a/libavformat/utils.c >> +++ b/libavformat/utils.c >> @@ -1070,6 +1070,9 @@ static int parse_packet(AVFormatContext *s, AVPacket >> *pkt, int stream_index) >> >> /* set the duration */ >> out_pkt.duration = 0; >> + if (pkt->duration > 0 && st->need_parsing == >> AVSTREAM_PARSE_HEADERS) { >> + out_pkt.duration = pkt->duration; >> + } else if (st->parser->duration > 0) { >> if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { >> if (st->codec->sample_rate > 0) { >> out_pkt.duration = av_rescale_q_rnd(st->parser->duration, >> @@ -1084,6 +1087,7 @@ static int parse_packet(AVFormatContext *s, AVPacket >> *pkt, int stream_index) >> st->time_base, >> AV_ROUND_DOWN); >> } >> + } >> >> out_pkt.stream_index = st->index; >> out_pkt.pts = st->parser->pts; >> -- >> 1.7.1 >> > > Should be ok. > > Though I have to wonder about the sanity of using parser duration for video. I > don't see how a parser can possibly know anything useful about video duration. >
None currently do. So that code doesn't really do anything for video right now. It was needed for audio, and it wasn't really any more work to also give the option to video parsers if needed. But if there is really no possiblity it will ever be needed we can just alter the documentation and remove the handling code for video in libavformat. -Justin _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel