title: ffmpeg/ffprobe get HLS 'codecs' string for a video/audio stream
body: <p>I'm using ffmpeg to create HLS sub-playlists. I used ffmpeg to create them for the renditions. Now I need to create the <strong>master</strong> playlist .m3u8.</p>
  <p>I need to do this manually, for a few reasons. I have everything I need except the 'CODECS' value.</p>
  <p>How can I get this CODECS value for the video and audio streams within my file?</p>
  <p>I cannot see the relevant data when I use ffprobe to get all the metadata about the streams.</p>
  <p>Example master manifest with CODECS:</p>
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-STREAM-INF:BANDWIDTH=540863,RESOLUTION=640x360,CODECS=&quot;avc1.64001e,mp4a.40.2&quot;
  v0/prog_index.m3u8
  
  #EXT-X-STREAM-INF:BANDWIDTH=2339363,RESOLUTION=960x540,CODECS=&quot;avc1.64001f,mp4a.40.2&quot;
  v1/prog_index.m3u8
  </code></pre>
  <p>Example of metadata I could get using ffprobe:</p>
  <pre><code>{'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}
  </code></pre>
  <pre><code>{'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'}
  </code></pre>