How to get a lossless encoding with ffmpe

-x265-params “profile=monochrome12:crf=0:lossless=1:preset=veryslow:qp=0”

profile=monochrome12

crf=0

lossless=1

preset=veryslow

qp=0

ffmpeg - 4K HDR HEVC X265

ffmpeg -y -i “massive_4k_input_file.mkv” -t 00:10:00 -analyzeduration 100M -probesize 100M -max_muxing_queue_size 9999 -map 0:v:0 -map 0:a:1 -pix_fmt yuv420p10le -vcodec libx265 -preset medium -x265-params “keyint=60:bframes=3:vbv-bufsize=75000:vbv-maxrate=75000:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=’G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)'” -acodec ac3 -ab 384k -ac 6 -map_metadata -1 -metadata title=”Movie Name (2018)” -metadata:s:a:0 language=eng -map_chapters -1 -sn “Movie Name (2018) 4K ffmpeg.mkv”

-analyzeduration 100M

-probesize 100M

-max_muxing_queue_size 9999

-map 0:v:0 -map 0:a:1

-pix_fmt yuv420p10le

-vcodec libx265

-preset medium

-x265-params “keyint=60:bframes=3:vbv-bufsize=75000:vbv-maxrate=75000:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=’G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)'”

-acodec ac3 -ab 384k -ac 6

Encoding settings for HDR 4K videos using 10-bit x265

ffmpeg -y -ss 07:48 -t 60 -i my_movie.mkv-vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:v libx265 -preset ultrafast -x265-params lossless=1 -an -sn -dn -reset_timestamps 1 movie_non_hdr.mkv

 

-preset ultrafast

-x265-params lossless=1 -an -sn -dn -reset_timestamps 1

-c:v libx265

-vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p

No quality loss

-c:v libx265 -preset ultrafast -x265-params lossless=1

 

-c:v libx265

-preset ultrafast

-x265-params lossless=1

 

 

-pix_fmt yuv420p10le -c:v libx265 -crf 28 -x265-params profile=main10

 

-pix_fmt yuv420p10le

-c:v libx265

-crf 28

-x265-params profile=main10

FFmpeg Colorspace Options

Normal option, -colorspace bt709
Number, -colorspace 1
Codec Params -x264-params “colorspace=bt709”
Filter -vf “colorspace=bt709”

 

Pixel format is gbrp10le (-pix_fmt)
Range is tv/limited (-color_range)
The YUV <-> RGB color matrix is bt2020nc (-colorspace)
The primaries are bt2020 (-color_primaries)
The EOTF/tone curve is arib-std-b67 (HLg) (-color_trc)

SAO

-m slower -q 18 -x –no-sao –aq-mode 3 for 720p transcodes
-m medium -q 20 -x –no-sao –aq-mode 3 for 1080p
-m medium -q 22 -x –no-sao for 2160p

-v – Verbose Output
-m medium – Medium encode speed (smaller higher quality, anything slower I find is not worth the time/quality dif)
-q 20 – the CRF used, 20 is similar to 18 or so in x264 but hey. This is for 1080p content (90% of my TV) I tend to use 22 for my 4K movies
-x – Use x265 central defined commands
–no-sao turns off Sample Adaptive Offset (improves speed of encode)
–aq-mode 3 – use Adaptive Quantisation with auto variance, helps 8bit encodes, especially in dark areas, stops most of the banding that can happen (at expense of encode time though)
–delete – replace encoding file with encoded file (test before using this one)
–stats – Write stats out to a csv file in the root of the path you ran from.

h265ize -v -m medium -q 20 -x –no-sao –aq-mode 3 –delete –stats

No Quality loss

-i “INPUT.mkv”: Specify the input file;
-attach “COVER.jpg”: Attach a cover art (thumbnail picture, poster, whatever) to the output. The cover art is usually shown in file explorers;
-map_metadata 0: Copy over any and all metadata from input 0, which in the example is just the input;
-map_chapters 0: Copy over chapter info (if present) from input 0;
-metadata title=”TITLE”: Set the title of the video;
-map 0:0 …: Map stream 0 of input 0, which means we want the first stream from the input to be written to the output. Since this stream is a video stream, it is the first video stream in the output, hence the stream specifier :s:v:0. Set its language tag to English;
-map 0:1 …: Similar to line 8, map the second stream (DTS audio), and set its language and title (for easier identification when choosing from players);
-map 0:2 …: Similar to line 9, except this stream is a subtitle;
-metadata:s:t:0 …: Set metadata for the cover art. This is required for mkv container format;
-c:v libx265 …: Video codec options. It’s so long that I’ve broken it into two lines. This setting is good for high quality bluray video (1080p) with minimal banding in gradient (which x265 sucks at). It is most likely an overkill for DVDs and TV shows and phone videos. This setting is mostly stolen from this Doom9 post;
crf=22:…: Continuation of video codec parameters. See the forum post mentioned above;
-c:a copy: Copy over audio;
-c:s copy: Copy over subtitles;
-t 120: Stop writing to the output after 120 seconds, which gives us a 2-minute clip for previewing trancoding quality;
“OUTPUT.HEVC.DTS.Sample.mkv”: Output file name. I tag my file names with the video codec and the primary audio codec.

 

 

