webmmux byte offset

F Weers dedomme123 at gmail.com
Sun May 22 20:12:24 UTC 2022


Summary: I think no plugin exists that can give me the written webm segment
byte-offset at disk. Trying to figure out where to insert an event in the
webmmux plugin.

Going through the webmmux plugin code, it looks like the master segment is
written here:
https://github.com/GStreamer/gst-plugins-good/blob/20bbeb5e37666c53c254c7b08470ad8a00d97630/gst/matroska/matroska-mux.c#L2651
.
I *think* a 'normal' segment is written here:
https://github.com/GStreamer/gst-plugins-good/blob/20bbeb5e37666c53c254c7b08470ad8a00d97630/gst/matroska/matroska-mux.c#L3187,
but I am not 100% sure. Looks like it finishes it's writing here:
https://github.com/GStreamer/gst-plugins-good/blob/20bbeb5e37666c53c254c7b08470ad8a00d97630/gst/matroska/matroska-mux.c#L3304
.

I guess I need to keep track of the segment offset at the start and its
final size to get a similar output (from
https://github.com/acolwell/mse-tools, mse_json_manifest) to this:

  "init": { "offset": 0, "size": 531},

  "media": [

    { "offset": 531, "size": 28194, "timecode": 0.000000 },

    { "offset": 28725, "size": 28007, "timecode": 0.041000 },

    { "offset": 56732, "size": 27994, "timecode": 0.083000 },

    { "offset": 84726, "size": 27999, "timecode": 0.125000 },

    { "offset": 112725, "size": 28006, "timecode": 0.166000 },

    { "offset": 140731, "size": 28012, "timecode": 0.208000 },

  ]

In the output above, init shows the initialization segment, and the media
contains the array of segments that follow.

In case anyone would be able to help with adding this functionality, or
providing knowledge about an existing element/property that is helpful
here, please let me know :)
Thank you very much in advance!

Sincerely,
Floris Weers

Op di 10 mei 2022 om 19:50 schreef F Weers <dedomme123 at gmail.com>:

> Hi all,
>
> summary: I have a pipeline that writes any video (with audio) to webm
> format (in which every frame is a keyframe), I want to know the byteoffsets
> of the (key-)frames of the written file.
>
> First of all, thanks for the awesome Rust support of GStreamer. I'm quite
> new to Rust, but it feels very natural to convert a console-command to the
> Rust equivalent!
> I have the following (simplified) pipeline:
>
> gst-launch-1.0 webmmux name=mux ! filesink location="output.webm" filesrc location="input.mp4" ! decodebin name=demux \
> demux. ! videoconvert ! videoscale ! videorate ! vp9enc !  mux.video_0 \
> demux. ! audioconvert ! audioresample ! opusenc ! mux.audio_0
>
>
> It converts an mp4 file to a webm file (I started with this ffmpeg
> command: 'ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -g 1 -b:v 0 -b:a 128k
> -c:a libopus output.webm'). This works great. In my code, I also set the
> keyframe-max-dist to 1, which means that every frame is a keyframe (the
> '-g 1' argument in the ffmpeg command). Now, I'd like to get the byte
> offsets of the key-frames, so I can directly load the segments from disk.
> While I can get those offsets using https://github.com/acolwell/mse-tools
> , I'd like to get them directly while converting an input video to its webm
> version with only keyframes.
>
> Thank you in advance! Let me know if something is unclear.
>
> Sincerely,
> Floris Weers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220522/a7195f80/attachment.htm>


More information about the gstreamer-devel mailing list