encoder_options Function

private function encoder_options(codec, quality) result(args)

ffmpeg's encoder options for codec and quality (see start_recording).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in), optional :: codec

an ffmpeg encoder (default libx264)

integer, intent(in), optional :: quality

the CRF (default 18; limited to 0 to 63)

Return Value character(len=:), allocatable


Called by

proc~~encoder_options~~CalledByGraph proc~encoder_options encoder_options proc~start_recording WindowProxy%start_recording proc~start_recording->proc~encoder_options

Source Code

    function encoder_options(codec, quality) result(args)
        character(len=*), intent(in), optional :: codec     !! an ffmpeg encoder (default libx264)
        integer, intent(in), optional :: quality            !! the CRF (default 18; limited to 0 to 63)
        character(len=:), allocatable :: args, c
        character(len=32) :: q
        c = 'libx264'
        if (present(codec)) c = trim(codec)
        write(q, '(i0)') 18
        if (present(quality)) write(q, '(i0)') max(0, min(63, quality))
        args = '-c:v '//c
        select case (c)
        case ('libx264')
            args = args//' -preset medium -crf '//trim(q)//' -pix_fmt yuv420p'
        case ('libx265')
            args = args//' -preset medium -crf '//trim(q)//' -pix_fmt yuv420p -tag:v hvc1'     ! (hvc1: QuickTime)
        case ('libvpx-vp9')
            args = args//' -crf '//trim(q)//' -b:v 0 -pix_fmt yuv420p'
        end select
    end function encoder_options