Page 1 of 1

Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 11:35 am
by Son_Of_Diablo
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.

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 2:09 pm
by Woodstock
What command line did you use?

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

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 2:12 pm
by Son_Of_Diablo
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

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 4:32 pm
by rollin_eng
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.

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 7:27 pm
by Son_Of_Diablo
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

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 8:03 pm
by Deleted User 11865
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?

Re: Difference in output files from CLI and GUI

Posted: Wed Apr 24, 2019 8:26 pm
by s55
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.

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 11:05 am
by Son_Of_Diablo
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!

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 3:19 pm
by Woodstock
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".

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 3:44 pm
by s55
@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.

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 5:39 pm
by Deleted User 11865
Dates would most likely be fixed-length fields and have no impact on the final output size, too.

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 5:42 pm
by rollin_eng
What exactly causes the difference then?

Re: Difference in output files from CLI and GUI

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

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 5:47 pm
by rollin_eng
Ok, but what makes it non-deterministic :)

Re: Difference in output files from CLI and GUI

Posted: Thu Apr 25, 2019 5:59 pm
by Deleted User 11865
No idea, ask x265 devs.

Re: Difference in output files from CLI and GUI

Posted: Fri Apr 26, 2019 3:35 am
by nhyone
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.

Re: Difference in output files from CLI and GUI

Posted: Fri Apr 26, 2019 6:46 pm
by Deleted User 11865
x264 is fully deterministic unless you specifically tell it not to be though (even with VBV).

Re: Difference in output files from CLI and GUI

Posted: Sat Apr 27, 2019 12:19 am
by nhyone
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.

Re: Difference in output files from CLI and GUI

Posted: Sat Apr 27, 2019 10:32 am
by s55
Increasing the thread count can change results. As long as those results are the same at a given thread count, t's deterministic.