12 for i
, value
in ipairs(arg
) do
13 if string.sub(value
, 1, 6) == "width=" then
14 width
= tonumber(string.sub(value
, 7, #value
));
16 if string.sub(value
, 1, 7) == "height=" then
17 height
= tonumber(string.sub(value
, 8, #value
));
19 if string.sub(value
, 1, 5) == "rate=" then
20 rate
= tonumber(string.sub(value
, 6, #value
));
22 if string.sub(value
, 1, 4) == "crf=" then
23 crf
= tonumber(string.sub(value
, 5, #value
));
25 if string.sub(value
, 1, 7) == "aspect=" then
26 aspect
= string.sub(value
, 8, #value
);
28 if value
== "final" then
31 if value
== "finale" then
35 if not width
or not height
or not rate
then
36 error("Valid width, height and rate needed (rate has default)");
40 if finalmode
or finalmodee
then
47 print("Width: " .. width
);
48 print("Height: " .. height
);
49 print("Rate: " .. rate
);
51 io
.stdout
:write("Creating src video pipe...");
52 os
.execute("rm -f video.src");
53 os
.execute("mkfifo video.src");
56 io
.stdout
:write("Creating src audio pipe...");
57 os
.execute("rm -f audio.src");
58 os
.execute("mkfifo audio.src");
61 io
.stdout
:write("Creating RGB video pipe...");
62 os
.execute("rm -f video.rgb");
63 os
.execute("mkfifo video.rgb");
66 io
.stdout
:write("Creating YUV video pipe...");
67 os
.execute("rm -f video.yuv");
68 os
.execute("mkfifo video.yuv");
71 io
.stdout
:write("Checking if PC speaker output is present...");
72 file
= io
.open("speaker.dump", "r");
77 outputs
= outputs
+ 1;
83 io
.stdout
:write("Checking if PCM output is present...");
84 file
= io
.open("pcm.dump", "r");
89 outputs
= outputs
+ 1;
94 io
.stdout
:write("Checking if FM output is present...");
95 file
= io
.open("fm.dump", "r");
100 outputs
= outputs
+ 1;
106 print("Converting PC speaker audio...");
108 os
.execute("xterm -e sh -c \"cat logoaudio.dump speaker.dump >audio.src \" &");
109 filename
= "audio.src";
111 filename
= "speaker.dump";
114 os
.execute("rawtoaudio2.exe --input-file=" .. filename
.. " --input-format=pcm --output-file=speaker.wav --output-format=wav --output-attenuation=20 --output-rate=" .. rate
);
119 print("Converting PCM audio...");
121 os
.execute("xterm -e sh -c \"cat logoaudio.dump pcm.dump >audio.src \" &");
122 filename
= "audio.src";
124 filename
= "pcm.dump";
127 os
.execute("rawtoaudio2.exe --input-file=" .. filename
.. " --input-format=pcm --output-file=pcm.wav --output-format=wav --output-rate=" .. rate
);
132 print("Converting FM audio...");
134 os
.execute("xterm -e sh -c \"cat logoaudio.dump fm.dump >audio.src \" &");
135 filename
= "audio.src";
137 filename
= "fm.dump";
140 os
.execute("rawtoaudio2.exe --input-file=" .. filename
.. " --input-format=fm --output-file=fm.wav --output-format=wav --output-rate=" .. rate
);
146 if outputs
> 1 then command
= command
.. "-m "; end
147 if speaker
then command
= command
.. "speaker.wav "; end
148 if pcm
then command
= command
.. "pcm.wav "; end
149 if fm
then command
= command
.. "fm.wav "; end
150 command
= command
.. "soundtrack.ogg";
151 io
.stdout
:write("Mixing soundtrack...");
156 io
.stdout
:write("Launching logo insertion...");
158 os
.execute("xterm -e sh -c \"cat logovideo.dump video.dump >video.src \" &");
160 os
.execute("xterm -e sh -c \"cat video.dump >video.src \" &");
164 io
.stdout
:write("Launching video conversion...");
165 os
.execute("xterm -e rawtorgb.exe video.src video.rgb lanczos2 " .. width
.. " " .. height
.. " 16666667 &");
168 io
.stdout
:write("Launching RGB->YUV conversion...");
169 os
.execute("xterm -e mencoder -nosound -vf format=i420 -ovc raw -of rawvideo -o video.yuv -demuxer rawvideo -rawvideo w=" .. width
.. ":h=" .. height
.. ":fps=60:format=rgb32 video.rgb &");
172 for i
=1,50000000 do end
174 print("Launching encoder process...");
175 if finalmode
or finalmodee
then
176 os
.execute("x264 --ssim --crf " .. crf
.. " --keyint 600 --ref 16 --mixed-refs --no-fast-pskip --bframes 16 --b-adapt 2 --mbtree --weightb --direct auto --subme 10 --trellis 2 --partitions all --me esa --merange 128 --rc-lookahead 250 --fullrange on --threads 6 --8x8dct --no-dct-decimate --sar " .. aspect
.. " --fps 60 -o videoonly.mkv video.yuv " .. width
.. "x" .. height
);
178 os
.execute("x264 --preset slow --threads 8 --crf " .. crf
.. " --merange 96 --me umh --sar " .. aspect
.. " --fps 60 -o videoonly.mkv video.yuv " .. width
.. "x" .. height
);
183 print("Muxing the MKV...");
185 os
.execute("mkvmerge -o final.mkv videoonly.mkv soundtrack.ogg");
187 os
.execute("mkvmerge -o final-wip.mkv videoonly.mkv soundtrack.ogg");