Answers.Body: <p>YouTube re-encodes whatever you give it. The process is lossy so there will be a quality reduction. All you can do is give it a very high quality:</p>
  
  <pre><code>ffmpeg -framerate 10 -pattern_type glob -i 'resized/*.JPG' -vf scale=1280:-2 -c:v libx264 -crf 17 out.mp4
  </code></pre>
  
  <ul>
  <li><p>Use <code>-crf 17</code> or <code>-crf 18</code> for higher quality.</p></li>
  <li><p>Try without <code>-pix_fmt yuv420p</code>. I'm not sure what YouTube uses for pixel format conversion, but perhaps it will look better than the FFmpeg swscale if they are using something different.</p></li>
  <li><p>No need for <code>-profile:v high</code>. Let the encoder choose. You usually only need to set a profile when your target device is limited in profile support.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-14T19:52:47.170Z
Answers.Text: Great, thanks I will give it a shot.
Answers.UserDisplayName: Aydin Hassan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-15T12:18:27.193Z
Answers.Text: Wouldn't 4:2:2 be a better option?
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-23T21:37:58.320Z
Answers.Text: @stib It is unknown if the OP additionally wanted to play the output in non-FFmpeg based players. Also, the JPG input pixel formats may be 4:4:4, so choosing 4:2:2 would not be ideal in that case if a user wanted to let ffmpeg automatically choose the "best" pixel format (yuvj444p in this case) and make YouTube do the conversion.
Answers.UserDisplayName: llogan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-25T00:49:32.970Z
Answers.Text: Of course. I realise I misread "try without" and thought you'd suggested "try with".
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-14T18:42:10.257Z
Answers.LastActivityDate: 2019-11-14T18:42:10.257Z
Answers.UserDisplayName: llogan
Body: <p>I created a video from a bunch of images off my camera using FFMPEG. I set it to 10fps. The output video looks fine. As soon as I upload it to Facebook or Youtube the quality is reduced significantly.</p>
  
  <p>Here is the command I used to create the video:</p>
  
  <p><code>ffmpeg -framerate 10 -pattern_type glob -i 'resized/*.JPG' -s:v 1280x720 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p  out.mp4</code></p>
  
  <p>Each image has been resized to 1000x1500 pixels.</p>
  
  <p>Screenshot from video from ffmpeg: <a href="https://www.dropbox.com/s/r3v30lj15a5hl6a/local.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/r3v30lj15a5hl6a/local.png?dl=0</a>
  Screenshot from video from Youtube: <a href="https://www.dropbox.com/s/qrur54r7xsnnrxs/youtube.png?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/qrur54r7xsnnrxs/youtube.png?dl=0</a></p>
  
  <p>If you look carefully you can see the Youtube one is missing a lot of sharpness and detail. It looks much worse when playing through the video.</p>
  
  <p>FYI - I know nothing about video encoding, I just googled for the ffmpeg command so most likely I am doing something silly.</p>
  
  <p>Thank you!</p>
  
Tags: <ffmpeg><video-quality><youtube>
Title: How to avoid quality loss on yotube/fb when encoding images into video via FFMPEG
UserDisplayName: Aydin Hassan
ThreadText: # How to avoid quality loss on yotube/fb when encoding images into video via FFMPEG
  
  (Asked by: username_0 on 2019-11-14)
  
  I created a video from a bunch of images off my camera using FFMPEG. I set it to 10fps. The output video looks fine. As soon as I upload it to Facebook or Youtube the quality is reduced significantly.
  
  Here is the command I used to create the video:
  
  `ffmpeg -framerate 10 -pattern_type glob -i 'resized/*.JPG' -s:v 1280x720 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p out.mp4`
  
  Each image has been resized to 1000x1500 pixels.
  
  Screenshot from video from ffmpeg: <https://www.dropbox.com/s/r3v30lj15a5hl6a/local.png?dl=0>
  Screenshot from video from Youtube: <https://www.dropbox.com/s/qrur54r7xsnnrxs/youtube.png?dl=0>
  
  If you look carefully you can see the Youtube one is missing a lot of sharpness and detail. It looks much worse when playing through the video.
  
  FYI - I know nothing about video encoding, I just googled for the ffmpeg command so most likely I am doing something silly.
  
  Thank you!
  
  **Tags:** ffmpeg, video-quality, youtube
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-14. Score: 1 | Accepted answer
  
  YouTube re-encodes whatever you give it. The process is lossy so there will be a quality reduction. All you can do is give it a very high quality:
  
  ```
  ffmpeg -framerate 10 -pattern_type glob -i 'resized/*.JPG' -vf scale=1280:-2 -c:v libx264 -crf 17 out.mp4
  
  ```
  
  * Use `-crf 17` or `-crf 18` for higher quality.
  * Try without `-pix_fmt yuv420p`. I'm not sure what YouTube uses for pixel format conversion, but perhaps it will look better than the FFmpeg swscale if they are using something different.
  * No need for `-profile:v high`. Let the encoder choose. You usually only need to set a profile when your target device is limited in profile support.
  
  > **Comments:**
  > **username_0**: Great, thanks I will give it a shot.  
  > **username_2**: Wouldn't 4:2:2 be a better option?  
  > **username_1**: @username_2 It is unknown if the OP additionally wanted to play the output in non-FFmpeg based players. Also, the JPG input pixel formats may be 4:4:4, so choosing 4:2:2 would not be ideal in that case if a user wanted to let ffmpeg automatically choose the "best" pixel format (yuvj444p in this case) and make YouTube do the conversion.  
  > **username_2**: Of course. I realise I misread "try without" and thought you'd suggested "try with".  
  
  ---
  
  