I would like to resize a 4K mkv video to 1920×1080 with ffmpeg version 3.4.6-0ubuntu0.18.04.1
on Ubuntu 18.04. The original file has the following features:
Input #0, matroska,webm
encoder : libebml v1.3.9 + libmatroska v1.5.2
Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
This version of FFmpeg
may not support x265
. I compiled a new version from the current Git repository, explicitly enabling x265
. Now, ffmpeg -hide_banner -pix_fmts
has, in its output:
FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL
-----
IO... yuv420p10le 3 15
This format should now be supported both for encoding and for decoding. I tried:
ffmpeg -i original_file.mkv -c:v libx265 -pix_fmt + -vf scale=1920:1080 -colorspace bt709 -c:a copy test_output.mkv
This produces:
Input #0, matroska,webm, from 'test_output.mkv':
Metadata:
ENCODER : Lavf58.35.100
Stream #0:0(eng): Video: hevc (Main 10), yuv420p10le(tv, bt709/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
So, it is apparently ok. However, test_output.mkv
colors still seem to be half the intensity of the original one, as if a grey layer was overlapped to the 4K video. I opened the file with both vlc
and mpv
, with no difference.
How to preserve the original colors as much as possible?
If it is possible, I would also like to lower the bitrate, but my attempt
ffmpeg -i original_file.mkv -s 1920x1080 -b 1700 output.mkv
produced a solid grey-only video with some moving squares.
I always get this message:
[matroska,webm @ 0x55a5507ad100] Could not find codec parameters for stream 1 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
FFmpeg
built from source has the following configuration:
ffmpeg version N-95768-gd831edc387 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --enable-gpl --enable-libx264 --enable-libx265
libavutil 56. 36.100 / 56. 36.100
libavcodec 58. 62.100 / 58. 62.100
libavformat 58. 35.100 / 58. 35.100
libavdevice 58. 9.101 / 58. 9.101
libavfilter 7. 66.100 / 7. 66.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100