From 388f1c75a876c412d98595583f5f13ce553dfc17 Mon Sep 17 00:00:00 2001 From: Mradul Dubey Date: Thu, 10 Aug 2023 18:37:19 +0530 Subject: [PATCH] write 0 sized entries in metadata track to ensure sync (#286) --- base/src/Mp4WriterSink.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/src/Mp4WriterSink.cpp b/base/src/Mp4WriterSink.cpp index 23abe46fc..5337eb12f 100644 --- a/base/src/Mp4WriterSink.cpp +++ b/base/src/Mp4WriterSink.cpp @@ -519,9 +519,11 @@ bool DetailH264::write(frame_container& frames) mp4_mux_track_add_sample(mux, videotrack, &mux_sample); - if (metatrack != -1 && mMetadataEnabled && inMp4MetaFrame.get()) + if (metatrack != -1 && mMetadataEnabled) { - if (inMp4MetaFrame->size()) + // null check must happen here to ensure 0 sized entries in mp4 metadata track's stsz table + // this will ensure equal entries in metadata and video tracks + if (inMp4MetaFrame.get() && inMp4MetaFrame->size()) { mux_sample.buffer = static_cast(inMp4MetaFrame->data()); mux_sample.len = inMp4MetaFrame->size();