Commit 3d5290f7 authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: generate AV1 extradata when missing

parent 50ee8803
......@@ -13,6 +13,8 @@ libmux_mp4_plugin_la_SOURCES = mux/mp4/mp4.c \
packetizer/hxxx_nal.c packetizer/hxxx_nal.h \
packetizer/hevc_nal.c packetizer/hevc_nal.h \
packetizer/h264_nal.c packetizer/h264_nal.h
libmux_mp4_plugin_la_SOURCES += $(extradata_builder_SOURCES)
libmux_mpjpeg_plugin_la_SOURCES = mux/mpjpeg.c
libmux_ps_plugin_la_SOURCES = \
mux/mpeg/pes.c mux/mpeg/pes.h \
......
......@@ -2255,15 +2255,7 @@ bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt,
case VLC_CODEC_YUYV:
case VLC_CODEC_VC1:
case VLC_CODEC_WMAP:
break;
case VLC_CODEC_AV1:
/* Extradata is an AVC1DecoderConfigurationRecord */
if(p_fmt->i_extra < 4 || ((uint8_t *)p_fmt->p_extra)[0] != 0x81)
{
if(p_obj)
msg_Err(p_obj, "Can't mux AV1 without extradata");
return false;
}
break;
case VLC_CODEC_H264:
if(!p_fmt->i_extra && p_obj)
......
......@@ -44,6 +44,7 @@
#include "libmp4mux.h"
#include "../packetizer/hxxx_nal.h"
#include "../av1_pack.h"
#include "../extradata.h"
/*****************************************************************************
* Module descriptor
......@@ -130,6 +131,8 @@ typedef struct
mp4mux_trackinfo_t *tinfo;
const es_format_t *p_fmt;
mux_extradata_builder_t *extrabuilder;
/* index */
vlc_tick_t i_length_neg;
......@@ -177,6 +180,9 @@ typedef struct
static void mp4_stream_Delete(mp4_stream_t *p_stream)
{
if(p_stream->extrabuilder)
mux_extradata_builder_Delete(p_stream->extrabuilder);
/* mp4 frag */
if (p_stream->p_held_entry)
{
......@@ -520,6 +526,7 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
return VLC_ENOMEM;
}
p_stream->extrabuilder = mux_extradata_builder_New(p_input->p_fmt->i_codec);
p_stream->p_fmt = p_input->p_fmt;
p_input->p_sys = p_stream;
......@@ -602,6 +609,17 @@ static block_t * BlockDequeue(sout_input_t *p_input, mp4_stream_t *p_stream)
if(unlikely(!p_block))
return NULL;
/* Create on the fly extradata as packetizer is not in the loop */
if(p_stream->extrabuilder && !mp4mux_track_HasSamplePriv(p_stream->tinfo))
{
mux_extradata_builder_Feed(p_stream->extrabuilder,
p_block->p_buffer, p_block->i_buffer);
const uint8_t *p_extra;
size_t i_extra = mux_extradata_builder_Get(p_stream->extrabuilder, &p_extra);
if(i_extra)
mp4mux_track_SetSamplePriv(p_stream->tinfo, p_extra, i_extra);
}
switch(p_stream->p_fmt->i_codec)
{
case VLC_CODEC_AV1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment