Visually lossless 1080p to 720p using ffmpeg
6,574
The ultrafast
preset option for x264 will make it go as fast as it can:
ffmpeg -i INPUT -c:a copy -c:v libx264 -crf 10 -preset ultrafast -s 1280x720 -pix_fmt yuv420p -map 0 OUTPUT
-c:a copy
will copy audio tracks instead of re-encoding-c:v libx264
– use libx264 encoder for video tracks-crf 10
value is low enough to look good (even with ultrafast preset), but will produce quite a large file. Changing this up to-crf 18
can result in a file size 2-5x smaller – but depending on content/viewing conditions may not be considered "visually lossless" (a subjective requirement – try different crf values with small samples beforehand by adding e.g.-ss 23:00 -to 23:10
before the input)-s 1280x720
resizes the output to 1280x720-map 0
will map ALL the streams from the first input into the output file, or use-map 0:v -map 0:a? -map 0:s?
to map all video tracks, and all audio/subtitle tracks, if they exist- If container format used for
OUTPUT
ismov
ormp4
, the option-c:s mov_text
will encode text-based subtitles
Related videos on Youtube
Author by
user227495
Updated on September 18, 2022Comments
-
user227495 over 1 year
I have an
mkv
video file which is 1080pVideo: hevc (Main 10), yuv420p10le(tv), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
Can someone help me convert it to visually lossless 720p without taking much time. I am ok with whatever file size it comes up. It is a 43 minute video file and is around 800 MB now.
The reason I am doing is 1080p stutter in my old laptop HD screen. When I tried Handbrake, it says ETA is 12 hours. I would prefer FFMPEG this time.
I saw a few other commands, but not sure whether it will work with my video file and FPS. Please do share the proper FFMPEG command for this purpose. Thanks.
-
Mike Scott about 4 yearsThere’s no such thing as visually lossless downscaling.
-
user227495 about 4 yearsI was trying to say as good as possible. Thanks.
-
Keltari about 4 yearsHandbrake uses FFMPEG for its encoding. You might not get much improvement in speed. However, maybe with the right options, you could.
-
user227495 about 4 yearsIt would be great if you can help with that.
-
Daniel B about 4 yearsIf your notebook is incapable of 1080p HEVC playback, it most certainly isn’t fast at encoding it either. You do not mention the settings you tried in Handbrake.
-
user227495 about 4 yearsI used
fast
andvery fast
for 720p, 30 fps. Everything else was default. I chose Matroska instead of mpv4. -
Admin about 4 yearsWill produce large files and take a while on a weak cpu:
ffmpeg -i INPUT -c copy -c:v libx264 -crf 10 -preset ultrafast -s 1280x720 -pix_fmt yuv420p OUTPUT.mkv
, or leave it @ 1920x1080:-crf 7 -preset ultrafast -pix_fmt yuv420p
(will be ~2.5-3x larger than 1280x720). If input file is HDR tonemapping may be wanted. Leave the framerate as it is. -
user227495 about 4 yearsIf we use h265 or v9, will it make any difference ? I heard it gives better results. Just curious. Thanks.
-
user227495 about 4 years@guest the first command worked like a charm. Picture and audio quality is good for an HD screen. 800 MB is now around 6.5 GB now, but that is fine. It took only 1 hour 15 minutes. The only regret is that there was subtitle available with the original video. It got lost in this one. If you can post this as an answer and (optionally) a method to keep the subtitle, I can accept it as an answer. Thanks.
-
Admin about 4 years@user227495 Sorry I forgot about possibility of subs. It would be possible to remux the subtitles back (without re-doing the x264 encode):
ffmpeg -i NEWFILE -i ORIGINALFILE -c copy -map 0 -map 1:s OUTPUT
– if output is tomp4
ormov
container, add-c:s mov_text
before the output file
-
-
user227495 about 4 yearsI got this error -- Stream mapping: Stream #0:2 -> #0:0 (hdmv_pgs_subtitle (pgssub) -> ass (ssa)) Press [q] to stop, [?] for help [ssa @ 0x55fe090e0380] Only SUBTITLE_ASS type supported. Subtitle encoding failed Conversion failed!
-
user227495 about 4 yearsUsed this command ---
ffmpeg -i INPUT.mkv -c:a copy -c:v libx264 -crf 10 -preset ultrafast -s 1280x720 -pix_fmt yuv420p -map 0:s OUTPUT.mkv
-
Admin about 4 yearsSorry, I don't know much about subs – try replacing
-map 0:s
with-c:s dvdsub -map 0:v -map 0:a -map 0:s
-
user227495 about 4 yearsThanks. Any idea how to use mkvToolNix ?
-
user227495 about 4 yearsRead that it is easy to extract subtitles through it. I don't mind adding subtitle file separately.
-
Admin about 4 yearsLooks like that would be
mkvextract INPUT.mkv tracks 2:OUTPUT.sup
. The manual says:PGS subtitles will be written as SUP files.
-
user227495 about 4 yearsNo need to use ffmpeg in the beginning ?
-
user227495 about 4 yearsIt works. You are awesome. It works even if we use SRT instead of .sup.
-
Elisa Cha Cha about 4 yearsYou can likely use
-crf 18
and have a ~60% smaller file compared to-crf 10
.