Compare commits

...

8 Commits

10 changed files with 216 additions and 1 deletions

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
videos
output
frames
node/node_modules
*.pth
*.pth
videos.txt

34
ffmpeg/basic/concat.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash -e
#####################################################
#
# This script will concatenate two videos in order
# and output the new video as ProRes file.
#
# Usage: bash ffmpeg/basic/concat.sh <input video 1> <input video 2> <output video>
#
#####################################################
INPUT_1=`realpath "${1}"`
INPUT_2=`realpath "${2}"`
OUTPUT="${3}"
# Check if output file extension is .mov
if [[ "${OUTPUT}" != *".mov" ]]; then
echo "Please use an .mov extension on your output file argument"
exit 2
fi
echo "file '${INPUT_1}'" > videos.txt
echo "file '${INPUT_2}'" >> videos.txt
ffmpeg -f concat \
-safe 0 \
-i videos.txt \
-c:v prores_ks \
-profile:v 3 \
-c:a aac \
"${OUTPUT}"
# cleanup file list
rm -f videos.txt

BIN
img/normanlewisuntitled.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -0,0 +1,10 @@
#!/bin/bash
#https://github.com/processing/processing/wiki/Command-Line
# processing-java requires the full path of the sketch
SKETCH=`realpath ./processing/example-sketch`
# pass all arguments on bash script example-sketch.pde sketch
processing-java --sketch="${SKETCH}" --run \
"${@}"

View File

@ -0,0 +1,46 @@
//Input should be .jpg or .png
String input = "";
String output = "";
PImage inputImage;
PGraphics canvas;
void setup() {
if (args != null) {
if (args.length > 0 && args[0] != null) {
input = args[0];
} else {
println("No input argument provided");
exit();
}
if (args.length > 1 && args[1] != null) {
output = args[1];
} else {
exit();
}
} else {
println("No arguments provided");
exit();
}
//don't show the processing window
surface.setVisible(false);
//only draw script once
noLoop();
//use psuedo-random generator
randomSeed(50);
}
void draw () {
inputImage = loadImage(input);
canvas = createGraphics(inputImage.width, inputImage.height);
canvas.image(inputImage, 0, 0);
/************************
* Do cool things here!!!
************************/
canvas.save(output);
exit();
}

25
processing/movie-maker.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash -e
#####################################################
#
# This script will take all of the frames rendered
# by a processing sketch using the "saveFrame()"
# function and sticth them together into a video.
# By default frames save as
#
# Usage: bash processing/movie-maker.sh <input dir> <output video>
#
#####################################################
INPUT_DIR="${1}"
OUTPUT="${2}"
FRAMERATE=24
ffmpeg \
-f image2 \
-i "${INPUT_DIR}/screen-%04d.tif" \
-r ${FRAMERATE} \
-c:v prores_ks \
-profile:v 3 \
"${OUTPUT}"

43
processing/processing.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/bash -e
#####################################################
#
# This script will export all frames of a video and
# then loop over them by running a processing sketch
# on each one. The example provided "example-sketch"
# will output the same image provided as input in its
# current state.
#
# Usage: bash processing/processing.sh <input video> <output video>
#
#####################################################
INPUT="${1}"
OUTPUT="${2}"
# Check if output file extension is .mov
if [[ "${OUTPUT}" != *".mov" ]]; then
echo "Please use an .mov extension on your output file argument"
exit 1
fi
mkdir -p frames
mkdir -p processing-frames
ffmpeg -i "${INPUT}" frames/frame-%06d.png
FRAMES=frames/*.png
for frame in ${FRAMES}; do
echo "Processing $frame with example-sketch..."
# Run the processing sketch on every frame
bash processing/example-sketch.sh "${frame}" "processing-${frame}"
done
ffmpeg -f image2 -i processing-frames/frame-%06d.png -c:v prores_ks -profile:v 3 "${OUTPUT}"
# clean up frames folder
rm -rf frames
rm -rf processing-frames

6
python/install_neural.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash -e
#https://github.com/ProGamerGov/neural-style-pt
python3 -m pip install neural-style
neural-style -download_models ./

25
python/neural.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
INPUT="${1}"
STYLE="${2}"
OUTPUT="${3}"
mkdir -p frames
mkdir -p neural-frames
ffmpeg -i "${INPUT}" frames/frame-%06d.png
FRAMES=frames/*.png
for frame in ${FRAMES}; do
echo "Running style transfer $frame -> neural-$frame ..."
bash python/style_transfer.sh "${frame}" "${STYLE}" "neural-${frame}"
done
sleep 10
ffmpeg -f image2 -i frames/neural-frame-%06d.png -c:v prores_ks -profile:v 3 "${OUTPUT}"
# cleanup frames directories when done
rm -rf frames
#rm -rf neural-frames

24
python/style_transfer.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
INPUT="${1}"
STYLE="${2}"
OUTPUT="${3}"
# https://github.com/ProGamerGov/neural-style-pt
neural-style \
-style_image "${STYLE}" \
-content_image "${INPUT}" \
-output_image "${OUTPUT}" \
-model_file python/nin_imagenet.pth \
-gpu c \
-backend nn \
-num_iterations 500 \
-seed 123 \
-content_layers relu0,relu3,relu7,relu12 \
-style_layers relu0,relu3,relu7,relu12 \
-content_weight 10 \
-style_weight 500 \
-save_iter 0 \
-image_size 720 \
-optimizer adam