Difference in output files from CLI and GUI

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
Son_Of_Diablo
Posts: 4
Joined: Tue Apr 23, 2019 10:34 am

Difference in output files from CLI and GUI

Post by Son_Of_Diablo » Wed Apr 24, 2019 11:35 am

Hello,

I have noticed that outputs from HandBrake CLI and HandBrake GUI is different.
I use the same preset (H.265 MKV 1080p30) with both.


HandBrake GUI version: 1.2.2 (2019022300)

HandBrake CLI version: HandBrake 1.2.2

OS: Windows 10

HandBrake GUI Activity Log:
https://pastebin.com/2RxtTkkb

HandBrake GUI File Properties:
Image

HandBrake GUI Codec Info (from VLC):
Image


HandBrake CLI Activity Log:
https://pastebin.com/KEZMt6cA

HandBrake CLI File Properties:
Image

HandBrake CLI Codec Info (from VLC):
Image


If you need any other info to help me out please let me know!
I just really want to know why there is a difference in the output files when I use the same preset.

Woodstock
Veteran User
Posts: 3118
Joined: Tue Aug 27, 2013 6:39 am

Re: Difference in output files from CLI and GUI

Post by Woodstock » Wed Apr 24, 2019 2:09 pm

What command line did you use?

The log from the CLI is damaged, and much of it (especially the setup section) is not there.

Son_Of_Diablo
Posts: 4
Joined: Tue Apr 23, 2019 10:34 am

Re: Difference in output files from CLI and GUI

Post by Son_Of_Diablo » Wed Apr 24, 2019 2:12 pm

Command was:

Code: Select all

D:\Programs\HandBrake\HandBrakeCLI.exe -v0 -i ".\filename.mp4" -o ".\filename.mkv" --preset="H.265 MKV 1080p30" 2> my-activity-log.txt

rollin_eng
Veteran User
Posts: 3100
Joined: Wed May 04, 2011 11:06 pm

Re: Difference in output files from CLI and GUI

Post by rollin_eng » Wed Apr 24, 2019 4:32 pm

2 video encodes will not be the same.

I think its down to rounding and averaging things but perhaps someone with better knowledge can answer why.

Son_Of_Diablo
Posts: 4
Joined: Tue Apr 23, 2019 10:34 am

Re: Difference in output files from CLI and GUI

Post by Son_Of_Diablo » Wed Apr 24, 2019 7:27 pm

I'm not quite sure what you mean @rollin_eng it's the same origin video, same preset, same computer, only difference is Handbrake GUI vs Handbrake CLI

User avatar
Rodeo
HandBrake Team
Posts: 12119
Joined: Tue Mar 03, 2009 8:55 pm

Re: Difference in output files from CLI and GUI

Post by Rodeo » Wed Apr 24, 2019 8:03 pm

The difference is like 1 kilobits per second average over the whole video… though typically this is only expected if e.g. the CPUs aren't the same, but maybe x265 isn't fully deterministic?

User avatar
s55
HandBrake Team
Posts: 9463
Joined: Sun Dec 24, 2006 1:05 pm

Re: Difference in output files from CLI and GUI

Post by s55 » Wed Apr 24, 2019 8:26 pm

x265 has modes which can be non-deterministic. This introduces very small variances for each run but for all intensive purposes, can be ignored.

Your settings are the same for both encodes, and the output stats for the video tracks are close enough for it to be irrelevant.

Son_Of_Diablo
Posts: 4
Joined: Tue Apr 23, 2019 10:34 am

Re: Difference in output files from CLI and GUI

Post by Son_Of_Diablo » Thu Apr 25, 2019 11:05 am

Okay, so for all intense and purposes the two output files are basically the same?

That is great to hear!

Thank you so much everyone!

Woodstock
Veteran User
Posts: 3118
Joined: Tue Aug 27, 2013 6:39 am

Re: Difference in output files from CLI and GUI

Post by Woodstock » Thu Apr 25, 2019 3:19 pm

If you do two encodes back-to-back, using the exact same settings, the files WILL be different, because there are fields in the container that include the time of the "mux".

