lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
555 stars 26 forks source link

The --Preset Options #83

Closed TehMaster closed 3 years ago

TehMaster commented 3 years ago

Hey @donmelton,

I figured I'd ask what seems like a silly question.. Is there any reason to not always use --preset p1 when transcoding now?

Thanks!

lisamelton commented 3 years ago

@TehMaster While using --preset p1 will get you the best performance with Nvenc, that's not a huge improvement from the default preset for HEVC output. However, it can be significantly faster for AVC/H.264 output. But I'm not sure it's worth risking lower quality to get that much speed. So I recommend trying some test transcodes yourself and see what you think.

Just so you know, I'm using the default preset, i.e. no preset at all. And I add the following options:

--nvenc-spatial-aq --nvenc-lookahead 32

These two options will help mitigate color banding and blockiness at scene transitions.

As always, your mileage may vary.

TehMaster commented 3 years ago

Thanks @donmelton. Quality always outweighs speed in my mind, so I'll stick with the default and add your line above. I did a few Animated episodes (South Park) with the --preset p1, but its hard to tell any difference with my eyes. I suppose animated content might not be the best test of quality.

As always appreciate the knowledge.

vasuvasu commented 3 years ago

@donmelton I just upgraded to latest other-transcode, ffmpeg, and Nvidia drivers, and when I try to specify a preset I get the following error

Unable to parse option value "p7"

Here's the command I'm trying to run...

PS D:\output> .\batch.rb --hevc --nvenc --preset p7 --mp4 --target 1080p=5000 --all-eac3 --add-subtitle eng --crop auto Verifying "ffprobe" availability... Verifying "ffmpeg" availability... Verifying "mkvpropedit" availability... Finding encoders... Scanning media... Detecting crop... crop = 1920:808:0:0 duration = 00:33:02.72 Stream mapping: 0 = hevc_nvenc / 5000 Kbps / p7 1 = copy 2 = subrip / English 3 = subrip / English [SDH] Command line: ffmpeg -loglevel error -stats -i C:\media\series\movie.mkv -map 0:0 -c:v hevc_nvenc -pix_fmt:v p010le -b:v 5000k -maxrate:v 15000k -preset:v p7 -rc:v vbr -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title= -disposition:v default -tag:v hvc1 -map 0:1 -c:a:0 copy -metadata:s:a:0 title= -disposition:a:0 default -map 0:2 -c:s:0 mov_text -disposition:s:0 0 -map 0:3 -c:s:1 mov_text -disposition:s:1 0 -metadata:g title= -movflags disable_chpl movie.mp4 Transcoding... [hevc_nvenc @ 00000246a4ce80c0] [Eval @ 00000067b87fde10] Undefined constant or missing '(' in 'p7' [hevc_nvenc @ 00000246a4ce80c0] Unable to parse option value "p7" [hevc_nvenc @ 00000246a4ce80c0] Error setting option preset to value p7. Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height C:/Ruby26-x64/bin/other-transcode: transcoding failed: movie.mp4

If I leave the preset out and just let it use the default, it runs fine, but I'd like to try fiddling with presets.

Here's the ffmpeg version I'm using

ffmpeg -version ffmpeg version 4.3.1-2020-11-19-full_build-www.gyan.dev Copyright (c) 2000-2020 the FFmpeg developers built with gcc 10.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100

I also seem unable to use the --nvenc-multipass option. I tried rolling back to 4.3.1-2020-10-01 as mentioned in https://github.com/donmelton/other_video_transcoding/issues/80#issuecomment-718034240 but that didn't help either

lisamelton commented 3 years ago

@vasuvasu I'm sorry you're having this problem. However, it looks like you're using version 4.3.1 of ffmpeg which does not support the p7 preset nor the -multipass option. You need to install a "git" build from the gyan.dev website and not a "release" build to use the new features. Try downloading from this link:

https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z

vasuvasu commented 3 years ago

@donmelton thanks that did it! I missed that these features were in the "git" releases and not the "release" releases.

Even at --preset p7 I'm getting 200fps which is outstanding, and even 110fps with --nvenc-multipass fullres

vasuvasu commented 3 years ago

Just so you know, I'm using the default preset, i.e. no preset at all. And I add the following options:

--nvenc-spatial-aq --nvenc-lookahead 32

These two options will help mitigate color banding and blockiness at scene transitions.

@donmelton in past comments, and in the Wiki, using --nvenc-temporal-aq was a suggested as a means to eek out a smidge more quality (though maybe not perceptible). Do you prefer nvenc-spatial-aq these days? I assume --nvenc-lookahead 32 is a higher value than default? Anything else interesting that can be tweaked / bumped up to increase quality even if it hurts performance? I often watch things on my laptop and the screen is like 1ft away from my eyes, so sometimes I notice things that I wouldn't on a TV that's 10 feet away. I also looooove a placebo 🥳

lisamelton commented 3 years ago

@vasuvasu Sorry I took so long to respond. I suck. Anyway...

I no longer recommend --nvenc-temporal-aq since it may have side effects. However, --nvenc-spatial-aq can reduce color banding in AVC/H.264 output and is likely to have benefits with HEVC output. Which is why I always use it.

Yes, the --nvenc-lookahead 32 option and argument is higher than the default because the default is effectively 0. A value of 32 is the maximum and it can have real benefits in preventing blockiness at scene transitions.

Another way to (somewhat) improve quality is to use --preset p5 or --preset p6. However these significantly reduce performance, especially the latter. I just always use the default preset and I always watch a foot away from my 27-inch HDR screen. Cheers. :)

lisamelton commented 3 years ago

Closing this now as I think all the questions have been addressed.