Even if FF_MOV_FLAG_FRAG_EVERY_FRAME is set, don't flush if no frame available.
This fixes an issue that we overwrite the track duration, causing it to be out-of-sync with the last written packet in previous fragment. Signed-off-by: Hu Weiwen <seh...@mail.scut.edu.cn> --- Hi Martin, I can confirm your patch "movenc: Don't try to fix the fragment end duration if none will be written"[1] does fix my issue reported in [2]. But I think my current patch would be a better fix. It is more self-explanatory, and more consistent in the case of FF_MOV_FLAG_FRAG_KEYFRAME. Also, I think my original patch [2] still has its value. "frag_start" seems to be redundant, and it is only updated relative to its previous value. This is bad because any potential error updating it will have infinite impact on future packets. [1]: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210805123421.10527-1-mar...@martin.st/ [2]: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210718102232.1382376-1-seh...@mail.scut.edu.cn/ libavformat/movenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 57062f45c57..72fe8df12c2 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5929,7 +5929,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt) (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME && par->codec_type == AVMEDIA_TYPE_VIDEO && trk->entry && pkt->flags & AV_PKT_FLAG_KEY) || - (mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME)) { + (mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME && trk->entry)) { if (frag_duration >= mov->min_fragment_duration) { // Set the duration of this track to line up with the next // sample in this track. This avoids relying on AVPacket -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".