Answers.Body: <h1>Convert 4k to 1080 (no change in codec)</h1>
  <pre><code>ffmpeg -i input4kvid.mp4 -vf scale=1920:1080 -c:a copy output1080vid.mp4
  </code></pre>
  <h1>Convert h.264 to h.265 (no change in resolution)</h1>
  <pre><code>ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -c:a copy output.mp4
  </code></pre>
  <h1>Convert 4k(h.264) to 1080(h.265)</h1>
  <ul>
  <li>Downscaling + Change in compression codec</li>
  </ul>
  <pre><code>ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -vf scale=1920:1080 -crf 20 -c:a copy output.mp4
  </code></pre>
  <h2>Options Explained</h2>
  <p><code>-i</code> input file name or file path</p>
  <p><code>-c:v libx265 -vtag hvc1</code> selecting compression. Default is <code>libx264</code></p>
  <p><code>-vf scale=1920:1080</code> specifying output resolution</p>
  <p><code>-c:a copy</code> copy audio as it is without any compression</p>
  <p><code>-preset slow</code> ask compression algorithm to take more time &amp; look for more areas for compression. Default is <code>medium</code>. Other options are <code>faster</code>, <code>fast</code>, <code>medium</code>, <code>slow</code>, <code>slower</code></p>
  <p><code>-crf 20</code> Compression quality</p>
  <blockquote>
  <p><code>-crf 0</code> high-quality, low compression, large file</p>
  </blockquote>
  <blockquote>
  <p><code>-crf 23</code> default</p>
  </blockquote>
  <blockquote>
  <p><code>-crf 51</code> low-quality, high compression, small file</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-23T14:15:17.640Z
Answers.LastActivityDate: 2021-09-24T13:49:05.393Z
Answers.LastEditDate: 2021-09-24T13:49:05.393Z
Answers.UserDisplayName: KeshavDulal
Answers.Body: <p>Use <strong>avconv</strong> if you want:</p>
  
  <pre><code>avconv -i 4kfile.mp4 -s hd1080 -c:v libx264 -c:a copy fullhdfile.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-23T13:52:53.593Z
Answers.LastActivityDate: 2018-07-23T13:52:53.593Z
Answers.UserDisplayName: Guray Celik
Answers.Body: <p><strike>The default settings for ffmpeg are very low quality, and since you don't specify any codec or quality parameters it's just using the defaults (I don't know why the devs don't fix that because it generates a lot of questions on forums everywhere).</strike></p>
  <p><em><strong>Edit</strong>: the defaults are now quite sane. With a recent (as in later than 2017) build of ffmpeg you don't need to specify anything more than input and output files to achieve good useable results. You can, of course tweak to your heart's desire.</em></p>
  <p>Try adding <strike><code>-c:v libx264</code></strike> <code>-crf 20 -preset slow</code> to the command.</p>
  <ul>
  <li><strike><code>-c:v libx264</code> tells it to use the libx264 encoder,</strike> this is the default now, no need to specify it</li>
  <li><code>crf 20</code> uses the Constant Rate Factor quantiser (which paradoxially means variable bit rate, but constant quality) with a value of 20 (pretty good quality; lower is better quality / larger files, higher is crappier / smaller)—default is 23,</li>
  <li>the <code>slow</code> preset is a shortcut for a bunch of encoder settings that means it puts a bit more effort into it than the default (medium). Note that the speed presets don't change the quality of the encoded file, just the efficiency, meaning a slower encode will result in a smaller file of the same quality and a faster encode will mean a larger file of the same quality.</li>
  </ul>
  <p>You can tweak these settings, see the <a href="https://trac.ffmpeg.org/wiki/Encode/H.264" rel="noreferrer">h.264 encoding guide</a> for instructions on what knobs to twiddle.</p>
  <p>And if you're using the audio as-is, add <code>c:a copy</code>. That will do a straight copy of the audio stream without re-encoding.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-21T06:24:28.787Z
