jlesage / docker-handbrake

Docker container for HandBrake
MIT License
776 stars 91 forks source link

Aspect Ratio Differences #12

Open mbc0 opened 6 years ago

mbc0 commented 6 years ago

Hi,

when using the same custom preset for the docker and the GUI and the same input file I get different results.

The input file is 1920X1080 and if I use my custom preset (which I also use on other machines) I get an output of 1280X694 which is expected.

If I drop the file in the watch folder I get an output of 1280X1080 which obviously looks pretty weird!

Any idea why there should be a difference?

here is the log from the incorrect formatting via the watch folder

------- CONVERSION OUTPUT Fri Feb 23 11:27:35 UTC 2018 ------- [11:27:35] hb_init: starting libhb thread [11:27:35] thread 7f304693aae8 started ("libhb") HandBrake 1.0.7 (2018021400) - Linux x86_64 - https://handbrake.fr 4 CPUs detected Opening /watch/Mr. Brooks 2007 BluRay 10Bit 1080p DD5.1 H265-d3g (1)-002.mkv... [11:27:35] CPU: Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz [11:27:35] - Intel microarchitecture Broadwell [11:27:35] - logical processor count: 4 [11:27:35] hb_scan: path=/watch/Mr. Brooks 2007 BluRay 10Bit 1080p DD5.1 H265-d3g (1)-002.mkv, title_index=1 udfread ERROR: ECMA 167 Volume Recognition failed disc.c:317: failed opening UDF image /watch/Mr. Brooks 2007 BluRay 10Bit 1080p DD5.1 H265-d3g (1)-002.mkv disc.c:418: error opening file BDMV/index.bdmv disc.c:418: error opening file BDMV/BACKUP/index.bdmv [11:27:35] bd: not a bd - trying as a stream/file instead libdvdnav: Using dvdnav version 5.0.1 libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed libdvdread: Can't open file VIDEO_TS.IFO. libdvdnav: vm: failed to read VIDEO_TS.IFO [11:27:35] dvd: not a dvd - trying as a stream/file instead Input #0, matroska,webm, from '/watch/Mr. Brooks 2007 BluRay 10Bit 1080p DD5.1 H265-d3g (1)-002.mkv': Metadata: title : Mr. Brooks 2007 BluRay 10Bit 1080p DD5.1 H265-d3g encoder : libebml v1.3.5 + libmatroska v1.4.8 creation_time : 2018-02-23T11:25:58.000000Z Duration: 00:01:00.07, start: 0.000000, bitrate: 4092 kb/s Chapter #0:0: start 0.000000, end 60.068000 Metadata: title : (01)00:00:00:000 Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt709), 1920x1040 [SAR 1:1 DAR 24:13], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: BPS : 3641623 BPS-eng : 3641623 DURATION : 00:01:00.060000000 DURATION-eng : 00:01:00.060000000 NUMBER_OF_FRAMES: 1440 NUMBER_OF_FRAMES-eng: 1440 NUMBER_OF_BYTES : 27339485 NUMBER_OF_BYTES-eng: 27339485 _STATISTICS_WRITING_APP: mkvmerge v20.0.0 ('I Am The Sun') 64-bit _STATISTICS_WRITING_APP-eng: mkvmerge v20.0.0 ('I Am The Sun') 64-bit _STATISTICS_WRITING_DATE_UTC: 2018-02-23 11:25:58 _STATISTICS_WRITING_DATE_UTC-eng: 2018-02-23 11:25:58 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default) Metadata: BPS : 448000 BPS-eng : 448000 DURATION : 00:01:00.064000000 DURATION-eng : 00:01:00.064000000 NUMBER_OF_FRAMES: 1877 NUMBER_OF_FRAMES-eng: 1877 NUMBER_OF_BYTES : 3363584 NUMBER_OF_BYTES-eng: 3363584 _STATISTICS_WRITING_APP: mkvmerge v20.0.0 ('I Am The Sun') 64-bit _STATISTICS_WRITING_APP-eng: mkvmerge v20.0.0 ('I Am The Sun') 64-bit _STATISTICS_WRITING_DATE_UTC: 2018-02-23 11:25:58 _STATISTICS_WRITING_DATE_UTC-eng: 2018-02-23 11:25:58 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES [11:27:35] scan: decoding previews for title 1 [11:27:35] scan: audio 0x1: ac3, rate=48000Hz, bitrate=448000 English (AC3) (5.1 ch)

