Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > (HD) DVD, Blu-ray & (S)VCD > DVD & BD Rebuilder

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th August 2021, 21:21   #1  |  Link
alek2702
Registered User
 
Join Date: Jul 2021
Posts: 3
4K to 1080p compliant BD-25?

Got some 4K mkvs I'd like to back up to 1080p compliant BD-25s.

While I can import them fine, it seems like it's not scaling them down to 1080p in Movie-only mode.
There's an old thread from a couple years ago - jdobbs suggested using Alternate output but these are not BD-compliant (slices, vbv-maxrate, GOP size, not sure what else is out of spec) even with the ALTERNATE_BLURAY=1 line added.

Any other way to get a compliant 1080p stream out of 4k files?
Thanks in advance!
alek2702 is offline   Reply With Quote
Old 14th August 2021, 13:44   #2  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,765
I would almost certainly re-encode them myself with Avisynth and x264, but we need more info.
Can you post here a full MediaInfo of the original file?
FranceBB is offline   Reply With Quote
Old 24th August 2021, 14:34   #3  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Metropolitan City of Milan, Italy
Posts: 1,765
Well, it's been 10 days and alek2702 didn't reply with more details, so I'm gonna do some guess work and post a reply that will actually help people.

So, he said a 4K .mkv and he wants to get a FULL HD BD, so let's suppose we have a UHD 3840x2160 23.976fps progressive BT2100 HDR PQ 10bit H.265 file and that we want to go to H.264 FULL HD BT709 SDR for BD-25 compatibility.

Here is the AVS Script:

Code:
#Indexing
FFMpegSource2("UHD.mkv", atrack=-1)

#From 10bit planar to 16bit planar
ConvertBits(16)

#From YUV to XYZ with 16bit planar precision
ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)

#From HDR PQ to SDR BT709 100 nits tonemapping with 16bit planar precision
ConvertXYZ_Reinhard_HDRtoSDR(exposure_X=2.5, contrast_X=0.9)

#From XYZ back to YUV with 16bit precision
ConvertXYZtoYUV(pColor=0)

#Downscale from UHD to FULL HD with 16bit precison
Spline64Resize(1920, 1080)

#From 4:4:4 planar 16bit to 4:2:0 planar 16bit
Converttoyuv420(matrix="Rec709", interlaced=false)

#Dithering down to 8bit planar with the Floyd Steinberg Error Diffusion
ConvertBits(bits=8, dither=1)

#Clipping
Limiter(min_luma=16, max_luma=235, min_chroma=16, max_chroma=240)

#Resampling
ResampleAudio(48000)

At this point, we just need x264 to create a BD-25 compatible file, so:



Quote:
avs4x264mod.exe "I:\AVS Script.avs" --x264-binary "x264.exe" --bitrate 25000 --preset medium --profile High --level 4.1 --keyint 24 --slices 4 --deblock -1:-1 --overscan show --range tv --log-level info --thread-input --opencl --colormatrix bt709 --transfer bt709 --colorprim bt709 --videoformat component --nal-hrd vbr --vbv-maxrate 40000 --vbv-bufsize 30000 --pass 1 --output NUL

avs4x264mod.exe "I:\AVS Script.avs" --x264-binary "x264.exe" --bitrate 25000 --preset medium --profile High --level 4.1 --keyint 24 --slices 4 --deblock -1:-1 --overscan show --range tv --log-level info --thread-input --opencl --colormatrix bt709 --transfer bt709 --colorprim bt709 --videoformat component --nal-hrd vbr --vbv-maxrate 40000 --vbv-bufsize 30000 --pass 2 --output "I:\temp\raw_video.h264"


ffmpeg.exe -i "I:\AVS Script.avs" -vn -sn -af loudnorm=I=-24:LRA=10:tp=-2 -c:a dca -b:a 1536k -ar 48000 -strict -2 "I:\temp\audio.dts"

ffmpeg.exe -i "I:\AVS Script.avs" -vn -sn -af loudnorm=I=-24:LRA=10:tp=-2 -c:a ac3 -b:a 384k -ac 2 -ar 48000 "I:\temp\audio.ac3"

C:/Programmi/MKVToolNix\mkvmerge.exe --output "\\VBOXSVR\Share_Windows_Linux\temp\raw_video.mkv" --language 0:und ^"^(^" \\VBOXSVR\Share_Windows_Linux\temp\raw_video.h264 ^"^)^"

