mirror of https://github.com/radex/radmatrix.git
convert video
parent
1fc98118de
commit
480068fabb
|
@ -1 +1 @@
|
||||||
badapple.webm
|
video/
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
src/gfx_png.h
|
src/gfx_png.h
|
||||||
src/audio_sample.h
|
src/audio_sample.h
|
||||||
gfx/
|
gfx/
|
||||||
gfx_output/
|
video_output/
|
||||||
audio/
|
audio/
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
convert video
|
## convert video
|
||||||
|
|
||||||
|
```sh
|
||||||
|
scripts/convert.sh ../badapple.webm
|
||||||
|
```
|
||||||
|
|
||||||
|
or manually:
|
||||||
|
|
||||||
```
|
```
|
||||||
ffmpeg -i ../badapple.webm -vf "fps=30,scale=40:40:force_original_aspect_ratio=increase,crop=40:40,format=gray" gfx/frame_%04d.png
|
ffmpeg -i ../badapple.webm -vf "fps=30,scale=40:40:force_original_aspect_ratio=increase,crop=40:40,format=gray" gfx/frame_%04d.png
|
||||||
|
|
|
@ -58,7 +58,9 @@ normalized = [int((v-minValue)/vrange*255) for v in data_out]
|
||||||
|
|
||||||
print("writing blob...")
|
print("writing blob...")
|
||||||
|
|
||||||
with open("audio/audio.bin", "wb") as f:
|
os.makedirs("video_output", exist_ok=True)
|
||||||
|
|
||||||
|
with open("video_output/audio.bin", "wb") as f:
|
||||||
f.write(bytes(normalized))
|
f.write(bytes(normalized))
|
||||||
|
|
||||||
print("done!")
|
print("done!")
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "converting $1"
|
||||||
|
rm -fr gfx
|
||||||
|
rm -fr video_output
|
||||||
|
rm -fr audio
|
||||||
|
mkdir gfx
|
||||||
|
ffmpeg -i "$1" -vf "fps=30,scale=40:40:force_original_aspect_ratio=increase,crop=40:40,format=gray" gfx/frame_%04d.png
|
||||||
|
python3 scripts/gfx_to_blob.py
|
||||||
|
mkdir audio
|
||||||
|
ffmpeg -i "$1" -ar 44000 audio/output.wav
|
||||||
|
python3 scripts/audio_convert.py
|
||||||
|
open video_output
|
|
@ -26,10 +26,10 @@ for (name, path) in gfx_files:
|
||||||
lengths += size.to_bytes(2, byteorder="little")
|
lengths += size.to_bytes(2, byteorder="little")
|
||||||
|
|
||||||
# create the output directory if it doesn't exist
|
# create the output directory if it doesn't exist
|
||||||
os.makedirs("gfx_output", exist_ok=True)
|
os.makedirs("video_output", exist_ok=True)
|
||||||
|
|
||||||
with open("gfx_output/gfx.bin", "wb") as f:
|
with open("video_output/gfx.bin", "wb") as f:
|
||||||
f.write(blob)
|
f.write(blob)
|
||||||
|
|
||||||
with open("gfx_output/gfx_len.bin", "wb") as f:
|
with open("video_output/gfx_len.bin", "wb") as f:
|
||||||
f.write(lengths)
|
f.write(lengths)
|
||||||
|
|
|
@ -159,7 +159,7 @@ void printSDStats(RP2040_SdVolume volume) {
|
||||||
File audioFile;
|
File audioFile;
|
||||||
|
|
||||||
void sd_loadAudio() {
|
void sd_loadAudio() {
|
||||||
if (!SD.exists("/badapple/audio.bin")) {
|
if (!SD.exists("byebyem/audio.bin")) {
|
||||||
Serial.println("Audio not found :(");
|
Serial.println("Audio not found :(");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ void sd_loadAudio() {
|
||||||
audioFile.close();
|
audioFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
audioFile = SD.open("/badapple/audio.bin", FILE_READ);
|
audioFile = SD.open("byebyem/audio.bin", FILE_READ);
|
||||||
Serial.println("Audio file opened");
|
Serial.println("Audio file opened");
|
||||||
|
|
||||||
audio_stop();
|
audio_stop();
|
||||||
|
@ -210,7 +210,7 @@ void sd_loadNextAudio() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sd_loadGfxFrameLengths() {
|
bool sd_loadGfxFrameLengths() {
|
||||||
auto path = "badapple/gfx_len.bin";
|
auto path = "byebyem/gfx_len.bin";
|
||||||
|
|
||||||
if (!SD.exists(path)) {
|
if (!SD.exists(path)) {
|
||||||
Serial.println("Frame lengths file not found :(");
|
Serial.println("Frame lengths file not found :(");
|
||||||
|
@ -242,7 +242,7 @@ File gfxFile;
|
||||||
uint16_t frameIdx = 0;
|
uint16_t frameIdx = 0;
|
||||||
|
|
||||||
bool sd_loadGfxBlob() {
|
bool sd_loadGfxBlob() {
|
||||||
auto path = "badapple/gfx.bin";
|
auto path = "byebyem/gfx.bin";
|
||||||
|
|
||||||
if (!SD.exists(path)) {
|
if (!SD.exists(path)) {
|
||||||
Serial.println("Gfx blob file not found :(");
|
Serial.println("Gfx blob file not found :(");
|
||||||
|
@ -257,6 +257,9 @@ bool sd_loadGfxBlob() {
|
||||||
|
|
||||||
// Returns size of frame read or -1 if error
|
// Returns size of frame read or -1 if error
|
||||||
int32_t sd_loadNextFrame() {
|
int32_t sd_loadNextFrame() {
|
||||||
|
if (frameIdx > 0) {
|
||||||
|
// return -1;
|
||||||
|
}
|
||||||
if (!gfxFile || !gfxFile.available()) {
|
if (!gfxFile || !gfxFile.available()) {
|
||||||
Serial.println("Gfx file not available");
|
Serial.println("Gfx file not available");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue