GNOME Bugzilla – Bug 652155
[ffmpegdec] generates invalid timestamps for audio streams
Last modified: 2012-04-30 21:05:50 UTC
Created attachment 189509 [details] [review] Simple patch (Note, this only concerns audio decoding) gstffmpegdec uses input buffer timestamp for output if the timestamp is valid (gst_ffmpegdec_audio_frame), but that's not always correct because AVCodecParser has internal buffer, so the actual data on the output might be coming from buffer that has been read in previous iterations. Simple patch attached.
Actually, the patch doesn't fix the problem. The input buffer TS and duration do not map well to output TS and duration for audio streams. After decoding the output buffer can have different size than the input buffer. It looks like perhaps the solution is only to use the input TS the beginning (and discontinuity) and just keep computing output timestamps.
Created attachment 189523 [details] [review] Patch to use input timestamps only at the beginning The patch will use computed timestamps during the stream and use the timestamps from input only at the beginning or discontinuity. If the input buffer duration is different than the output buffer duration (seems to happen with all decoders I've tested) I don't see point of trying to pass the input timestamp to output as it won't really be valid.
This is not how timestamps are supposed to work. Timestamps can "wander around" what you might expect given the number of samples, without having discont flags set on buffers. The audio sink will fix it up, more or less successfully. So, the second patch is incorrect. Bug report sounds valid, however.
Well, thanks for the explanation but I'm still not sure how the timestamps are supposed to work in gstreamer then, because even if as you say the sink can currently fix them, some muxers that I've tried can't. Could you maybe explain the "wandering around" part some more? I know this can be fixed by a simple filter in the pipeline after the FFMpeg decoder and I plan to do that given that my patch got rejected, but before I do that I'd like to know if there is something significant that I'm missing regarding audio timestamps.
Don't think this is relevant anymore.