-
-
Save lextra2/f40641bdb3385ec7a986eed74f45c564 to your computer and use it in GitHub Desktop.
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/tree/master/amf/public/include/components | |
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_Encode_HEVC_API.md | |
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/master/amf/doc/AMF_Video_PreAnalysis_API.md | |
OBS | |
https://github.com/obsproject/obs-studio/blob/master/plugins/obs-ffmpeg/texture-amf.cpp | |
--------------------------------------------------------------------------------------------------------- | |
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/439#issuecomment-1917886326 | |
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/417#issuecomment-2040289753 | |
{ | |
"description": "VirtualDub external encoder profile collection", | |
"externalEncoders": { | |
"sets": { | |
"ProRes": { | |
"videoEncoder": "ProRes", | |
"audioEncoder": "", | |
"multiplexer": "", | |
"description": "", | |
"extension": "", | |
"processPartial": true, | |
"useOutputAsTemp": false | |
}, | |
"ProRes Q4": { | |
"videoEncoder": "ProRes Q4", | |
"audioEncoder": "", | |
"multiplexer": "", | |
"description": "", | |
"extension": "", | |
"processPartial": true, | |
"useOutputAsTemp": false | |
} | |
}, | |
"profiles": { | |
"ProRes": { | |
"name": "ProRes", | |
"program": "ffmpeg.exe", | |
"commandArguments": "-f rawvideo -pix_fmt %(pix_fmt) -s %(width)x%(height) -r %(fpsnum)/%(fpsden) -i - -c:v prores_ks -pix_fmt yuv420p10le %(tempvideofile)", | |
"outputFilename": "%(outputname).mov", | |
"type": 0, | |
"pixelFormat": "yuv444p16le", | |
"inputFormat": 0, | |
"checkReturnCode": true, | |
"logStdout": true, | |
"logStderr": true, | |
"bypassCompression": false, | |
"predeleteOutputFile": false | |
}, | |
"ProRes Q4": { | |
"name": "ProRes Q4", | |
"program": "ffmpeg.exe", | |
"commandArguments": "-f rawvideo -pix_fmt %(pix_fmt) -s %(width)x%(height) -r %(fpsnum)/%(fpsden) -i - -c:v prores_ks -q:v 4 -pix_fmt yuv420p10le %(tempvideofile)", | |
"outputFilename": "%(outputname).mov", | |
"type": 0, | |
"pixelFormat": "yuv444p16le", | |
"inputFormat": 0, | |
"checkReturnCode": true, | |
"logStdout": true, | |
"logStderr": true, | |
"bypassCompression": false, | |
"predeleteOutputFile": false | |
} | |
} | |
} | |
} |
mkvpropedit --add-track-statistics-tags INPUT.mkv
Read more
Needed to write statistics for VP9 / Opus
mkvpropedit --tags all:"" --delete title INPUT.mkv
Delete all tags and title
ffmpeg -i INPUT.flac -c:a libopus -b:a 576K OUTPUT.opus
- 2CH = 160K
- 6CH = 432K
- 8CH = 576K
NTSC
-color_primaries smpte170m -colorspace smpte170m -color_trc smpte170m -color_range tv
PAL
-color_primaries bt470bg -colorspace bt470bg -color_trc gamma28 -color_range tv
NTSC HD
-color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv
ffmpeg -y -benchmark -init_hw_device opencl=GPU -filter_hw_device GPU -i SAMPLE.mkv -map_metadata -1 -vf "format=p010,hwupload,tonemap_opencl=tonemap=hable:tonemap=hable:primaries=bt709:transfer=bt709:matrix=bt709:range=tv:format=p010,hwdownload,format=p010" -c:v prores_ks -qscale:v 4 TonemapGPU.mov
ffmpeg -y -benchmark -i SAMPLE.mkv -map_metadata -1 -vf "zscale=transfer=linear,tonemap=hable,zscale=primaries=bt709:transfer=bt709:matrix=bt709:range=tv,format=yuv420p10" -c:v prores_ks -qscale:v 4 TonemapCPU.mov
ffmpeg -y -benchmark -i 0001.mov -map_metadata -1 -c:v libx264 -x264-params "ref=4:keyint=60:scenecut=0" -profile:v high -level:v 4.2 -preset veryslow -crf 12 -vf scale=1920:-1 -pix_fmt nv12 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv -an OUTPUT.mkv
Note: Level 4.2 is limited to a maximum of 4 reference frames.
https://silentaperture.gitlab.io/mdbook-guide/encoding/x264.html
ffmpeg -y -benchmark -i INPUT.mkv -c:v prores_ks -q:v 4 -vf "dejudder, fps=30000/1001, fieldmatch=order=tff:mode=pcn_ub:combmatch=full, bwdif=mode=0:deint=interlaced, decimate" -an OUTPUT.mkv
ffmpeg -y -benchmark -i INPUT.mkv -c:v h264_amf -quality balanced -qp_i 32 -qp_p 32 -g 120 -an OUTPUT_AVC_QP32.mkv
460 FPS - 152 MB - 8452 kb/s avg, 21934 kb/s Max
ffmpeg -y -benchmark -i INPUT.mkv -c:v hevc_amf -quality balanced -qp_i 30 -qp_p 30 -g 120 -an OUTPUT_HEVC_QP30.mkv
460 FPS - 155 MB - 8612 kb/s, 26722 kb/s Max
ffmpeg -y -benchmark -i INPUT.mkv -c:v libx264 -x264-params "keyint=120:scenecut=0:nal-hrd=none:filler=0:vbv-maxrate=16000:vbv-bufsize=16000:bitrate=8000:threads=24" -profile:v high -preset medium -an x264.mkv
127 FPS - 143 MB - 7946 kb/s, 18114 kb/s Max
ffmpeg -y -benchmark -init_hw_device vulkan=GPU -hwaccel vulkan -hwaccel_output_format vulkan -extra_hw_frames 30 -i "C:\Users\Admin\Downloads\New folder\OPM.avs" -filter_hw_device GPU -vf "format=nv12,hwupload,libplacebo=w=iw/2:h=ih/2:downscaler=sinc,hwdownload,format=yuv420p" -c:v hevc_amf -qp_i 18 -qp_p 18 -g 240 -an TEST.mkv
ffmpeg -y -benchmark -init_hw_device vulkan -i "C:\Users\Admin\Downloads\New folder\OPM.avs" -vf "libplacebo=w=iw*2:h=ih*2:upscaler=sinc" -c:v libx264 -preset ultrafast -qp 0 -g 1 -an test1234.mkv
ffmpeg -y -benchmark -i INPUT.mkv -c:v libx264 -x264-params "ref=4:psy-rd=1,0.15:merange=32:threads=24:lookahead-threads=6:bframes=3:b-pyramid=none:keyint=48:scenecut=0:rc-lookahead=48:crf=19:qcomp=0.75:vbv-maxrate=5000:vbv-bufsize=10000:nal-hrd=none:filler=0:aq-strength=0.8" -preset veryslow -pix_fmt yuv420p -an H264.mkv
ffmpeg -y -benchmark -i Bleach02.avs -pix_fmt yuv422p10le -c:v prores_ks cut005_48.mkv
ffmpeg -y -benchmark -i cut03.mkv -pix_fmt yuv422p10le -c:v prores_ks -vf mpdecimate,setpts=N/24/TB -vsync vfr cut003.mkv
ffmpeg -y -f concat -i list.txt -c copy CUTS_48.mkv
ffmpeg -y -f concat -i list.txt -c:v prores_ks CUTS_TEST.mkv
ffmpeg -i cut003_48.mkv -vf fps=48000/1001 cut03\%04d.png
ffmpeg -y -r 48 -i cut03\%04d.png -c:v prores_ks -pix_fmt yuv422p10le cut03_FIXED_48.mkv
list.txt
file 'cut01_FIXED_48.mkv'
file 'cut02_FIXED_48.mkv'
file 'cut03_FIXED_48.mkv'
file 'cut04_FIXED_48.mkv'
file 'cut05_FIXED_48.mkv'
If you set TargetBitrate
before setting PeakBitrate
AMF tries to adjust peak bitrate
GPUOpen-LibrariesAndSDKs/AMF#488 (comment)
If you would like to have more control over bitrate accuracy, please consider using PEAK_CONSTRAINED_VBR
GPUOpen-LibrariesAndSDKs/AMF#489 (comment)
GPUOpen-LibrariesAndSDKs/AMF#439 (comment)
PAEngineType=
- Host/CPU (1)
- DX11 (3)
- OpenCL (4)
- Vulkan (10)
- DX12 (11)
GPUOpen-LibrariesAndSDKs/AMF#435
LTR requires MaxConsecutiveBPictures=0
https://visionular.ai/what-are-av1-golden-frames/
Golden Frames / Long Term Reference Frames
Golden frames are useful in boosting compression efficiency because not only are high quality and are long-term references, but they significantly improve the coding efficiency of the subsequent frames specially in scenes with low motion or repetitive elements, resulting in lower bit-rates without reducing video quality.
GPUOpen-LibrariesAndSDKs/AMF#500 (comment)
The main reason for adding low latency parameters is to force clocks to stay high and keep latency low.
LowLatencyInternal=true
NEVER use "Alternative Reference Frames"
ALT-REF (temporally filtered) frames
VERY blurry
Used by VP9 (2-pass) & VP10 (AV1)
https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/Parameters.md#av1-specific-options
While OBS currently overrides the rate control method to CBR for streaming
https://github.com/obsproject/obs-studio/pull/9352#discussion_r1515202908
🤡🤡🤡
...
Most AMF parameters explained:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/wiki/AMF-Encoder-Settings-and-Tuning-in-FFmpeg
AMD Display Library dithering:
https://github.com/GPUOpen-LibrariesAndSDKs/display-library/blame/29beb5a1217ab5805c5032284fdcdc56418bce36/include/adl_defines.h#L1013
MaxConsecutiveBPictures
supersedesBPicturesPattern
MaxConsecutiveBPictures=1 or greater
supersedesPALongTermReferenceEnable=true
PAPerceptualAQMode=1
supersedesEnableVBAQ=true
PATemporalAQMode=1 or 2
supersedesEnableVBAQ=true
andPAPerceptualAQMode=1
PAHighMotionQualityBoostMode=1
supersedesHighMotionQualityBoostEnable=true
x265
ctu=32
for 1920x1080no-sao=1
limit-sao=1
b-pyramid=0
aq-mode=3
mcstf=1
Motion-compensated spatio-temporal filtering. Give it a try
x264
too many lookahead threads significantly degrades lookahead accuracy
https://code.videolan.org/videolan/x264/-/blob/master/encoder/encoder.c?ref_type=heads#L1294
x264 has a complex lookahead module designed to estimate the coding cost of frames that have not yet been
analyzed by the main encoder module. It uses these estimations to make a variety of decisions, such as adaptive B-frame
placement, explicit weighted prediction, and bit allocation for buffer-constrained ratecontrol. For performance reasons, it
operates on a half-resolution version of the frame and calculates SATD residuals only, doing no quantization or
reconstruction.
It is important to note that, in x264, the regular B-frame quantizer offsets (--pbratio) are disabled
when MBtree is on, since they serve the same role.
One might assume similarly that macroblock-tree can replace keyframe quantizer offsets. However, testing
suggested this was not the case
Benchmark Software Decoder
ffmpeg -benchmark -i H264.mkv -an -f null -
Important AMD encoder settings
PASceneChangeDetectionEnable=false PALookAheadBufferDepth=41 MaxNumRefFrames=4
PASceneChangeDetectionEnable=false
(default=true) - adaptive I-frames, Scenecut, requires LookaheadAdaptiveMiniGOP=true
(default=true) - adaptive B-frames, B-adapt, requires LookaheadBReferenceEnable=true
(default=true) - Use B-frames as Reference frames
MaxNumRefFrames=4
=4 for High 4.2 Profile (1920x1080@60)
Important NVenc settings
AVC
lookaheadDepth=32 useBFramesAsRef=1
HEVC
lookaheadLevel=3 lookaheadDepth=32
Note: NV_ENC_LOOKAHEAD_LEVEL_0 has the highest performance,
while NV_ENC_LOOKAHEAD_LEVEL_3 has the highest quality. It increases bitrate significantly and should not be used.
useBFramesAsRef=
=1
Any B-frame can be a reference frame
=2
Halved - Uses the following logic:
4 B-frames = 2 reference frames
3 B-frames = 1 reference frame
2 B-frames = 1 reference frame
1 B-frame = 1 reference frame <-- untested, but should be logical to clamp to 1
Show all supported encoders in FFMPEG:
ffmpeg -encoders
Show all encoder options:
ffmpeg -h encoder=hevc_nvenc
Lossless: NVenc
ffmpeg -y -benchmark -i INPUT.mkv -c:v hevc_nvenc -tune lossless -pix_fmt p010le -an OUTPUT.mkv
Almost Lossless: Apple ProRes 422 High Quality
ffmpeg -y -benchmark -i INPUT.mkv -c:v prores_ks -q:v 0 -profile:v 3 -bits_per_mb 1024 -vendor apl0 -pix_fmt yuv422p10le 1024.mov
Note:-bits_per_mb
can go up to 8192
. Higher = less lossy.
Lossless: UT Video
ffmpeg -y -benchmark -i INPUT.mkv -c:v utvideo -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv OUTPUT.mkv
AV1 Basically lossless settings:
ffmpeg -y -benchmark -i INPUT.mkv -c:v libsvtav1 -svtav1-params "enable-tf=0:mbr=10M:tile-columns=2:tile-rows=0" -g 240 -qp 14 -preset 4 -pix_fmt yuv420p10le SVT_AV1.mkv
Libaom AV1 settings:
ffmpeg -y -benchmark -i TEST.mkv -c:v libaom-av1 -pix_fmt yuv420p10le -g 240 -cpu-used 4 -auto-alt-ref 0 -aq-mode 0 -tile-columns 2 -tile-rows 0 -row-mt 1 -crf 16 -pass 1 libaom-pass1.webm
ffmpeg -y -benchmark -i TEST.mkv -c:v libaom-av1 -pix_fmt yuv420p10le -g 240 -cpu-used 4 -auto-alt-ref 0 -aq-mode 0 -tile-columns 2 -tile-rows 0 -row-mt 1 -crf 16 -pass 2 libaom-pass2.webm
High Quality Example:
NVEncC64.exe --codec hevc --cqp 18 --preset p7 --output-depth 10 --lookahead 32 --ref 8 --split-enc forced_2 --colormatrix bt709 --colorprim bt709 --transfer bt709 --colorrange limited -i INPUT.mkv -o OUTPUT.mkv
190 FPS with 2560x1440 input from the RTX 5070 Ti
Lossless:
NVEncC64.exe --lossless --colormatrix bt709 --colorprim bt709 --transfer bt709 --colorrange limited -i INPUT.mkv -o OUTPUT_Lossless-avc.mkv
ffmpeg -y -benchmark -i TEST.mkv -c:v libx264 -x264-params "ref=8:keyint=240:bframes=3:b-adapt=2:rc-lookahead=60:aq-mode=3:me=umh:merange=24:subme=9:trellis=2:lookahead-threads=2:threads=16" -crf 14 -pix_fmt yuv420p10le AVC_14.mkv
Check encoder settings like this
ffmpeg -h encoder=libvpx-vp9
Say yes if asked
ffmpeg -y
Show encoding time in seconds
-benchmark
Write to logfile
-report
Hide ffmpeg (for piping)
-loglevel quiet
Or show warnings only
-loglevel warning