Scanning title 1 of 1, preview 3, 30.00 % Scanning title 1 of 1, preview 6, 60.00 % Scanning title 1 of 1, preview 8, 80.00 %[11:27:36] scan: 10 previews, 1920x1040, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1

Scanning title 1 of 1, preview 10, 100.00 %[11:27:36] libhb: scan thread found 1 valid title(s)

encoded 1440 frames in 77.47s (18.59 fps), 899.96 kb/s, Avg QP:24.32 [11:28:53] mux: track 0, 1440 frames, 6762183 bytes, 900.10 kbps, fifo 2048 [11:28:53] mux: track 1, 1877 frames, 3363584 bytes, 447.72 kbps, fifo 2048 [11:28:53] libhb: work result = 0

Encode done! HandBrake has exited.

mbc0 commented 6 years ago

I have been doing some experimenting with this...

I have changed my custom present 3-4 times and removed the docker and reloaded but I still always get 1280X1084

I have also tried customizing an existing preset which although I get 1280X720 nothing I can do will make the sound passthrough (like I can make happen on my custom preset) it ALWAYS encodes even though I have removed encoding audio.. any help would be greatly appreciated! its all so close to being perfect!

jlesage commented 6 years ago

For the aspect ratio, do you have the same behaviour for all your files or only a specific one?

Can you provide some screenshots showing your audio preset settings?

mbc0 commented 6 years ago

Hi,

I get the same issue on all files I have tried.

I am using my custom preset (in the log you can see it is called myhd720P

The Sound is doing exactly what it should which is passing through.

The docker works as expected but only if I use the GUI but it is via the watch folder is where the height goes wrong.

here are 2 files for example

Mr Brooks Original Aspect 1920X1040 GUI automatically correctly guesses the output 1280X694 but via the watch folder I get 1280X1080

Dr Zhivago Original Aspect 1920X800 GUI automatically correctly guesses the output 1280X534 but via the watch folder I get 1280X694

mbc0 commented 6 years ago

Hopefully this may be of help... it is a folder containing 2 encodes of the same file, one was done via the GUI and the other via the Watch Folder, I have included also the logs for each encode.. The GUI correctly chooses 594 as the height and the Watch folder chooses incorrectly 694 as the height. Same file, same preset. Hope you can help me :-) https://1drv.ms/f/s!AjnJhtmhYMJlhqYt1WhXLwAZCQT5Rg

jlesage commented 6 years ago

Are you using the latest version of the container image? If yes, can you try with the previous version (1.11.2) to see if you have the same behaviour?

mbc0 commented 6 years ago

I am using the latest as I just followed this instructions on this page, how do I specify a version?

jlesage commented 6 years ago

In your docker run command, just use jlesage/handbrake:v1.11.2 instead of jlesage/handbrake for the repository.

mbc0 commented 6 years ago

Hi, I removed the old image and reloaded with 1.11.2 but now I get 1280X720??? I have uploaded the conversion log into the onedrive folder (https://1drv.ms/f/s!AjnJhtmhYMJlhqYt1WhXLwAZCQT5Rg) and also a screenshot of the handbrake GUI that proves the preset auto selects the aspect ratio from 1920X800 to 1280X534 as it should do but for whatever reason the watch folder is not able to select the correct height despite being the same preset?

Thanks for all your time on this...

jlesage commented 6 years ago

Did you get distorted image or it encoded black bars? Also, if you use one of the default preset (like Fast 720p30) without changing any setting, do you get the same result?

mbc0 commented 6 years ago

Hi, the video results are in the onedrive folder I shared, you will see it is distorted using my custom preset myhd720p but only when using the watch folder, the preset works when using the GUI

I just tried using the default fast 720p30 and although it outputs 1280X720 instead of 1280X594 like my preset does it looks great! (Does this mean it is encoding the black bars?)

jlesage commented 6 years ago

I think the video I was talking about is not on OneDrive. I was talking about the video you got with version 1.11.2: it has a different resolution of 1280x720, while the one with the latest version had a resolution of 1280X694.

mbc0 commented 6 years ago

My apologies, I have now added myhd720p custom preset result & the veryfast720p30 result to onedrive..

jlesage commented 6 years ago

Is the video for veryfast720p30 the right one? You said that it has a resolution of 1280x720, but the one on OneDrive has 1920x800.

mbc0 commented 6 years ago

Again! Apologies!

I accidentally uploaded the source.. the encode is there now :-)