Answers.Text: The defaults depends on the encoder. libx264 is usually used for MP4 output by default, and it produces a nice quality output with no additional options, but the ffmpeg build in the question appears to not support this encoder and therefore uses the ancient encoder `mpeg4` producing MPEG-4 Part 2 video, and the defaults for it were more sane during its heyday (such as for 320x240, etc).
Answers.UserDisplayName: llogan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-23T01:00:59.433Z
Answers.Text: It's good to hear that libx264 is the default now.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-15T12:36:54.103Z
Answers.Text: I'd say crf 20 is pretty *darn* good. 18 is functionally lossless. I do most of my videos at 23.
Answers.UserDisplayName: user3643
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-16T13:47:58.557Z
Answers.Text: Most of my work gets displayed on playback devices working locally from an SD card. I don't need to optimise much for size, so I leave the quality as high as I can. I agree, I'd dial it down if I was delivering over the web.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-03T13:59:31.033Z
Answers.Text: This didn't help me. I still have blocky weirdness wherever motion occurs in the video. crf of 18, preset to slow. 2.7k->1080p.
Answers.UserDisplayName: rewolf
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-23T23:55:53.710Z
Answers.Text: @rewolf post a question, rather than asking in the comments.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-25T06:09:25.837Z
Answers.Text: @stib I'm not asking a question. I'm saying that this is not a definite answer the problem posed (or one of the same nature). That is useful to others in the same position.
Answers.UserDisplayName: rewolf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-10T11:19:31.917Z
Answers.Text: What if the quality is lower than 1080 already and we don't want to upscale it?
Answers.UserDisplayName: Oliver Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-10T13:08:59.847Z
Answers.Text: @OliverDixon I'm not sure what you're asking. If the resolution is lower than 1080p and you don't want to upscale it then you can display it at its current resolution..?
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-11T09:35:39.237Z
Answers.Text: @stib I found a solution using 'min'. I was seeing performance problems with this because low quality videos were trying to upscale from users.
Answers.UserDisplayName: Oliver Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-02-20T07:17:43.867Z
Answers.LastActivityDate: 2021-04-09T05:11:26.587Z
Answers.LastEditDate: 2021-04-09T05:11:26.587Z
Answers.UserDisplayName: stib
Body: <p>I have some 4K 3840x2160 footage in MP4 format that I need to bring down to 1080p. I tried running </p>
  
  <pre><code>ffmpeg -i orig.mp4 -vf scale=1920:1080 smaller.mp4  
  </code></pre>
  
  <p>but the result is very poor quality, with the entire image being composed of square "tiles" as if I was magnifying 4:1.</p>
  
  <p>Here is the output of running this command:</p>
  
  <pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'origs/P1000003.MP4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: mp42avc1
      creation_time   : 2015-02-19 17:10:38
    Duration: 00:05:14.48, start: 0.000000, bitrate: 95903 kb/s
      Stream #0.0(und): Video: h264 (High), yuvj420p, 3840x2160 [PAR 1:1 DAR 16:9], 95792 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
      Metadata:
        creation_time   : 2015-02-19 17:10:38
      Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 125 kb/s
      Metadata:
        creation_time   : 2015-02-19 17:10:38
  Incompatible pixel format 'yuvj420p' for codec 'mpeg4', auto-selecting format 'yuv420p'
  [buffer @ 0x22a3420] w:3840 h:2160 pixfmt:yuvj420p
  [scale @ 0x22a3ce0] w:3840 h:2160 fmt:yuvj420p -&gt; w:1920 h:1080 fmt:yuv420p flags:0x4
  Output #0, mp4, to '1-short.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: mp42avc1
      creation_time   : 2015-02-19 17:10:38
      encoder         : Lavf53.21.1
      Stream #0.0(und): Video: mpeg4, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
      Metadata:
        creation_time   : 2015-02-19 17:10:38
      Stream #0.1(und): Audio: libvo_aacenc, 48000 Hz, stereo, s16, 200 kb/s
      Metadata:
        creation_time   : 2015-02-19 17:10:38
  Stream mapping:
    Stream #0.0 -&gt; #0.0
    Stream #0.1 -&gt; #0.1
  Press ctrl-c to stop encoding
  frame=  125 fps=  6 q=31.0 Lsize=     968kB time=5.00 bitrate=1586.7kbits/s    
  video:842kB audio:123kB global headers:0kB muxing overhead 0.421047%
  </code></pre>
  
  <p>I know from experience that ffmpeg is an excellent tool, so I must be screwing up the options/parameters somehow...</p>
  
  <p>How can I do this? </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-19T20:22:00.680Z