User avatar
s55
HandBrake Team
Posts: 9463
Joined: Sun Dec 24, 2006 1:05 pm

Re: Difference in output files from CLI and GUI

Post by s55 » Thu Apr 25, 2019 3:44 pm

@Woodstock, the video will also be different (in some cases), even with identical settings. x265 won't always produces identical results for subsequent runs. While not identical, the differences is minuscule. Thus, safe to say, they are the same. (Although wouldn't produce the same checksum)

While small, container dates wouldn't impact filesize to the extent @son_of_diablo is seeing.

User avatar
Rodeo
HandBrake Team
Posts: 12119
Joined: Tue Mar 03, 2009 8:55 pm

Re: Difference in output files from CLI and GUI

Post by Rodeo » Thu Apr 25, 2019 5:39 pm

Dates would most likely be fixed-length fields and have no impact on the final output size, too.

rollin_eng
Veteran User
Posts: 3100
Joined: Wed May 04, 2011 11:06 pm

Re: Difference in output files from CLI and GUI

Post by rollin_eng » Thu Apr 25, 2019 5:42 pm

What exactly causes the difference then?

User avatar
Rodeo
HandBrake Team
Posts: 12119
Joined: Tue Mar 03, 2009 8:55 pm

Re: Difference in output files from CLI and GUI

Post by Rodeo » Thu Apr 25, 2019 5:46 pm

rollin_eng wrote:
Thu Apr 25, 2019 5:42 pm
What exactly causes the difference then?
s55 wrote:
Thu Apr 25, 2019 3:44 pm
x265 won't always produces identical results for subsequent runs.
https://en.wikipedia.org/wiki/Deterministic_algorithm (or in this case, lack thereof)

rollin_eng
Veteran User
Posts: 3100
Joined: Wed May 04, 2011 11:06 pm

Re: Difference in output files from CLI and GUI

Post by rollin_eng » Thu Apr 25, 2019 5:47 pm

Ok, but what makes it non-deterministic :)

User avatar
Rodeo
HandBrake Team
Posts: 12119
Joined: Tue Mar 03, 2009 8:55 pm

Re: Difference in output files from CLI and GUI

Post by Rodeo » Thu Apr 25, 2019 5:59 pm

No idea, ask x265 devs.

nhyone
Bright Spark User
Posts: 212
Joined: Fri Jul 24, 2015 4:13 am

Re: Difference in output files from CLI and GUI

Post by nhyone » Fri Apr 26, 2019 3:35 am

I believe it is due to multithreading.

When encoding a chunk, it may need to reference previous chunks. Earlier chunks may finish close enough that different ones are used on different runs.

x264 also has this issue, but to a lesser extent. If you use more threads, space efficiency goes down a little. My guess is that it can only reference much earlier chunks (the ones in-flight can't be used) that results in less compression.

This is why I only use 6 threads (and 1 lookahead) for x264.

User avatar
Rodeo
HandBrake Team
Posts: 12119
Joined: Tue Mar 03, 2009 8:55 pm

Re: Difference in output files from CLI and GUI

Post by Rodeo » Fri Apr 26, 2019 6:46 pm

x264 is fully deterministic unless you specifically tell it not to be though (even with VBV).

nhyone
Bright Spark User
Posts: 212
Joined: Fri Jul 24, 2015 4:13 am

Re: Difference in output files from CLI and GUI

Post by nhyone » Sat Apr 27, 2019 12:19 am

Rodeo wrote:
Fri Apr 26, 2019 6:46 pm
x264 is fully deterministic unless you specifically tell it not to be though (even with VBV).
When lookahead threads > 1, the output size is larger. I forgot if it is deterministic.

And with 1 lookahead thread, there isn't much reason to use >6 threads.

User avatar
s55
HandBrake Team
Posts: 9463
Joined: Sun Dec 24, 2006 1:05 pm

Re: Difference in output files from CLI and GUI

Post by s55 » Sat Apr 27, 2019 10:32 am

Increasing the thread count can change results. As long as those results are the same at a given thread count, t's deterministic.

Post Reply