GStreamer appending to an existing MP4 video file
Terry Barnaby
terry1 at beam.ltd.uk
Fri May 5 06:31:00 UTC 2023
We have a camera video recording system that captures video, encodes in
H264 and stores in Mp4 container format to a file on a disk.
We now want the ability, sometime later, to append some more video to
that file such that the resulting file is one contiguous MP4 video.
In our C++ code, when appending to an existing MP4 file we are basically
(lots removed) doing:
v4l2src device=/dev/video0 ! vaapih264enc ! h264parse ! mp4mux
fragment-duration=10 ! filesink append=true location=file.mp4 async=false
This works, sort of, in that it just ends up appending a complete MP4
video segment as fif you just concatenated to MP4 video files together,
as expected. So in the MP4 file there are two "ftyp/moov" header sets
with moof/mdat fragments with sequences/times starting from 0 for each
of the video segments.
Some video players will play this contiguously although the displayed
time jumps back, but other playes will stop at the end of the first segment.
So has anyone any ideas how we might achieve this with a C++ driven C++
pipeline (We can create our own gstreamer modules etc.) ?
My thoughts were:
1. Create a different mp4mux with a "append=true", "startSequence=?"
options that will ignore sending the MP4 header information and set its
sequence counter to that given (we can set the gstreamer frame timecodes
as needed).
2. Create a new filesink that can parse the incoming MP4 stream and
ignore the MP4 header when appending and fixup the sequence and time fields.
Is there any capability within the existing gstreamer to do something
like this ?
Any ideas ?
Terry
More information about the gstreamer-devel
mailing list