title: Ffmpeg converting to HLS - video extremely low quality
body: <p>I'm building a streaming webapp that uses FFMPEG. The client sends webcam video using FFMPEG (converting the webm stream into mpeg-ts in the process) over RTMP, and the media server receives the mpeg-ts stream, transcodes it into HLS with multiple quality levels for ABR (using a master playlist). </p>
  
  <p>So far, I've got all of this working, except that my transcoding command creates HLS segments that are extremely low quality; the video is very pixellated, and the best quality level (1080p) just looks like 240p scaled up to 1080p. In order to test my FFMPEG command I remuxed a sample high quality 1080p movie into mpeg-ts (I checked the quality, it looks the same as the original), and I'm using this command to transcode this movie into HLS for the test : </p>
  
  <pre><code>ffmpeg.exe -threads 4 -filter_complex_threads 4 -vsync 1 -i output.ts -filter_complex 
  "[v:0]split=5[s0][s1][s2][s3][s4]; 
  [s0]scale=w=1920:h=1080:flags=lanczos,yadif[v0];
  [s1]scale=w=1280:h=720:flags=lanczos,yadif[v1];
  [s2]scale=w=854:h=480:flags=lanczos,yadif[v2];
  [s3]scale=w=480:h=360:flags=lanczos,yadif[v3];
  [s4]scale=w=426:h=240:flags=lanczos,yadif[v4]" 
  -map "[v0]" -pix_fmt yuv420p -r 23.976 -vcodec libx264 -b:v 3400k -preset medium -profile:v baseline -keyint_min 24 -g 48 -x264opts no-scenecut -strict experimental -map_metadata -1 
  -map "[v1]" -pix_fmt yuv420p -r 23.976 -vcodec libx264 -b:v 1725k -preset medium -profile:v baseline -keyint_min 24 -g 48 -x264opts no-scenecut -strict experimental -map_metadata -1 
  -map "[v2]" -pix_fmt yuv420p -r 23.976 -vcodec libx264 -b:v 960k -preset medium -profile:v baseline -keyint_min 24 -g 48 -x264opts no-scenecut -strict experimental -map_metadata -1 
  -map "[v3]" -pix_fmt yuv420p -r 23.976 -vcodec libx264 -b:v 510k -preset medium -profile:v baseline -keyint_min 24 -g 48 -x264opts no-scenecut -strict experimental -map_metadata -1  
  -map "[v4]" -pix_fmt yuv420p -r 23.976 -vcodec libx264 -b:v 320k -preset medium -profile:v baseline -keyint_min 24 -g 48 -x264opts no-scenecut -strict experimental -map_metadata -1 
  -map a:0 -map a:0 -map a:0 -map a:0 -map a:0 -c:a aac -b:a 96k -af “aresample=async=1:min_hard_comp=0.100000:first_pts=0” 
  -f hls -var_stream_map "v:0,a:0 v:1,a:1, v:2,a:2, v:3,a:3, v:4,a:4" 
  -hls_wrap 24 -hls_time 10 -master_pl_name master.m3u8 "C:/Users/John/Desktop/ffmpeg-20181218-978c935-win64-static/bin/vs%v/manifest.m3u8"
  </code></pre>
  
  <p>I'm very new to FFMPEG, I referred to <a href="https://videoblerg.wordpress.com/2016/08/16/how-to-create-abr-content-with-ffmpeg-in-one-pass/" rel="nofollow noreferrer">this</a> article for the video options, and modified it to create HLS instead of mp4. Needless to say I botched this up pretty bad, although the command itself works and does what I need it to (other than the crappy quality). Could anyone help me optimize this command to make it transcode much less lossy video? </p>