This commit is contained in:
Brooke Vibber 2023-03-25 20:26:45 -07:00
parent 7fa606743f
commit 5196adef43
7 changed files with 6 additions and 18 deletions

View file

@ -589,7 +589,6 @@ function decimate(input, palette, n) {
// preface the reserved bits // preface the reserved bits
let buckets = reserved.slice().map((c) => [atariRGB[c]]).concat([input.slice()]); let buckets = reserved.slice().map((c) => [atariRGB[c]]).concat([input.slice()]);
if (input.length != 160) { if (input.length != 160) {
console.log(input.length);
throw new Error('xxx bad input size'); throw new Error('xxx bad input size');
} }
@ -615,7 +614,6 @@ function decimate(input, palette, n) {
}; };
let medianCut = (bucket, range) => { let medianCut = (bucket, range) => {
if (bucket.length < 2) { if (bucket.length < 2) {
console.log(bucket);
throw new Error('short bucket'); throw new Error('short bucket');
} }
//console.log('medianCut', bucket, range); //console.log('medianCut', bucket, range);
@ -642,7 +640,6 @@ function decimate(input, palette, n) {
// Find the bucket with the greatest range in any channel // Find the bucket with the greatest range in any channel
let ranges = buckets.map((bucket) => { let ranges = buckets.map((bucket) => {
if (bucket.length == 0) { if (bucket.length == 0) {
console.log(buckets);
throw new Error('xxx empty bucket'); throw new Error('xxx empty bucket');
} }
let red = bucket.map((rgb) => rgb.r); let red = bucket.map((rgb) => rgb.r);
@ -766,13 +763,7 @@ function decimate(input, palette, n) {
let index = dists.indexOf(closest); let index = dists.indexOf(closest);
return palette[index]; return palette[index];
}); });
// hack
decimated.sort((a, b) => a - b); decimated.sort((a, b) => a - b);
console.log(decimated);
// we shouldn't have to do this
//decimated[0] = 0;
console.log(decimated);
// Palette fits // Palette fits
return dither(decimated); return dither(decimated);
@ -842,7 +833,6 @@ async function convert(source) {
height, height,
rgba rgba
} = await loadImage(source); } = await loadImage(source);
console.log({width,height});
if (width > 160) { if (width > 160) {
throw new Error(`expected <160px width, got ${width} pixels`); throw new Error(`expected <160px width, got ${width} pixels`);
@ -893,9 +883,7 @@ async function convert(source) {
.slice(y * width, (y + 1) * width); .slice(y * width, (y + 1) * width);
if (padding) { if (padding) {
console.log(`length was ${inputLine.length}`);
inputLine = left.concat(inputLine, right); inputLine = left.concat(inputLine, right);
console.log(`length is now ${inputLine.length}`);
} }
if (y > 0) { if (y > 0) {
let error = lines[y - 1].error; let error = lines[y - 1].error;

View file

@ -4,7 +4,7 @@ ffmpeg \
-i 'cats-audio.wav' \ -i 'cats-audio.wav' \
-ac 2 \ -ac 2 \
-ar 48000 \ -ar 48000 \
-vf 'pad=w=640:h=360:x=52:y=20' \ -vf 'pad=w=534' \
-pix_fmt yuv420p \ -pix_fmt yuv420p \
-movflags +faststart \ -movflags +faststart \
-y cats-dither.mp4 -y cats-dither.mp4

View file

@ -4,7 +4,7 @@ mkdir -p frames
ffmpeg \ ffmpeg \
-i 'cats computer fun.mp4' \ -i 'cats computer fun.mp4' \
-vf 'scale=160:150,pad=h=160:y=5' \ -vf 'scale=320:150,pad=h=192:y=5' \
-an \ -an \
-y 'frames/cats-%04d.png' -y 'frames/cats-%04d.png'

View file

@ -4,7 +4,7 @@ ffmpeg \
-i 'doom-audio.wav' \ -i 'doom-audio.wav' \
-ac 2 \ -ac 2 \
-ar 48000 \ -ar 48000 \
-vf 'pad=w=640:h=360:x=52:y=20' \ -vf 'pad=w=534' \
-pix_fmt yuv420p \ -pix_fmt yuv420p \
-movflags +faststart \ -movflags +faststart \
-y doom-dither.mp4 -y doom-dither.mp4

View file

@ -8,7 +8,7 @@ ffmpeg \
-i 'doom-speedrun.webm' \ -i 'doom-speedrun.webm' \
-t $TIME \ -t $TIME \
-r 60000/1001 \ -r 60000/1001 \
-vf 'scale=160:192' \ -vf 'scale=320:192' \
-an \ -an \
-y 'frames/doom-%04d.png' -y 'frames/doom-%04d.png'

View file

@ -4,7 +4,7 @@ ffmpeg \
-i 'colamath-audio.wav' \ -i 'colamath-audio.wav' \
-ac 2 \ -ac 2 \
-ar 48000 \ -ar 48000 \
-vf 'pad=w=640:h=360:x=52:y=20' \ -vf 'pad=w=534' \
-pix_fmt yuv420p \ -pix_fmt yuv420p \
-movflags +faststart \ -movflags +faststart \
-y colamath-dither.mp4 -y colamath-dither.mp4

View file

@ -4,7 +4,7 @@ mkdir -p frames
ffmpeg \ ffmpeg \
-i colamath-dv.avi \ -i colamath-dv.avi \
-vf 'yadif=1,scale=160:200,crop=h=160' \ -vf 'yadif=1,scale=320:200,crop=h=192:y=4' \
-an \ -an \
-y 'frames/colamath-%04d.png' -y 'frames/colamath-%04d.png'