ffmpeg -i *mkv -c:audio copy -c:v libx265 -preset veryslow -x265-params crf=18:no-sao=1:tune=grain
-preset veryslow -x265-params crf=18:no-sao=1:tune=grain

FFMPEG x265 10bit and virtualdub x265 10bit settings

-c:v libx265 -preset medium -an -pix_fmt yuv420p -x265-params crf=18 -c:a aac -strict experimental -b:a 160k

 

ffmpeg -y -i in_file.mov -loglevel warning -codec:v libx264 -preset veryfast -b:v 10000k -minrate 8000k -maxrate 10000k -bufsize 4800k -threads 0 -movflags +faststart -s 1920×1080 -pix_fmt yuv420p -codec:a aac out_file.mov

 

 

1080p, 15mbps, SDR 8-bit color, HEVC/x265; 7.1 channel audio with 800kbps

ffmpeg -i input.BLURAY.SOURCE.mkv -metadata title=”The Movie Name” -metadata year=”2020″ -c:v libx265 -b:v 15M -pix_fmt yuv420p -preset slow -acodec aac -b:a 800k -ac 8 -c:s copy -movflags +faststart -f matroska -y output.2020.BLURAY.RIP.1080p.x265.AAC.mkv

2160p, 70mbps, HDR 10-bit color, HEVC/x265; 7.1 channel audio with 800kbps

ffmpeg -i input.BLURAY.UHD.4K.SOURCE.mkv -metadata title=”The Movie Name” -metadata year=”2020″ -c:v libx265 -b:v 70M -pix_fmt yuv420p10le -preset slow -acodec aac -b:a 800k -ac 8 -c:s copy -movflags +faststart -f matroska -y output.2020.BLURAY.UHD.RIP.2160p.4K.x265.AAC.mkv

metadata

-metadata title=”” – set the file title

-metadata:s:v:0 title=”” – set the first video stream title

-metadata:s:a:0 title=”” – set the first audio stream title

-metadata:s:a:0 language=eng – set the first audio stream language flag to english

-c:s copy selects the codec for subtitle streams (in this case it just copies them untouched) — yes,

70 Mbit/s for UHD Blu-rays is absolute overkill, it’s most likely higher than their original bitrate. My “The Matrix”-UHD-Blu-ray has a bitrate of 49 Mbit/s. I’d probably go with 20–30 Mbit/s.

Concerning the regular Blu-rays, again, 15 Mbit/s is probably rather high, I typically encode them at 4–12 Mbit/s. I’d also recommend converting them to 10-bit video using -pix_fmt yuv420p10le and using AQ-mode 3 with -x265-params aq-mode=3 to prevent banding.

Copy code

-c:a copy

Info

ffmpeg -y -i “%%v” -s 848×480 -y -tune animation -crf 18 -pix_fmt yuv420p10le -strict experimental -preset ultrafast -metadata title=”%%~nv-[480p 265x AAC 96k].mkv” -metadata:s:v encoder=’AnimeTv4u’ -vcodec copy -c:a copy -map 0 -acodec aac -ab 96k -ac 2 -ar 48000 -vcodec libx265 “%%~nv\%%~nv-[480p 265x AAC 96k].mkv”

-s 848×480
-y
-crf 18
-tune animation
-pix_fmt yuv420p10le
-strict experimental
-preset ultrafast
-metadata title=”%%~nv-[480p 265x AAC 96k].mkv”
-metadata:s:v encoder=’AnimeTv4u’
-vcodec copy -c:a copy -map 0
-acodec aac -ab 96k -ac 2 -ar 48000
-vcodec libx265

 

-crf 28 -pix_fmt yuv420p12le \
-c:a aac -b:a 128k \
output_12bit.mp4
-crf 28 -pix_fmt yuv420p10le \
-c:a aac -b:a 128k \
output_10bit.mp4
-crf 28 -pix_fmt yuv420p \
-c:a aac -b:a 128k \
output_8bit.mp4

-pix_fmt yuv420p10le
-c:v libx265
-crf 28
-x265-params
profile=main10

c:a aac
c:v libx265
b:a 192k
profile:v main
x265-params
me=2
rd=4
subme=7
aq-mode=3
f’aq-strength=1
f’deblock=1,1
f’psy-rd=1
f’psy-rdoq=1
rdoq-level=2
merange=57
bframes=8
b-adapt=2
limit-sao=1
frame-threads=3
no-info=1
crf 24.2
preset slow
pix_fmt yuv420p

• film – use for high quality movie content; lowers deblocking
• animation – good for cartoons; uses higher deblocking and more reference frames
• grain – preserves the grain structure in old, grainy film material
• stillimage – good for slideshow-like content
• fastdecode – allows faster decoding by disabling certain filters
• zerolatency – good for fast encoding and low-latency streaming
• psnr – ignore this as it is only used for codec development
• ssim – ignore this as it is only used for codec development