U
U
usersay2021-02-01 20:13:00
Video
usersay, 2021-02-01 20:13:00

How to do two-pass encoding in HEVC with ffmpeg?

Good evening!
Introductory: I have a lot of Blu-ray discs with my favorite films on hand. Removed the protection (for personal use), there is a full copy on the HDD with the preservation of the structure. The task is to convert movies to 720p, m4v container, with hevc codec. Before that I used only HandBrake. For H264, I am completely satisfied with HB, but it does not work with HEVC. I have settings for h264 HB tailored to a specific movie (back to the future):

Settings for HandBrake
"D:\HandBrake 1.3.3\HandBrakeCLI.exe" -i "D:\Back to the Future 1985\BDMV\STREAM\0029.m2ts" -t 1 -o "D:\BackToTheFuture.m4v" -f mp4 -O -w 1280 -l 692 --crop 42:42:0:0 --modulus 4 -e x264 -r 23.976 -b 6000 -2 -a none -x cabac=0:ref=3:me=umh:b-pyramid=none:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500:subq=9:merange=32:deblock=-2,-2:qcomp=0.80:qpmin=0:qpmax=69:fast_pskip=0:aq-strength=0.8:no-dct-decimate=1:psy-rd=1.00,0.25

After reading about ffmpeg commands, I realized that I needed something like this:
Settings for ffmpeg
"D:\ffmpeg-N-100898-gd16b0a4bf0-win64-gpl-vulkan\bin\ffmpeg.exe" -i "D:\Back to the Future 1985\BDMV\STREAM\00294.m2ts" -map 0:0 -c:v libx265 -f mp4 -vf crop=42:42 -s 1280x692 -r 23.976 -b:v 4500 -passlogfile "D:\x265_2pass.log" -x265-params pass=2:cabac=0:ref=3:me=umh:b-pyramid=none:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500:subq=9:merange=32:deblock=-2,-2:qcomp=0.80:qpmin=0:qpmax=69:fast_pskip=0:aq-strength=0.8:no-dct-decimate=1:psy-rd=1.00,0.25 -an -sn "D:\BackToTheFutureHEVC.m4v"

Throws errors, At least one output file must be specified, for example. Audio and subtitles do not need to be transferred.
I will attach the clean settings from which you need to proceed:
Clean settings for ffmpeg
"D:\ffmpeg-N-100898-gd16b0a4bf0-win64-gpl-vulkan\bin\ffmpeg.exe" -i "D:\Back to the Future 1985\BDMV\STREAM\00294.m2ts" -map 0:0 -c:v libx265 -f mp4 -vf crop=42:42 -s 1280x692 -r 23.976 -b:v 4500 -x265-params cabac=0:ref=3:me=umh:b-pyramid=none:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500:subq=9:merange=32:deblock=-2,-2:qcomp=0.80:qpmin=0:qpmax=69:fast_pskip=0:aq-strength=0.8:no-dct-decimate=1:psy-rd=1.00,0.25 -an -sn "D:\BackToTheFutureEXPhevc.m4v"

In general, for hb the settings are 100% working and correct. If I incorrectly transferred some settings to ffmpeg (which is possible), please write. And what about two passes? Settings like psy-rd, crop, resolution, framerate, etc. cannot be changed.
* Tips like "find, download ready", "buy", "for 720p hevc is not needed!" are not accepted
** I can compile to mkv via eac3to, but here everything is in one file. Even more. Two video roads, map 0:0 is needed for road selection

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question