Commit 427d1915 authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: only mp4mux can tell if it supports specific atoms

parent d30fd611
......@@ -273,7 +273,11 @@ block_t * ForgedInitSegment::buildMoovBox()
trackinfo.fmt.psz_language = strdup(language.c_str());
mp4mux_trackinfo_t *p_tracks = &trackinfo;
bo_t *box = mp4mux_GetMoovBox(NULL, &p_tracks, 1, true, false, false, false);
bo_t *box = NULL;
if(mp4mux_CanMux( NULL, &trackinfo.fmt ))
box = mp4mux_GetMoovBox(NULL, &p_tracks, 1, true, false, false, false);
mp4mux_trackinfo_Clear(&trackinfo);
block_t *moov = NULL;
......
......@@ -1835,3 +1835,47 @@ bo_t *mp4mux_GetFtyp(vlc_fourcc_t major, uint32_t minor, vlc_fourcc_t extra[], s
}
return box;
}
bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt)
{
switch(p_fmt->i_codec)
{
case VLC_CODEC_A52:
case VLC_CODEC_DTS:
case VLC_CODEC_EAC3:
case VLC_CODEC_MP4A:
case VLC_CODEC_MP4V:
case VLC_CODEC_MPGA:
case VLC_CODEC_MP3:
case VLC_CODEC_MPGV:
case VLC_CODEC_MP2V:
case VLC_CODEC_MP1V:
case VLC_CODEC_MJPG:
case VLC_CODEC_MJPGB:
case VLC_CODEC_SVQ1:
case VLC_CODEC_SVQ3:
case VLC_CODEC_H263:
case VLC_CODEC_AMR_NB:
case VLC_CODEC_AMR_WB:
case VLC_CODEC_YV12:
case VLC_CODEC_YUYV:
case VLC_CODEC_VC1:
case VLC_CODEC_WMAP:
break;
case VLC_CODEC_H264:
if(!p_fmt->i_extra && p_obj)
msg_Warn(p_obj, "H264 muxing from AnnexB source will set an incorrect default profile");
break;
case VLC_CODEC_HEVC:
if(!p_fmt->i_extra && p_obj)
msg_Err(p_obj, "HEVC muxing from AnnexB source is unsupported");
return false;
case VLC_CODEC_SUBT:
if(p_obj)
msg_Warn(p_obj, "subtitle track added like in .mov (even when creating .mp4)");
break;
default:
return false;
}
return true;
}
......@@ -71,6 +71,7 @@ bo_t *box_full_new(const char *fcc, uint8_t v, uint32_t f);
void box_fix (bo_t *box, uint32_t);
void box_gather (bo_t *box, bo_t *box2);
bool mp4mux_CanMux(vlc_object_t *, const es_format_t *);
bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);
......@@ -396,40 +396,8 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
sout_mux_sys_t *p_sys = p_mux->p_sys;
mp4_stream_t *p_stream;
switch(p_input->p_fmt->i_codec)
if(!mp4mux_CanMux(VLC_OBJECT(p_mux), p_input->p_fmt))
{
case VLC_CODEC_A52:
case VLC_CODEC_DTS:
case VLC_CODEC_EAC3:
case VLC_CODEC_MP4A:
case VLC_CODEC_MP4V:
case VLC_CODEC_MPGA:
case VLC_CODEC_MP3:
case VLC_CODEC_MPGV:
case VLC_CODEC_MP2V:
case VLC_CODEC_MP1V:
case VLC_CODEC_MJPG:
case VLC_CODEC_MJPGB:
case VLC_CODEC_SVQ1:
case VLC_CODEC_SVQ3:
case VLC_CODEC_H263:
case VLC_CODEC_AMR_NB:
case VLC_CODEC_AMR_WB:
case VLC_CODEC_YV12:
case VLC_CODEC_YUYV:
break;
case VLC_CODEC_H264:
if(!p_input->p_fmt->i_extra)
msg_Warn(p_mux, "H264 muxing from AnnexB source will set an incorrect default profile");
break;
case VLC_CODEC_HEVC:
if(!p_input->p_fmt->i_extra)
msg_Err(p_mux, "HEVC muxing from AnnexB source is unsupported");
return VLC_EGENERIC;
case VLC_CODEC_SUBT:
msg_Warn(p_mux, "subtitle track added like in .mov (even when creating .mp4)");
break;
default:
msg_Err(p_mux, "unsupported codec %4.4s in mp4",
(char*)&p_input->p_fmt->i_codec);
return VLC_EGENERIC;
......
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