title: How to create a Master Playlist for HLS using a Java wrapper library for FFMPEG
body: <p>I am trying to find/use a Java Library that wraps around FFMPEG to create HLS compatible segments and metadata files along with a master metadata file. </p>
  
  <p>Most existing libraries perform encoding just fine and allow extra functions for additional audio/video parameters. But I could not find a good way for using them to create a master metadata file and other resolution/bandwidth/bitrate based metadata + segments.</p>
  
  <p>One way that I am planning to go about it is running the piece of code that performs HLS for me multiple times to suit the different bitrates and then programmatically look at the metadata files to compose the master metadata file. But that adds room for errors.</p>
  
  <p>If you know of an existing library that can do it for me. Please share the details. It would really help out.</p>
  
  <p>Libraries:</p>
  
  <ul>
  <li><a href="https://github.com/bramp/ffmpeg-cli-wrapper" rel="nofollow noreferrer">https://github.com/bramp/ffmpeg-cli-wrapper</a></li>
  <li><a href="https://github.com/hoary/JavaAV" rel="nofollow noreferrer">https://github.com/hoary/JavaAV</a> </li>
  <li><a href="https://github.com/kokorin/Jaffree" rel="nofollow noreferrer">https://github.com/kokorin/Jaffree</a></li>
  <li><a href="http://www.xuggle.com/" rel="nofollow noreferrer">http://www.xuggle.com/</a></li>
  </ul>
  
  <p>Documentation (see Section Master Playlist)
  <a href="https://developer.apple.com/library/content/referencelibrary/GettingStarted/AboutHTTPLiveStreaming/about/about.html" rel="nofollow noreferrer">https://developer.apple.com/library/content/referencelibrary/GettingStarted/AboutHTTPLiveStreaming/about/about.html</a></p>
  
  <p>FFMPEG command line code that works for me</p>
  
  <pre><code>ffmpeg -loglevel debug -threads 4 -vsync 1 -i 'id.mp4' -vf yadif -g 29.97 -r 29.97 -b:v:0 5250k -c:v libx264 -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -rc-lookahead 32 -forced-idr 1 -b:v:1 4200k -c:v libx264 -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -rc-lookahead 32 -forced-idr 1 -b:v:1 3150k -c:v libx264 -rc:v vbr_hq -pix_fmt yuv420p -profile:v main -level 4.1 -rc-lookahead 32 -forced-idr 1 -b:a:0 256k -b:a:0 192k -b:a:0 128k -c:a aac -ar 48000  -map 0:v -map 0:a:0 -map 0:v -map 0:a:0 -map 0:v -map 0:a:0 -f hls -var_stream_map "v:0,a:0  v:1,a:1 v:2,a:2" -master_pl_name  master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size 0 -master_pl_publish_rate 10 -hls_flags delete_segments+discont_start+split_by_time "vs%v_manifest.m3u8"
  </code></pre>
  
  <p>Any help would be appreciated. Thanks in advance.</p>