Hello!
I am trying to write correct metadata for fragmented mp4 files. We are using the cmafmux
and taking inspiration from the HLS live example in gst-plugin-rs
repo.
I get the duration / end_time of a fragment by going:
// Calculate the end time at this point. The duration of the segment header is set
// to the whole duration of this segment.
let end_time = start_time + first.duration().ok_or(gst::FlowError::Eos)?;
tracing::info!("segment header duration: {}", first.duration().unwrap());
Just as I see in the HLS live example. The start time / end times I get in this way line up. With that I mean that the end time I calculate for a fragment matches the start time I get for the next item. All peachy.
But when I compare the duration I get with what gst-discover-1.0
or ffprobe
gives me it does not match.
Example:
I have generated the item item-00000000
, the print above gives:
segment header duration: 0:00:05.943495333
I create self contained files by concatenating the header with the fragment.
The tool gst-disoverer-1.0
gives:
$ gst-discoverer-1.0 test_create_items_fmp4/self-contained.0
Properties:
Duration: 0:00:06.002000000
Seekable: yes
Live: no
container #0: Quicktime
video #1: H.264 (Constrained Baseline Profile)
Stream ID: f2cd67b38fa926e925ee0999d7183ec9e733e6462b227301919c369fcd67e282/001
Width: 320
Height: 180
Depth: 24
Frame rate: 30/1
Pixel aspect ratio: 1/1
Interlaced: false
Bitrate: 0
Max bitrate: 0
And ffprobe
:
$ ffprobe -hide_banner test_create_items_fmp4/self-contained.0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_create_items_fmp4/self-contained.0':
Metadata:
major_brand : cmf2
minor_version : 0
compatible_brands: iso6cmfccfsd
creation_time : 2023-12-04T06:21:04.000000Z
Duration: 00:00:06.00, start: 0.082333, bitrate: 1379 kb/s
Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 320x180, 1373 kb/s, SAR 1:1 DAR 16:9, 30.29 fps, 30 tbr, 3k tbn (default)
Metadata:
creation_time : 2023-12-04T06:21:04.000000Z
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Using the pbutils
API calls does not match either. Am I doing some kind of thinko? Or is this expected in some way?
I construct the cmafmux
like:
let cmafmux = gst::ElementFactory::make_with_name("cmafmux", None)?;
cmafmux.set_property("fragment-duration", item_duration_ns);
cmafmux.set_property_from_str("header-update-mode", "update");
cmafmux.set_property("write-mehd", true);
Many thanks for reading!