ffmpeg -loglevel warning -hide_banner -stats -y -vsync passthrough -init_hw_device opencl=gpu:0.0 -filter_hw_device gpu -hwaccel cuda -i [INPUT FILE] -vf "hwupload_cuda,scale_cuda=1920:1080,hwdownload,format=p010,hwupload,tonemap_opencl=t=bt709:p=bt709:m=bt709:tonemap=mobius:format=nv12,hwdownload,format=nv12" -codec:v h264_nvenc -preset 18 -profile high -level 41 -rc 1 -cq 18 -rc-lookahead 4 -codec:a copy -codec:s copy -max_muxing_queue_size 9999 [OUTPUT FILE]
-loglevel warning
- only print warning messages and suppress more detailed information-hide_banner
- do not print the ffmpeg banner which shows copyright information and configuration options-stats
- prints encoding progress and stats-y
- automatically overwrite the output file if it already exists-vsync passthrough
- passthrough all frames without dropping or duplicating any frames-init_hw_device opencl=gpu:0.0 -filter_hw_device gpu
- sets the hardware filter device to be the GPU, allows for HW-accelerated OpenCL filters-hwaccel cuda
- use CUDA to accelerate video decoding-vf
- video filtershwupload_cuda
- upload data to GPU memory for use with CUDA filtersscale_cuda
- scale the video, accelerated with CUDAhwdownload
- download data from GPU memory (VRAM) back to CPU memory (system RAM)format=p010
- set the pixel format,p010
refers to 10-bithwupload
- upload the data to GPU memory, this time for use with OpenCLtonemap_opencl
- OpenCL filter to tonemap HDR into SDR, documentation heret=bt709
- colorspace of transfer,bt709
is the SDR colorspacep
andm
are also setting colors tobt709
SDR
tonemap=mobius
- tonemapping algorithm to use.mobius
claims to retain color accuracy while sacrificing highlight detail- see here for documentation of other tonemapping algorithms
format=nv12
- set the output pixel format of the tonemapping filter,nv12
refers to 8-bit
hwdownload
- download data from GPU memory (VRAM) back to CPU memory (system RAM)format=nv12
- set the output pixel format,nv12
refers to 8-bit
codec:v h264_nvenc
- use NVIDIA's H264 hardware encoder to encode the video stream. Useffmpeg -h encoder=h264_nvenc
to see full documentation of options-preset 18
- slowest (best quality) encoding preset-profile high -level 41
- sets the format profile to[email protected]
, see here for more information about profiles in H264/AVC-rc 1
- set the rate control to variable bitrate modecq 18
- set the target quality level for constant quality encoding (similar tocrf
inx264
)rc-lookahead 4
- number of frames to lookahead for rate-control
codec:a copy
- copy all audio tracks untouchedcoded:s copy
- copy all subtitle tracks untouchedmax_muxing_queue_size 9999
- the number of frames that can be queued at once
- Figure out a way to scale using OpenCL or other method that doesn't require uploading and downloading to VRAM twice
- Check for and remove settings that are at default values
- Compare/contrast various parameters with regards to file size, video quality, and encoding time
- Compare/contrast using hardware acceleration vs software based encoding and tonemapping with regards to file size, video quality, and encoding time