jlesage commented 6 years ago

Sorry I didn't had time to look at this... Trying to push some fixes for HandBrake.

However, since the veryfast720p30 preset is working better, did you compared with your preset to see the differences?

Also, I was not able to confirm if the auto-crop feature is something that should be working with the CLI... It doesn't seems to have an argument for this feature and I don't know if it will pick up the option in the preset file. Do you have more details in this regard?

mbc0 commented 6 years ago

Hi,

Sorry for my delay too I have been unwell..

The difference between veryfast720p30 and my own is that on my preset Anamorphic is disabled on my preset and enabled on veryfast720p30 I have however tried disabling it on my preset with no difference :-(

As for CLI I have never used it.. I am just using the preset that I have on several machines where the encoding works perfectly and trying to apply it to your docker. I am sure it must be possible to do through CLI as the GUI I would imaging just uses the same parameters as CLI it is just prettier/easier?

jlesage commented 6 years ago

That's what I would assume... But that's obviously not the case. Can you also upload a part of the original movie and your preset file (found under ghb/presets.json in your appdata folder)?

mbc0 commented 6 years ago

Hi, All uploaded, if you load the file segment into the GUI using my preset you will see that handbrake automatically chooses 1280X534 which is what I am trying to achieve.

Many Thanks Again!

jlesage commented 6 years ago

Do you still have issue with this? For me, it seems that enabling anamorphic (to loose) fixed the problem.

cpatenta commented 5 years ago

Hello, I think the same problem got me here. If I use the GUI with a custom preset it keeps the aspect ratio (720x406 in my case), if I use the watch folder it doesn't and makes the video 720x480. The preset seems ok, "PictureKeepRatio" is set to true.

How can I make Handbrake keep aspect ratio when using watch folders?

Thank you!

                "PictureAutoCrop": true,
                "PictureBottomCrop": 0,
                "PictureCombDetectCustom": "",
                "PictureCombDetectPreset": "default",
                "PictureDARWidth": 0,
                "PictureDeblock": 0,
                "PictureDeblockCustom": "qp=0:mode=2",
                "PictureDeinterlaceCustom": "",
                "PictureDeinterlaceFilter": "decomb",
                "PictureDeinterlacePreset": "default",
                "PictureDenoiseCustom": "",
                "PictureDenoiseFilter": "off",
                "PictureDenoisePreset": "",
                "PictureDenoiseTune": "none",
                "PictureDetelecine": "off",
                "PictureDetelecineCustom": "",
                "PictureForceHeight": 0,
                "PictureForceWidth": 0,
                "PictureHeight": 480,
                "PictureItuPAR": false,
                "PictureKeepRatio": true,
                "PictureLeftCrop": 0,
                "PictureLooseCrop": false,
                "PictureModulus": 2,
                "PicturePAR": "off",
                "PicturePARHeight": 1,
                "PicturePARWidth": 1,
                "PictureRightCrop": 0,
                "PictureRotate": "disable=1",
                "PictureSharpenCustom": "",
                "PictureSharpenFilter": "off",
                "PictureSharpenPreset": "",
                "PictureSharpenTune": "",
                "PictureTopCrop": 0,
                "PictureWidth": 720,
jlesage commented 5 years ago

Did you try to enable anamorphic and set it to loose?

"PicturePAR": "loose"

cpatenta commented 5 years ago

It worked! Thank you!

kitobelix commented 5 years ago

Hi! I'm super grateful for this job. Thank you very much jlesage for your effort and your time. Fortunately I had this inconvenience a few hours ago and found the problem. It turns out, that HB's graphical interface saves profiles with the last configuration applied with the video that was used to generate the profile or with the default values that are applied when you don't load a video and save a profile. In my experiments, I found it viable to save the profiles using the following settings:

Anamorphic: loose Resolution: Width: 0 | Height: 720px Aspect Ratio: 1:1

Then, when the profile is saved, you must manually edit these values in the profile file "profile.json" with a text editor so that they are as follows:

"PicturePAR": "loose", "PicturePARHeight": 0, "PicturePARWidth: 0, "PictureWidth: 0,

Thus, the CLI will automatically decide the aspect ratio and horizontal resolution and the video will be well formed in players that do not support anamorphic video. It would be great to apply a parameter in the RUN file to omit these parameters on demand, perhaps with an environment variable? Any algorithm? I don't know, I leave it to you. Greetings!