minimp4
minimp4 copied to clipboard
Question: support of MOV container
I have an issue when I need to save H264 video + G711 audio into container. I have read that it is not possible with mp4, but is supported by mov. I want to ask maybe it is possible to extend this project or create a new one for support of mov container.
Hi :) mov and mp4 should be pretty much the same.There only different standards and atom/box layouts. If codec do not need any specific atoms, no modification required. Just create new track:
MP4E_track_t tr;
tr.track_media_kind = e_audio;
tr.language[0] = 'u';
tr.language[1] = 'n';
tr.language[2] = 'd';
tr.language[3] = 0;
tr.object_type_indication = MP4_OBJECT_TYPE_AUDIO_ISO_IEC_14496_3;
tr.time_scale = 90000;
tr.default_duration = 0;
tr.u.a.channelcount = 1;
int audio_track_id = MP4E_add_track(mux, &tr);
All we need - specify different codec instead of MP4_OBJECT_TYPE_AUDIO_ISO_IEC_14496_3. According to this https://github.com/ireader/media-server/blob/master/libmov/include/mov-format.h list, it should be
#define MOV_OBJECT_G711a 0xFD // ITU G.711 alaw
#define MOV_OBJECT_G711u 0xFE // ITU G.711 ulaw
Do not know if it's standard values or not though.
Thank you @lieff! I will try it out. Also with setting of tr.object_type_indication
to MOV_OBJECT_G711u
I think I will need to set tr.time_scale
to 8000
, because G711 use 8kHz sample rate. What do you think?
Time scale can be any value, it's just affects timestamps which passed to MP4E_put_sample().
Hi @lieff, do you know if it is enough just to change the tr.object_type_indication? Can we use G.711 packed into the 'mp4a' atom type? If I understand correctly it requires the AAC audio format, and currently, this is the only one supported in your library?
Currently I do not know, that's why I write "If codec do not need any specific atoms". It may require another atom inside BOX_stsd. If you have sample stream - I can take a look.