Reputation: 167
I am creating a master m3u8 file to allow adaptive streaming of two streaming videos. Both have the readable codec name MPEG-4 AVC (part 10) (avc1)
How can I translate this into the CODECS value that should appear in my master m3u8 playlist file, as in this example:
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,CODECS="avc1.42001f,mp4a.40.2",RESOLUTION=354x240
How do I get the value to replace avc1.42001f,mp4a.40.2
Apple's specs say "Valid format identifiers are those in the ISO file format name space defined by RFC 6381 [RFC6381]" but I have no idea how to read the RFC 6381 documentation.
Upvotes: 4
Views: 4931
Reputation: 9466
You can consult ffmpeg code https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavformat/hlsenc.c , search for 'write_codec_attr' (but unfortunately it is not in any public interface)
Upvotes: 0
Reputation: 167
With advice from commenters here, I refined my Google searches and eventually found a blog post explaining how the codes are constructed:
A comment on this post led me to the mp4box.js utility, which loads a file and gives a ton of info, including the CODECS value:
Upvotes: 2
Reputation: 31100
Each codec string is codec specific. For audio, mp4a
indicate its mpeg audio 40
means its mpeg 4.0 (I think) and the last integer is the "audio object type". AAC-LC is 2. The full list can be found here. https://wiki.multimedia.cx/index.php/MPEG-4_Audio#Audio_Object_Types
For video, in your example case, The video codec is h.264, also known as "advanced video codec" aka avc1
. The hex string is 3 bytes representing the codec profile, flags, and level. Those can be found in the first 3 bytes the the SPS.
Other codecs are different.
Upvotes: 4