Page 1 of 1
Scale with a BITC Custom FFMPEG
Posted: Fri Sep 23, 2022 11:30 pm
by oneskinnydave
I'm a little stuck on how to properly scale a quicktime - I'm just about nailed the custom FFMPEG script here:
Code: Select all
-vf drawtext="fontsize=15:fontfile=%s_ffastrans_dir%\DejaVuSans.ttf:\
timecode='%i_stc_hh%\:%i_stc_mm%\:%i_stc_ss%\:%i_stc_ff%':rate=%f_frame_rate%:text='TCR\:':fontsize=72:fontcolor='white':\
boxcolor=0x000000AA:box=1:x=(w-text_w)/2:y=h-th-10" -b:v 1500k -b:a 128k -c:v h264_nvenc
This gives me an awesome file - but I'd love to scale the video size down by 1/3 - I can do this with a few different ways:
-vf "scale=iw/3:ih/3" - has worked fine when I do not have drawtext
-s %i_width%:%i_height% also works at the end of my script - but I cannot adjust it by the "/3" or even a minimum width/height for some reason. I'd love to be able to do that if possible!
I've done the built-in AviSynth/Frame resize/Timecode - but nvenc is so much faster on our sytems (4-5x vs 13-14x!) so I'd love to keep it that fast if at all possible.
Also - not totally sure I'm getting the proper font for BITC - it does jump around quite a bit with the letters - I can't seem to find it when I search on the forums but does anyone have any tips/tricks to having clean BITC?!?
Thanks - this software is a literal life saver!
Re: Scale with a BITC Custom FFMPEG
Posted: Sat Sep 24, 2022 9:43 pm
by FranceBB
oneskinnydave wrote: ↑Fri Sep 23, 2022 11:30 pm
-vf "scale=iw/3:ih/3" - has worked fine when I do not have drawtext
If it works when you don't have drawtext, just pipe the output of the first command line to a new FFMpeg which encodes the way you want.
I mean this:
Code: Select all
ffmpeg.exe -i "input.mxf" -vf drawtext="fontsize=15:fontfile=%s_ffastrans_dir%\DejaVuSans.ttf:\
timecode='%i_stc_hh%\:%i_stc_mm%\:%i_stc_ss%\:%i_stc_ff%':rate=%f_frame_rate%:text='TCR\:':fontsize=72:fontcolor='white':\
boxcolor=0x000000AA:box=1:x=(w-text_w)/2:y=h-th-10" -strict -1 -f yuv4mpegpipe - | ffmpeg.exe -i - -vf "scale=iw/3:ih/3" -b:v 1500k -b:a 128k -c:v h264_nvenc -y "output.mkv"
By the way, I would personally specify the resizing kernel too, otherwise it's gonna default to Bilinear and it shouldn't really be used for anything in 2022!
Code: Select all
-vf "scale=iw/3:ih/3:flags=lanczos"
Lanczos is probably gonna be "good enough" for your use case.
If we were in Avisynth I would have used SinPowResizeMT(), which is Sin squared kernel for resize, but sadly there isn't such a thing in FFMpeg...
In a nutshell, your final Command Line to be executed in the Command Executor node in FFAStrans is:
Code: Select all
%comspec% /C ""%s_ffmpegx64%" -i "input.mxf" -vf drawtext="fontsize=15:fontfile=%s_ffastrans_dir%\DejaVuSans.ttf:\
timecode='%i_stc_hh%\:%i_stc_mm%\:%i_stc_ss%\:%i_stc_ff%':rate=%f_frame_rate%:text='TCR\:':fontsize=72:fontcolor='white':\
boxcolor=0x000000AA:box=1:x=(w-text_w)/2:y=h-th-10" -strict -1 -f yuv4mpegpipe - | "%s_ffmpegx64%" -i - -vf "scale=iw/3:ih/3:flags=lanczos" -b:v 1500k -b:a 128k -c:v h264_nvenc -y "output.mkv""
Cheers,
Frank
Re: Scale with a BITC Custom FFMPEG
Posted: Sun Sep 25, 2022 9:15 am
by admin
Hi oneskinnydave, thank you for using FFAStrans and welcome to the forum!
If I understand you correctly you want scale your current
output (with BITC) by a factor of 3. So in a nutshell all your sizes, both video and font size has to be scaled by the same factor. So I think this filter chain will do the trick:
scale=iw/3:ih/3,drawtext="fontsize=15/3:fontfile=%s_ffastrans_dir%\DejaVuSans.ttf:timecode='%i_stc_hh%\:%i_stc_mm%\:%i_stc_ss%\:%i_stc_ff%':rate=%f_frame_rate%:text='TCR\:':fontsize=72/3:fontcolor='white':boxcolor=0x000000AA:box=1:x=(w-text_w)/2:y=h-th-10"
So simply apply /3 to both input size and font size and you should be good to go.
And don't worry about the scaling kernel. Default in ffmpeg is "bicubic" so it's basically ok for preview files.
-steinar
Re: Scale with a BITC Custom FFMPEG
Posted: Sun Sep 25, 2022 1:10 pm
by oneskinnydave
This is amazing - thank you all!
@stienar - your solution actually yielded great results - and actually sped up the process - I'm hovering around 30x speed increases!!! I should have stated these are just for producers to screen, so quality is not of importance, honestly just how fast I can make then is all that matters! Nvenc has reduced CPU usage greatly and like I said I'm around 600-700fps!!!
Thank you so much for your help!
Re: Scale with a BITC Custom FFMPEG
Posted: Mon Sep 26, 2022 11:31 am
by emcodem
Depending on your input files you could potentially speed up even more by getting rid of one of the 2 fields. Also, i believe i always got slightly faster using libx264 instead of nvenc on Core i cpu's but of course only when processing a single file, not in paralell. Anyway 30-35x are beyond the results that i got too for h264 HD encoding (without subtitle), so your results are good already. The only way to get a lot faster from here is to split off encoding into the single GOP's and encode on multiple machines/jobs in paralell.
Re: Scale with a BITC Custom FFMPEG
Posted: Tue Sep 27, 2022 12:06 pm
by oneskinnydave
Yes - I totally forgot about deinterlacing! Good idea. I tested both encoding formats, but I’d like to put less stress on my CPU because it really bogs the system down and makes it in operable.
I am currently working on farming out on our network, The main issue is all of our systems connect to our NAS server on different subnets so it may get a little wacky with UNC naming. It’s working great so far, thanks so much for all your ideas and help!!
Re: Scale with a BITC Custom FFMPEG
Posted: Tue Sep 27, 2022 1:06 pm
by emcodem
Here is how we did benchmark encoding for interlaced sources, trying to avoid any unneccessary filtering (e.g. unwanted deinterlacing). It's perfect for generating quick previews of interlaced sources. What an unfortune that you need to insert subtitles
Code: Select all
"%s_ffmpeg%" -i "%s_source%" -pix_fmt yuv420p -c:v h264_nvenc -vf field=top,setdar=16/9 "%s_outputfile%"