ffmpeg.exe -i "\\VBOXSVR\Share_Windows_Linux\temp\raw_video.mkv" -i "\\VBOXSVR\Share_Windows_Linux\temp\audio.dts" -i "\\VBOXSVR\Share_Windows_Linux\temp\audio.ac3" -map 0:0 -map 1:0 -map 2:0 -c:v copy -c:a copy -c:a copy -metadata provider_name="Avisynth" -metadata service_provider="Avisynth" -metadata service_name="Avisynth" -mpegts_original_network_id 0x1122 -mpegts_transport_stream_id 0x3344 -mpegts_service_id 0x5566 -mpegts_pmt_start_pid 0x1500 -mpegts_start_pid 0x150 -mpegts_service_type "digital_tv" -mpegts_flags "resend_headers" "\\VBOXSVR\Share_Windows_Linux\temp\final.m2ts"

pause

This way we've been encoding the file with two passes in H.264 so that it's BD compliant and we've got the .h264 file. Then, we've encoded the audio in DTS and we've added a second track as AC3 for backward compatibility.
Last but not least we've been creating a temporary mkv file with our newly encoded video and audio which has then been remuxed to .m2ts called "final.m2ts" and it's ready to be burned on a disk or be played by a compatible Bluray player on the fly.


Cheers,
Frank

Last edited by FranceBB; 24th August 2021 at 14:37.
FranceBB is offline   Reply With Quote
Old 24th August 2021, 20:27   #4  |  Link
jdobbs
Moderator
 
Join Date: Oct 2001
Posts: 20,851
Quote:
Originally Posted by alek2702 View Post
Got some 4K mkvs I'd like to back up to 1080p compliant BD-25s.

While I can import them fine, it seems like it's not scaling them down to 1080p in Movie-only mode.
There's an old thread from a couple years ago - jdobbs suggested using Alternate output but these are not BD-compliant (slices, vbv-maxrate, GOP size, not sure what else is out of spec) even with the ALTERNATE_BLURAY=1 line added.

Any other way to get a compliant 1080p stream out of 4k files?
Thanks in advance!
All you have to do is make sure that the hidden option:

ALTERNATE_BLURAY=1

... is enabled. It should be enabled by default. But you can add it just to be sure. (See HIDDENOPTS.TXT for more details)

Remember though... you can't just "import" the files or choose an ALTERNATE output option that keeps the original. They have to be reencoded to ALTERNATE output to get proper settings. Setting #10 in the default ALTERNATE.TXT file might be a good choice: "MKV Container, 1920x1080, 640Kbs DD5.1".
__________________
Help with development of new apps: Donations.
Website: www.jdobbs.net

Last edited by jdobbs; 29th August 2021 at 13:53.
jdobbs is offline   Reply With Quote
Old 11th September 2021, 08:48   #5  |  Link
alek2702
Registered User
 
Join Date: Jul 2021
Posts: 3
Quote:
Originally Posted by FranceBB View Post
Well, it's been 10 days and alek2702 didn't reply with more details, so I'm gonna do some guess work and post a reply that will actually help people.
Apologies, I missed your original reply. And thanks a lot for the script, definitely helpful!
alek2702 is offline   Reply With Quote
Old 11th September 2021, 08:58   #6  |  Link
alek2702
Registered User
 
Join Date: Jul 2021
Posts: 3
Quote:
Originally Posted by jdobbs View Post
All you have to do is make sure that the hidden option:

ALTERNATE_BLURAY=1

... is enabled. It should be enabled by default. But you can add it just to be sure. (See HIDDENOPTS.TXT for more details)

Remember though... you can't just "import" the files or choose an ALTERNATE output option that keeps the original. They have to be reencoded to ALTERNATE output to get proper settings. Setting #10 in the default ALTERNATE.TXT file might be a good choice: "MKV Container, 1920x1080, 640Kbs DD5.1".
Thanks for the reply!
I'm aware 4k to 1080p is going to be a re-encode and I did try using the ALTERNATE_BLURAY=1 line but the resulting BD would not play on my PS4 (did work fine in another standalone though).
Upon further inspection I noticed slices, vbv-maxrate, GOP size were out of spec so I don't think the ALTERNATE_BLURAY=1 line was doing its job.

I have since added this to the INI file:
TWEAK_ALTERNATE= --slices 4 --vbv-maxrate 35000

and to alternate.txt:
vKeyint=24

to keep those in spec but was wondering if there's an easier way to do that. Haven't had the chance to test the resulting files on the PS4 yet.

Last edited by alek2702; 20th September 2021 at 16:30.
alek2702 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.