From 8254bf03797f0fe85971fee31bf732c13985b1de Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 1 Apr 2011 19:35:26 +0300 Subject: [PATCH] Support widescreen mode in NHMLFixup --- scripts/NHMLFixup.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/NHMLFixup.lua b/scripts/NHMLFixup.lua index 57862cf..694b46f 100755 --- a/scripts/NHMLFixup.lua +++ b/scripts/NHMLFixup.lua @@ -1,12 +1,16 @@ #!/usr/bin/env lua ---------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------- --- NHMLFixup v8 by Ilari (2010-12-06). +-- NHMLFixup v9 by Ilari (2011-04-01). -- Update timecodes in NHML Audio/Video track timing to conform to given MKV v2 timecodes file. --- Syntax: NHMLFixup [delay=] [tvaspect] +-- Syntax: NHMLFixup [delay=] [tvaspect|widescreen] -- is number of milliseconds to delay the video (in order to compensate for audio codec delay, reportedly -- does not work right with some demuxers). -- The 'tvaspect' option makes video track to be automatically adjusted to '4:3' aspect ratio. +-- The 'widescreen' option makes video track to be automatically adjusted to '16:9' aspect ratio. +-- +-- Version v9 by Ilari (2011-04-01): +-- - Support widescreen mode ("widescreen"). -- -- Version v8 by Ilari (2010-12-06): -- - Support Special timecode file "@CFR" that fixes up audio for CFR encode. @@ -431,7 +435,7 @@ end if #arg < 3 then - error("Syntax: NHMLFixup.lua [delay=] [tvaspect]"); + error("Syntax: NHMLFixup.lua [delay=] [tvaspect|widescreen]"); end -- Load the NHML files. @@ -480,7 +484,9 @@ delay = 0; rdelay = 0; for i = 4,#arg do if arg[i] == "tvaspect" then - do_aspect_fixup = true; + do_aspect_fixup = 1; + elseif arg[i] == "widescreen" then + do_aspect_fixup = 2; elseif string.sub(arg[i], 1, 6) == "delay=" then local n = tonumber(string.sub(arg[i], 7, #(arg[i]))); if not n then @@ -547,9 +553,12 @@ io.stdout:write("Fixing up audio timecodes..."); io.stdout:flush(); fixup_audio_times(audio_samples, audio_fixup, video_header.timeScale, audio_header.timeScale); io.stdout:write("Done.\n"); -if do_aspect_fixup then +if do_aspect_fixup == 1 then video_header.parNum, video_header.parDen = reduce_fraction(4 * video_header.height, 3 * video_header.width); end +if do_aspect_fixup == 2 then + video_header.parNum, video_header.parDen = reduce_fraction(16 * video_header.height, 9 * video_header.width); +end -- Save the NHML files. io.stdout:write("Computing CTSOffset for video samples..."); io.stdout:flush(); -- 2.11.4.GIT