Articles | Late-2018 Video Processing Guide

This article assumes you've read this article and all corresponding articles. In this article I won't be discussing many technical elements, and I've decided to separate it from the others primarily to preserve the information for the old pipelines they possess for the sake of cross referencing future research.

 


 

Following the Drunk Swede's extensive research following the base OBS pipeline established in mid-2018, we now have a series of batch commands that allow us to pull what is nearly the limit of what the x264 codec can give us for quality in public video media without using placebo settings and taking huge hits on encoding speed. In this article I will provide the bat files and a summary of their applications in my setup.

 

Tools -

 

OBS - Following the OBS pipeline outlined here. We're using a custom build that fixes the 444 Chroma Subsampling setting.

FFMPEG - I've removed Megui from my pipeline as it isn't necessary anymore at all.

AVISynth - Avisynth exists solely to hand ffmpeg a file from Vegas frameserver.

Foobar - I sometimes use Foobar to convert wav files into nero AAC. It isn't necessary if you prefer to use Audition.

Bat Files - The Drunk Swede has provided several bat files that allows us to automate some logistics. All of our ffmpeg and many audio related commands will be handled via bat files.

Audition 1.5, Vegas, Frameserver, MKVToolnix - Nothing new here.

 

Base Encodes

 

A base encode is the replacement of my old encodes that used the Fraps -> Megui pipeline.

 

In the initial version of the pipeline as outlined in the 2018 video article, I was manually splicing videos together. That is now unnecessary.

 

Record (OBS) -> Sort (Move to Encoding Folder)-> Encode (Bat) -> Encode Audio (Bat) -> Process Audio (Audition/Vegas/Foobar (See Below)) -> Mux (Mkvtoolnix)

 

We record with OBS, then move the files to an annointed directory, and run this bat.

 

(for %%i in ("E:\manlatcher\*.mkv") do @echo file '%%i') > "E:\drunkswede's ffmpeg\bin\concat.txt"

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS

"E:\drunkswede's ffmpeg\bin\ffmpeg64.exe" -f concat -safe 0 -i "E:\drunkswede's ffmpeg\bin\concat.txt"  -map 0:0 -c:v:0 libx264 -psy-rd 1.00:1.00 -me_method umh -x264-params crf=28:subme=9:merange=16:trellis=1:fullrange=on:colorprim=bt709:colormatrix=bt709:transfer=bt709:partitions=all:direct=temporal:rc_lookahead=60 -pix_fmt yuv444p10le -vf scale="in_range=full:in_color_matrix=bt709:out_range=full:out_color_matrix=bt709" "H:\KMesk_ff14_seg4.mkv"

pause

 

The directories to alter should be self-explanatory.

 

You may notice some commands have been altered in this command line. They follow the Drunk Swede's more recent research into psy-rd, which combats the innate blurring behavior of x264 and makes it a little more intelligent. We aren't entirely sure how it works, but some tests between this and the command initially demonstrated in the 2018 article has yielded superior sharpness and accuracy. It may benefit from more extensive testing in the future, so we may visit this subject in the future (perhaps a 2019 article).

 

This will only produce a video for us. The audio I have separated into its own bat file as I sometimes need to re-encode one or the other but very rarely both at once. I only export two audio streams out of OBS (Mic and windows), so this could be adjusted if you need more.

 

(for %%i in ("E:\manlatcher\*.mkv") do @echo file '%%i') > "E:\drunkswede's ffmpeg\bin\concat.txt"

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS


"E:\drunkswede's ffmpeg\bin\ffmpeg.exe" -f concat -safe 0 -i "E:\drunkswede's ffmpeg\bin\concat.txt" -map 0:1 -c:a:1 pcm_s24le "H:\merged_obs_folder_files-stream1.wav"
"E:\drunkswede's ffmpeg\bin\ffmpeg.exe" -f concat -safe 0 -i "E:\drunkswede's ffmpeg\bin\concat.txt" -map 0:2 -c:a:2 pcm_s24le "H:\merged_obs_folder_files-stream2.wav"

pause

 

Concat allows us to automate the otherwise painful logistics of merging a large number of recordings. We've replaced the process of generating avisynth scripts for directories of fraps files with simply using these bat files, basically.

 

