4

I'm using ffmpeg to create HLS sub-playlists. I used ffmpeg to create them for the renditions. Now I need to create the master playlist .m3u8.

I need to do this manually, for a few reasons. I have everything I need except the 'CODECS' value.

How can I get this CODECS value for the video and audio streams within my file?

I cannot see the relevant data when I use ffprobe to get all the metadata about the streams.

Example master manifest with CODECS:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=540863,RESOLUTION=640x360,CODECS="avc1.64001e,mp4a.40.2"
v0/prog_index.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=2339363,RESOLUTION=960x540,CODECS="avc1.64001f,mp4a.40.2"
v1/prog_index.m3u8

Example of metadata I could get using ffprobe:

{'avg_frame_rate': '24000/1001',
 'bit_rate': '35956',
 'bits_per_raw_sample': '8',
 'chroma_location': 'left',
 'closed_captions': 0,
 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
 'codec_name': 'h264',
 'codec_tag': '0x31637661',
 'codec_tag_string': 'avc1',
 'codec_time_base': '1001/48000',
 'codec_type': 'video',
 'coded_height': 368,
 'coded_width': 640,
 'display_aspect_ratio': '16:9',
 'disposition': {'attached_pic': 0,
                 'clean_effects': 0,
                 'comment': 0,
                 'default': 1,
                 'dub': 0,
                 'forced': 0,
                 'hearing_impaired': 0,
                 'karaoke': 0,
                 'lyrics': 0,
                 'original': 0,
                 'timed_thumbnails': 0,
                 'visual_impaired': 0},
 'duration': '5.005000',
 'duration_ts': 120120,
 'has_b_frames': 2,
 'height': 360,
 'index': 0,
 'is_avc': 'true',
 'level': 30,
 'nal_length_size': '4',
 'nb_frames': '120',
 'pix_fmt': 'yuv420p',
 'profile': 'High',
 'r_frame_rate': '24000/1001',
 'refs': 1,
 'sample_aspect_ratio': '1:1',
 'start_pts': 0,
 'start_time': '0.000000',
 'tags': {'handler_name': 'VideoHandler',
          'language': 'eng',
          'timecode': '01:00:00:00'},
 'time_base': '1/24000',
 'width': 640}
{'avg_frame_rate': '0/0',
 'bit_rate': '138375',
 'bits_per_sample': 0,
 'channel_layout': 'stereo',
 'channels': 2,
 'codec_long_name': 'AAC (Advanced Audio Coding)',
 'codec_name': 'aac',
 'codec_tag': '0x6134706d',
 'codec_tag_string': 'mp4a',
 'codec_time_base': '1/48000',
 'codec_type': 'audio',
 'disposition': {'attached_pic': 0,
                 'clean_effects': 0,
                 'comment': 0,
                 'default': 1,
                 'dub': 0,
                 'forced': 0,
                 'hearing_impaired': 0,
                 'karaoke': 0,
                 'lyrics': 0,
                 'original': 0,
                 'timed_thumbnails': 0,
                 'visual_impaired': 0},
 'duration': '5.005000',
 'duration_ts': 240240,
 'index': 1,
 'max_bit_rate': '138375',
 'nb_frames': '236',
 'profile': 'LC',
 'r_frame_rate': '0/0',
 'sample_fmt': 'fltp',
 'sample_rate': '48000',
 'start_pts': 0,
 'start_time': '0.000000',
 'tags': {'handler_name': 'SoundHandler', 'language': 'eng'},
 'time_base': '1/48000'}
llogan
  • 121,796
  • 28
  • 232
  • 243
Richard
  • 215
  • 1
  • 9

1 Answers1

1

ffprobe will not provide HLS CODECS information.

Although you are manually making your own master playlist, add -master_pl_name playlist.m3u8 to your command and get the CODECS values from the resulting file (playlist.m3u8).

llogan
  • 121,796
  • 28
  • 232
  • 243
  • I'm manually creating the master playlist, without ffmpeg, so that isn't possible. – Richard Dec 18 '20 at 22:26
  • @Richard Confusing, because in your question you said, "I'm using ffmpeg to create HLS playlists". So how are you actually using ffmpeg? You can still use ffmpeg and create your own master playlist manually. – llogan Dec 18 '20 at 22:58
  • I'm creating the subplaylists using ffmpeg. And the master playlist manually without ffmpeg. – Richard Dec 18 '20 at 23:01
  • @Richard Doesn't really clarify anything. I don't understand why you can't just add `-master_pl_name` to your ffmpeg HLS command to get a temporary playlist for the sole purpose of getting CODECS for you to help you create your actual master playlist manually. – llogan Dec 18 '20 at 23:05
  • Because like I said. I am generating the master playlist WITHOUT ffmpeg. So I am not running ffmpeg and therefore cannot add master_pl_name parameter. – Richard Dec 18 '20 at 23:12
  • @Richard So you are "using ffmpeg to create HLS sub-playlists", but "not running ffmpeg". Maybe if you show your ffmpeg command (assuming you are actually using ffmpeg given the contradictory statements) it will clarify things. Because right now as far as I can tell my answer directly addresses your question of "ffmpeg/ffprobe get 'codecs' string for a video/audio stream". 1) ffprobe: not possible. 2) ffmpeg: `-master_pl_name` workaround. – llogan Dec 18 '20 at 23:15
  • here's the command for creating one of the sub-playlists: `ffmpeg -i 1080p_30fps_vertical.webm -hls_time 5 -hls_segment_filename /tmp/%d.ts -hls_playlist_type vod /tmp/rendition.m3u8` – Richard Dec 18 '20 at 23:19
  • If i add `-master_pl_name file.m3u8` to that, ffmpeg says 'Trailing option(s) found in the command: may be ignored.' – Richard Dec 18 '20 at 23:19
  • @Richard Option placement is important: `ffmpeg [input options] -i input [output options] output`. Use `ffmpeg -i /home/comp/dev/app/tests/test_data/1080p_30fps_vertical.webm -hls_time 5 -hls_segment_filename /tmp/pytest-of-comp/pytest-37/test_create_segments_for_video0/%d.ts -master_pl_name file.m3u8 -hls_playlist_type vod /tmp/pytest-of-comp/pytest-37/test_create_segments_for_video0/rendition.m3u8` – llogan Dec 18 '20 at 23:24