Jump to content

FFMPEG vs Handbrake giving me different results

As the 1080p videos from my phone and camera are bloated, running them through handbrake removes the metadata, so I have to use ffmpeg with "-map_metadata 0".

 

These are my video settings on handbrake - Nvidia NVNC HEVC h265, CQR 30, Slow preset. Not sure how much rc-lookahead is affecting the video size, and I don't know what the right command for ffmpeg is. Everything else is passthrough'd. 

 

I got the .bat script from EposVox's github which I edited a bit, full code listed at the bottom. I just want to mirror all settings in handbrake to ffmpeg.

 

The video quality, as I tested using vmaf are slightly worse than the handbrake's encode, and are always smaller. Although I don't see the difference quite as much without pixel peeping, I only tested with smaller videos. 

ffmpeg -hwaccel auto -i "%%A" -map 0:v -map 0:a -map_metadata 0 -c:v hevc_nvenc -preset slow -rc constqp -qp %ffmpeg_qv% -b:v 0K -c:a aac -b:a 384k -movflags +faststart -movflags use_metadata_tags "%%A_compressed.mp4"

 

image.thumb.png.9257a1ee79734476ff5b01d3587a1a48.png

 

pushd "%2"

::Default variables
SET paths=paths.txt
::paths lets you put a bunch of folder paths in a text file and run this across those, instead of individually. I use this to run overnight on a LOT of footage folders at once. Thanks to Aayla for a lot of these upgrades
::Fun tip - select your folders (15 max at a time) and shift+right-click and click "copy as paths"
SET /A ffmpeg_qv=30
::change CQP value here so you only have to type it once. 22 is lossless for HEVC.

::for /R %%A in (*.mp4, *.avi, *.mov, *.wmv, *.ts, *.m2ts, *.mkv, *.mts) do (
::    echo Processing %%A
::    ffmpeg -hwaccel auto -i "%%A" -pix_fmt p010le -map 0:v -map 0:a -c:v hevc_nvenc -rc constqp -qp 21 -b:v 0K -c:a libfdk_aac -vbr 5 -movflags +faststart "%%A~dnpA_CRF%ffmpeg_qv%_HEVC.mp4"
::    echo Processed %%A
::)
::pause
::Test if the paths file exists and iterate through it
if EXIST %paths% (
    for /f "tokens=*" %%a in (%paths%) do (
        echo Changing to directory %%a
        pushd "%%a"
        CALL :ffmpeg
    )
) else (
    ::It doesn't exist
    CALL :ffmpeg
)
pause
EXIT /B %ERRORLEVEL%
::Don't run the function when they're first defined because that's a thing Batch does for some reason???
:ffmpeg
    for /R %%A in (*.mp4, *.avi, *.mov, *.wmv, *.ts, *.m2ts, *.mkv, *.mts) do (
        echo Processing "%%A"
        ffmpeg -hwaccel auto -i "%%A" -map 0:v -map 0:a -map_metadata 0 -c:v hevc_nvenc -preset slow -rc constqp -qp %ffmpeg_qv% -b:v 0K -c:a aac -b:a 384k -movflags +faststart -movflags use_metadata_tags "%%A_compressed.mp4"
		::"-pix_fmt p010le" is setting it to 10-bit instead of 420 8-bit, which is what I had before (removed by me)
		:: "-map_metadata 0" copies all metadata from source file
		:: "-movflags +faststart" helps with audio streaming
        echo Processed %%A
    )
GOTO :EOF

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

QP21 in FFMPEG, no rc-lookahead (much higher quality in theory but also higher file size)

 

QP30 in Handbrake, with rc-lookiahead

 

At least the obvious things I catched from quick glance on those screenshots

Link to comment
Share on other sites

Link to post
Share on other sites

34 minutes ago, WereCat said:

QP21 in FFMPEG, no rc-lookahead (much higher quality in theory but also higher file size)

 

QP30 in Handbrake, with rc-lookiahead

 

At least the obvious things I catched from quick glance on those screenshots

The QP21 is in comment, the actual code is set to 30 at the top. Check 7th line.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×