The big issue with audio is that we need to merge the two streams after we process them, and Audition 1.5 can't handle exporting audio over 3 hours in length in multitrack, and Vegas can't handle AAC in any reasonable timeframe if at all. We can encode to wav in both cases, but we still need a final file for the MKV. This can be accomplished with Nero AAC in Foobar or directly. Be extremely careful with this step if you deviate - many AAC encoders can produce wonky VBR files. Only use Nero. I stick to 400-500 CBR generally.

 

Thus audio for files exceeding 3 hours on non-Vegas sourced encodes still end up using vegas.

 

Encode Audio (bat file) -> Process in Audition -> Re-Save wav files -> merge in Vegas -> Export to wav -> Convert to AAC with neroaacenc.exe (through foobar or bat file) -> mux (mkvtoolnix)

 

It's dumb and convoluted but that's what we're forced to do atm.

 

Vegas Encodes

 

As opposed to concat, Vegas encodes still require Avisynth because ffmpeg isn't able to hook the signpost file directly and I had a lot of issues with it. Our Avisynth file is just the one line pointing to that file.

 

AVISource("H:\SKYRIMJOB.avi")

 

The vegas file is similar to our other one except it exchanges concat for the avisynth source.

 

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS

"E:\drunkswede's ffmpeg\bin\ffmpeg.exe" -i "c:\anonh.avs" -map 0:0 -c:v:0 libx264 -psy-rd 1.00:1.00 -me_method umh -x264-params

crf=28:subme=9:merange=16:trellis=1:fullrange=on:colorprim=bt709:colormatrix=bt709:transfer=bt709:partitions=all:direct=temporal:rc_lookahead=60 -pix_fmt yuv444p10le -vf

scale="in_range=full:in_color_matrix=bt709:out_range=full:out_color_matrix=bt709" "H:\KMesk_AJ-s1.mkv"


pause

 

You may notice we don't use the 64bit version of ffmpeg for this process. This is because the 64bit version of ffmpeg, at least in this specific build that I'm using, has demonstrated instability or incompatibility in very specific circumstances. It also seems to refuse to work with both the 32 and 64bit versions of avisynth. Should your build behave differently you can try interchanging them.

 

Spline64 Rescaling

 

The spline64 rescaling researched a year ago was ported to ffmpeg to be used in Skyrim and similar recordings. Here's the bat I used for Skyrim segment 1 (that accidentally got passed to some D&D videos).

 

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS

"E:\drunkswede's ffmpeg\bin\ffmpeg.exe" -i "c:\anonh.avs" -map 0:0 -c:v:0 libx264 -psy-rd 1.00:1.00 -me_method umh -x264-params crf=26:subme=9:merange=16:trellis=1:fullrange=on:colorprim=bt709:colormatrix=bt709:transfer=bt709:partitions=all:direct=temporal:rc_lookahead=60 -pix_fmt yuv444p10le -vf scale="in_range=full:in_color_matrix=bt709:out_range=full:out_color_matrix=bt709:w=1280:h=800:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp" "H:\KMesk_dnd-SSC-15.mkv"


pause

 

Converting 444 to 420 for Vegas

 

Sometimes we need to convert chroma subsampled files for Vegas. This will do so in as non-destructive a way as managable without being super hard on drive space.

 

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS

for %%a in ("E:\MANSPLAIN\*.mkv") do ffmpeg64 -i "%%a" -map 0:0 -c:v:0 libx264 -pix_fmt yuv420p -me_range 4 -preset ultrafast -x264-params crf=16:fullrange=on:colorprim=bt709:colormatrix=bt709 -vf scale="in_range=full:in_color_matrix=bt709:out_range=full:out_color_matrix=bt709" "E:\MANSPLAIN_Encoded\%%~nastream_0.mp4"
pause

 

And this one handled the audio for those files.

 

CD "E:\drunkswede's ffmpeg\bin\"
PROMPT $P$_$G
SET PATH=%CD%;%PATH%
CLS

for %%a in ("E:\MANSPLAIN\*.mkv") do ffmpeg64 -i "%%a" -map 0:1 -c:a:1 pcm_s24le "E:\MANSPLAIN_Encoded\%%~na-stream_1.wav"
for %%a in ("E:\MANSPLAIN\*.mkv") do ffmpeg64 -i "%%a" -map 0:2 -c:a:2 pcm_s24le "E:\MANSPLAIN_Encoded\%%~na-stream_2.wav"
pause