Comments.Text: Please show the full, complete console output from your command. You can just encode a short segment, so add `-t 10` to make a 10 second output. Why do you want to downscale? What is the use case for your scaled output? This info will help me provide a more accurate answer.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-20T00:10:43.577Z
Comments.Text: @LordNeckbeard I have just added the console output. I want to downscale so that I can more easily share these clips with people who are working with me.
Comments.UserDisplayName: lara michaels
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-20T03:29:21.227Z
Comments.Text: Looks like some stuff was omitted. I'm also looking for the version info and how it was configured. Can you show the whole output?
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-21T06:22:50.143Z
Comments.Text: I will still provide an answer with additional info if the complete console output is provided.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T03:10:52.187Z
Comments.Text: Don't forget `-c:a copy`, since you don't want or need to re-encode the audio stream.  Use `-map 0` to copy any chapter metadata, or other stuff.  (ffmpeg only takes 1 vid + 1 aud by default.)
Comments.UserDisplayName: Peter Cordes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T03:14:19.700Z
Comments.Text: Also, `-sws_flags lanczos+print_info` will use a better scaling algo than the default (bilinear I think).  stlb's answer covers the video encoding part of the process.
Comments.UserDisplayName: Peter Cordes
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T18:04:28.077Z
Comments.Text: @PeterCordes Alternatively, `scale=1920:-2:flags=lanczos`. I was also going to mention the `-2` for scale in my non-existent answer. For those who don't know you can put `-2` in width or height, and it will automatically provide the correct value while preserving aspect ratio **and** making the value divisible by 2 (required by libx264 for yuv420p outputs).
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-23T22:45:31.040Z
Comments.Text: `-sws_flags` will use lanczos for scaling chroma when going from 4:4:4: to 4:2:0 or vice verse, for example.  So I think it's not a bad idea to have it on your command line at all times, in case you do something that auto-inserts a scale filter.  But yeah, auto-calculated height = win.  You won't always get perfectly square pixels in your output, if the required height isn't a multiple of 2 (or even a whole number), but ffmpeg will set the display aspect ratio in the output so players will scale it correctly if up or down-scaling.
Comments.UserDisplayName: Peter Cordes
Tags: <ffmpeg><file-formats><conversion><full-hd><4k>
Title: How to downsample 4k to 1080p using ffmpeg while maintaining the quality?
UserDisplayName: lara michaels
ThreadText: # How to downsample 4k to 1080p using ffmpeg while maintaining the quality?
  
  (Asked by: username_0 on 2015-02-19)
  
  I have some 4K 3840x2160 footage in MP4 format that I need to bring down to 1080p. I tried running
  
  ```
  ffmpeg -i orig.mp4 -vf scale=1920:1080 smaller.mp4  
  
  ```
  
  but the result is very poor quality, with the entire image being composed of square "tiles" as if I was magnifying 4:1.
  
  Here is the output of running this command:
  
  ```
  Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'origs/P1000003.MP4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: mp42avc1
      creation_time   : 2015-02-19 17:10:38
    Duration: 00:05:14.48, start: 0.000000, bitrate: 95903 kb/s
      Stream #0.0(und): Video: h264 (High), yuvj420p, 3840x2160 [PAR 1:1 DAR 16:9], 95792 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
      Metadata:
        creation_time   : 2015-02-19 17:10:38
      Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 125 kb/s
      Metadata:
        creation_time   : 2015-02-19 17:10:38
  Incompatible pixel format 'yuvj420p' for codec 'mpeg4', auto-selecting format 'yuv420p'
  [buffer @ 0x22a3420] w:3840 h:2160 pixfmt:yuvj420p
  [scale @ 0x22a3ce0] w:3840 h:2160 fmt:yuvj420p -> w:1920 h:1080 fmt:yuv420p flags:0x4
  Output #0, mp4, to '1-short.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: mp42avc1
      creation_time   : 2015-02-19 17:10:38
      encoder         : Lavf53.21.1
      Stream #0.0(und): Video: mpeg4, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 tbn, 25 tbc
      Metadata:
        creation_time   : 2015-02-19 17:10:38
      Stream #0.1(und): Audio: libvo_aacenc, 48000 Hz, stereo, s16, 200 kb/s
      Metadata:
        creation_time   : 2015-02-19 17:10:38
  Stream mapping:
    Stream #0.0 -> #0.0
    Stream #0.1 -> #0.1
  Press ctrl-c to stop encoding
  frame=  125 fps=  6 q=31.0 Lsize=     968kB time=5.00 bitrate=1586.7kbits/s    
  video:842kB audio:123kB global headers:0kB muxing overhead 0.421047%
  
  ```
  
  I know from experience that ffmpeg is an excellent tool, so I must be screwing up the options/parameters somehow...
  
  How can I do this?
  
  **Tags:** ffmpeg, file-formats, conversion, full-hd, 4k
  
  > **Comments:**
  > **username_1**: Please show the full, complete console output from your command. You can just encode a short segment, so add `-t 10` to make a 10 second output. Why do you want to downscale? What is the use case for your scaled output? This info will help me provide a more accurate answer.  
  > **username_0**: @LordNeckbeard I have just added the console output. I want to downscale so that I can more easily share these clips with people who are working with me.  
  > **username_1**: Looks like some stuff was omitted. I'm also looking for the version info and how it was configured. Can you show the whole output?  
  > **username_1**: I will still provide an answer with additional info if the complete console output is provided.  
  > **username_2**: Don't forget `-c:a copy`, since you don't want or need to re-encode the audio stream.  Use `-map 0` to copy any chapter metadata, or other stuff.  (ffmpeg only takes 1 vid + 1 aud by default.)  
  > **username_2**: Also, `-sws_flags lanczos+print_info` will use a better scaling algo than the default (bilinear I think).  stlb's answer covers the video encoding part of the process.  
  > **username_1**: @username_2 Alternatively, `scale=1920:-2:flags=lanczos`. I was also going to mention the `-2` for scale in my non-existent answer. For those who don't know you can put `-2` in width or height, and it will automatically provide the correct value while preserving aspect ratio **and** making the value divisible by 2 (required by libx264 for yuv420p outputs).  
  > **username_2**: `-sws_flags` will use lanczos for scaling chroma when going from 4:4:4: to 4:2:0 or vice verse, for example.  So I think it's not a bad idea to have it on your command line at all times, in case you do something that auto-inserts a scale filter.  But yeah, auto-calculated height = win.  You won't always get perfectly square pixels in your output, if the required height isn't a multiple of 2 (or even a whole number), but ffmpeg will set the display aspect ratio in the output so players will scale it correctly if up or down-scaling.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_5 on 2015-02-20. Score: 41 | Accepted answer
  
  The default settings for ffmpeg are very low quality, and since you don't specify any codec or quality parameters it's just using the defaults (I don't know why the devs don't fix that because it generates a lot of questions on forums everywhere).
  
  ***Edit**: the defaults are now quite sane. With a recent (as in later than 2017) build of ffmpeg you don't need to specify anything more than input and output files to achieve good useable results. You can, of course tweak to your heart's desire.*
  
  Try adding `-c:v libx264` `-crf 20 -preset slow` to the command.
  
  * `-c:v libx264` tells it to use the libx264 encoder, this is the default now, no need to specify it
  * `crf 20` uses the Constant Rate Factor quantiser (which paradoxially means variable bit rate, but constant quality) with a value of 20 (pretty good quality; lower is better quality / larger files, higher is crappier / smaller)—default is 23,
  * the `slow` preset is a shortcut for a bunch of encoder settings that means it puts a bit more effort into it than the default (medium). Note that the speed presets don't change the quality of the encoded file, just the efficiency, meaning a slower encode will result in a smaller file of the same quality and a faster encode will mean a larger file of the same quality.
  
  You can tweak these settings, see the [h.264 encoding guide](https://trac.ffmpeg.org/wiki/Encode/H.264) for instructions on what knobs to twiddle.
  
  And if you're using the audio as-is, add `c:a copy`. That will do a straight copy of the audio stream without re-encoding.
  
  > **Comments:**
  > **username_1**: The defaults depends on the encoder. libx264 is usually used for MP4 output by default, and it produces a nice quality output with no additional options, but the ffmpeg build in the question appears to not support this encoder and therefore uses the ancient encoder `mpeg4` producing MPEG-4 Part 2 video, and the defaults for it were more sane during its heyday (such as for 320x240, etc).  
  > **username_5**: It's good to hear that libx264 is the default now.  
  > **username_6**: I'd say crf 20 is pretty *darn* good. 18 is functionally lossless. I do most of my videos at 23.  
  > **username_5**: Most of my work gets displayed on playback devices working locally from an SD card. I don't need to optimise much for size, so I leave the quality as high as I can. I agree, I'd dial it down if I was delivering over the web.  
  > **username_7**: This didn't help me. I still have blocky weirdness wherever motion occurs in the video. crf of 18, preset to slow. 2.7k->1080p.  
  > **username_5**: @username_7 post a question, rather than asking in the comments.  
  > **username_7**: @username_5 I'm not asking a question. I'm saying that this is not a definite answer the problem posed (or one of the same nature). That is useful to others in the same position.  
  > **username_8**: What if the quality is lower than 1080 already and we don't want to upscale it?  
  > **username_5**: @username_8 I'm not sure what you're asking. If the resolution is lower than 1080p and you don't want to upscale it then you can display it at its current resolution..?  
  > **username_8**: @username_5 I found a solution using 'min'. I was seeing performance problems with this because low quality videos were trying to upscale from users.  
  
  ---
  
  ### Answer by username_3 on 2021-09-23. Score: 19
  
  # Convert 4k to 1080 (no change in codec)
  
  ```
  ffmpeg -i input4kvid.mp4 -vf scale=1920:1080 -c:a copy output1080vid.mp4
  
  ```
  
  # Convert h.264 to h.265 (no change in resolution)
  
  ```
  ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -c:a copy output.mp4
  
  ```
  
  # Convert 4k(h.264) to 1080(h.265)
  
  * Downscaling + Change in compression codec
  
  ```
  ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -vf scale=1920:1080 -crf 20 -c:a copy output.mp4
  
  ```
  
  ## Options Explained
  
  `-i` input file name or file path
  
  `-c:v libx265 -vtag hvc1` selecting compression. Default is `libx264`
  
  `-vf scale=1920:1080` specifying output resolution
  
  `-c:a copy` copy audio as it is without any compression
  
  `-preset slow` ask compression algorithm to take more time & look for more areas for compression. Default is `medium`. Other options are `faster`, `fast`, `medium`, `slow`, `slower`
  
  `-crf 20` Compression quality
  
  > `-crf 0` high-quality, low compression, large file
  
  > `-crf 23` default
  
  > `-crf 51` low-quality, high compression, small file
  
  
  ---
  
  ### Answer by username_4 on 2018-07-23. Score: 1
  
  Use **avconv** if you want:
  
  ```
  avconv -i 4kfile.mp4 -s hd1080 -c:v libx264 -c:a copy fullhdfile.mp4
  
  ```
  
  
  ---
  
  