Opened 7 years ago

Closed 7 years ago

#6695 closed defect (invalid)

avformat_new_stream() and cur_dts

Reported by: Jon Smirl Owned by:
Priority: important Component: avformat
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

avformat_new_stream() is not initializing AVStream->cur_dts. This causes problems down in av_interleaved_write_frame(), compute_muxer_pkt_fields() on this test since cur_dts is randomly set.

    if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
        ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
          st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE &&
          st->codecpar->codec_type != AVMEDIA_TYPE_DATA &&
          st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
        av_log(s, AV_LOG_ERROR,
               "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
               st->index, av_ts2str(st->cur_dts), av_ts2str(pkt->dts));
        return AVERROR(EINVAL);
    }

Changing my code like this makes it work as expected.

        out_stream = avformat_new_stream(ofmt_ctx, NULL);
        out_stream->cur_dts = AV_NOPTS_VALUE;

I'm using git head from 9/24. This is a recent change since my code worked on older versions of ffmpeg.

Change History (2)

comment:1 by Carl Eugen Hoyos, 7 years ago

Component: undeterminedavformat
Description: modified (diff)
Keywords: regression added
Priority: normalimportant

Please send your patch - made with git format-patch - to the development mailing list.

comment:2 by Jon Smirl, 7 years ago

Resolution: invalid
Status: newclosed

When I was making a patch for this I noticed what changed in ffmpeg. That led me to look at our code. Our code was mis-using the iformat field to pass a 'this' pointer to the file/open close callbacks since there wasn't any other way to pass the pointer. Apparently we can't mis-use that field anymore.

We were trying to avoid writing a full custom IO implementation since all we needed was to track the file opens. I guess we have to figure out how to write the full custom IO code now.

Note: See TracTickets for help on using tickets.