I want to add a protobuf
message as attachment to a Matroska (mkv) video file after all video frames have been written without copying the video data. This must be possible because attaching an arbitrary file to an mkv can be achieved with the MKVToolNix suite (for a JPG):
# add attachment, no copy according to man page
mkvpropedit out.mkv --add-attachment ~/Downloads/hummingbird.jpg
.
.
# get attachment id
mkvmerge -i out.mkv
.
Attachment ID 1: type 'image/jpeg', size 821740 bytes, file name 'hummingbird.jpg'
.
# extract attachment
mkvextract attachments out.mkv 1:./test.jpg
I want to be capable to perform the same read-write-cycle by calling library methods. Preferably without the need to write the protobuf
message to a file first (e.g. by passing a byte array of the serialized protobuf
message).
Currently I'm using libav
for reading/writing video data from/to mkv. Therefor my favorite solution would also only depend on libav
. If this is not possible I would consider introducing libEBML
and libMatroska
as new dependencies (same as MKVToolNix).
What are the key functions in the frameworks that need to be called to achieve the goal? I'm pretty sure mbunkus knows the solution ...