title: How to convert mkv video to hls using compiled ffmpeg
body: <p>With the following commands converting the mkv video into HLS master playlist based video streams is not working correctly.</p>
  <pre><code>ffmpeg -i input.mkv \
    -y -vsync 0 -c:v h264_cuvid -c:v h264_nvenc -c:a copy \
    -map 0:v:0 -map 0:a:0 -vf fade,hwupload_cuda,scale_npp=854:358 -b:v:0 1M -b:a:0 128k \
    -map 0:v:0 -map 0:a:0 -vf fade,hwupload_cuda,scale_npp=1280:536 -b:v:1 3M -b:a:1 192k \
    -var_stream_map &quot;v:0,a:0,name:480p v:1,a:1,name:720p&quot; \
    -hls_time 10 -hls_list_size 0 -hls_time 3 -hls_flags independent_segments -f hls -hls_playlist_type event -master_pl_name &quot;master-pl.m3u8&quot; output-%v.m3u8
  </code></pre>
  <p>And it is generating the output as follows which is wrong.</p>
  <pre><code>#EXTM3U
  #EXT-X-VERSION:6
  #EXT-X-STREAM-INF:BANDWIDTH=1240800,RESOLUTION=1280x536,CODECS=&quot;avc1.4d401f,ac-3&quot;
  output-480p.m3u8
  
  #EXT-X-STREAM-INF:BANDWIDTH=3511200,RESOLUTION=1280x536,CODECS=&quot;avc1.4d401f,ac-3&quot;
  output-720p.m3u8
  </code></pre>
  <h2>Question</h2>
  <p>How to generate master playlist with ffmpeg (which was compiled to work with nvidia GPU)</p>
  <h2>GPU compile configurations</h2>
  <pre><code>--enable-nonfree --disable-shared --enable-gpl --enable-libx264 --enable-cuda --enable-nvenc --enable-cuvid --enable-cuda-nvcc --enable-openssl --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
  
  </code></pre>
  <p>I have copied the multiple resolution based video generating based on following commands which works well, but it works with CPU I would like to convert it into GPU.</p>
  <pre><code>ffmpeg -i input.mkv \
  -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 \
  -c:v libx264 -crf 22 -c:a aac -ar 48000 \
  -filter:v:0 scale=w=480:h=360  -maxrate:v:0 600k -b:a:0 64k  \
  -filter:v:1 scale=w=640:h=480  -maxrate:v:1 900k -b:a:1 128k  \
  -filter:v:2 scale=w=1280:h=720 -maxrate:v:2 900k -b:a:2 128k  \
  -var_stream_map &quot;v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p&quot; \
  -preset slow -hls_list_size 0 -threads 0 -f hls -hls_playlist_type event -hls_time 3 \
  -hls_flags independent_segments -master_pl_name &quot;name-pl.m3u8&quot; \
  &quot;name-%v.m3u8&quot;
  </code></pre>