Script is now able to generate standard and random sequences from the example videos provided in the examples.sh script. The --realtime and --random flags are working. TODO: fix alt patterns like 2:2 or 3:1
This commit is contained in:
parent
91a5298b72
commit
d2e33bd8de
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Downloading example videos from archive.org..."
|
||||||
|
|
||||||
|
mkdir examples
|
||||||
|
|
||||||
|
#Please run this script sparingly!!!
|
||||||
|
|
||||||
|
if [ ! -f ./examples/A.mp4 ]; then
|
||||||
|
wget -O A.mp4 https://ia802701.us.archive.org/9/items/electricsheep-flock-244-20000-0/00244%3D20660%3D11095%3D11000_512kb.mp4
|
||||||
|
mv A.mp4 ./examples/
|
||||||
|
fi
|
||||||
|
if [ ! -f ./examples/B.mp4 ]; then
|
||||||
|
wget -O B.mp4 https://ia802603.us.archive.org/0/items/electricsheep-flock-244-72500-0/00244%3D73690%3D73529%3D73425.mp4
|
||||||
|
mv B.mp4 ./examples/
|
||||||
|
fi
|
||||||
|
if [ ! -f ./examples/C.mp4 ]; then
|
||||||
|
wget -O C.mp4 https://ia800300.us.archive.org/6/items/electricsheep-flock-244-72500-8/00244%3D73008%3D72588%3D72531.mp4
|
||||||
|
mv C.mp4 ./examples/
|
||||||
|
fi
|
||||||
|
if [ ! -f ./examples/D.mp4 ]; then
|
||||||
|
wget -O D.mp4 https://ia800306.us.archive.org/34/items/electricsheep-flock-244-72500-6/00244%3D73236%3D72551%3D72705.mp4
|
||||||
|
mv D.mp4 ./examples/
|
||||||
|
fi
|
||||||
|
if [ ! -f ./examples/E.mp4 ]; then
|
||||||
|
wget -O E.mp4 https://ia600501.us.archive.org/16/items/electricsheep-flock-244-82500-4/00244%3D82524%3D82019%3D82016.mp4
|
||||||
|
mv E.mp4 ./examples/
|
||||||
|
fi
|
||||||
|
|
||||||
|
./frameloom -i "./examples/A.mp4:./examples/B.mp4" -o "./examples/AB.mov"
|
||||||
|
./frameloom -i "./examples/A.mp4:./examples/B.mp4" -o "./examples/AB_realtime.mov" --realtime
|
||||||
|
./frameloom -i "./examples/A.mp4:./examples/B.mp4:./examples/C.mp4:./examples/D.mp4" -o "./examples/ABCD.mov"
|
||||||
|
./frameloom -i "./examples/B.mp4:./examples/C.mp4" -o "./examples/BCE_random.mov" --random
|
20
frameloom
20
frameloom
|
@ -10,6 +10,7 @@ const fs = require('fs-extra')
|
||||||
|
|
||||||
let TMPDIR = os.tmpdir() || '/tmp'
|
let TMPDIR = os.tmpdir() || '/tmp'
|
||||||
let TMPPATH
|
let TMPPATH
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shells out to execute a command with async/await.
|
* Shells out to execute a command with async/await.
|
||||||
* Async wrapper to exec module.
|
* Async wrapper to exec module.
|
||||||
|
@ -70,6 +71,7 @@ function shuffle (a) {
|
||||||
* Establishes a directory if none exists.
|
* Establishes a directory if none exists.
|
||||||
**/
|
**/
|
||||||
async function clear () {
|
async function clear () {
|
||||||
|
let cmd = `rm -r "${TMPPATH}"`
|
||||||
let exists
|
let exists
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -81,9 +83,10 @@ async function clear () {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
console.log(`Clearing temp directory "${TMPPATH}"`)
|
console.log(`Clearing temp directory "${TMPPATH}"`)
|
||||||
try {
|
try {
|
||||||
await fs.rmdir(TMPPATH)
|
await exec(cmd)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
//suppress error
|
//suppress error
|
||||||
|
console.dir(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +97,8 @@ async function clear () {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Exports all frames from video. Appends number to the string
|
* Exports all frames from video. Appends number to the string
|
||||||
|
@ -124,7 +129,7 @@ async function frames (video, order, avconv) {
|
||||||
return process.exit(3)
|
return process.exit(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.join(TMPPATH, `export_${order}`)
|
return path.join(TMPPATH, `export-%05d_${order}`)
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Re-arranges the frames into the order specified in the pattern.
|
* Re-arranges the frames into the order specified in the pattern.
|
||||||
|
@ -273,7 +278,7 @@ async function standardSort (list, pattern, realtime) {
|
||||||
console.log(`Renaming ${list[i]} -> ${newName}`)
|
console.log(`Renaming ${list[i]} -> ${newName}`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.move(oldPath, newPath, { overwrite: true })
|
await fs.move(oldPath, newPath)
|
||||||
newList.push(newName)
|
newList.push(newName)
|
||||||
frameCount++
|
frameCount++
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -330,7 +335,7 @@ async function randomSort (list, pattern, realtime) {
|
||||||
console.log(`Renaming ${list[i]} -> ${newName}`)
|
console.log(`Renaming ${list[i]} -> ${newName}`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.move(oldPath, newPath, { overwrite : true })
|
await fs.move(oldPath, newPath)
|
||||||
newList.push(newName)
|
newList.push(newName)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
@ -354,7 +359,8 @@ async function render (output, avconv) {
|
||||||
let h264 = `-vcodec libx264 -g 1 -crf 25 -pix_fmt yuv420p`
|
let h264 = `-vcodec libx264 -g 1 -crf 25 -pix_fmt yuv420p`
|
||||||
let prores = `-c:v prores_ks -profile:v 3`
|
let prores = `-c:v prores_ks -profile:v 3`
|
||||||
let format = (output.indexOf('.mov') !== -1) ? prores : h264
|
let format = (output.indexOf('.mov') !== -1) ? prores : h264
|
||||||
const cmd = `${exe} -r 24 -f image2 -s ${resolution} -i ${frames} ${format} -y ${output}`
|
let framerate = `24`
|
||||||
|
const cmd = `${exe} -r ${framerate} -f image2 -s ${resolution} -i ${frames} ${format} -y ${output}`
|
||||||
|
|
||||||
console.log(`Exporting video ${output}`)
|
console.log(`Exporting video ${output}`)
|
||||||
console.log(cmd)
|
console.log(cmd)
|
||||||
|
@ -442,8 +448,6 @@ async function main (arg) {
|
||||||
return process.exit(5)
|
return process.exit(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
await delay(2000)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await render(output, avconv)
|
await render(output, avconv)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -452,7 +456,7 @@ async function main (arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//await clear()
|
await clear()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return process.exit(7)
|
return process.exit(7)
|
||||||
|
|
Loading…
Reference in New Issue