mirror of
https://github.com/radex/radmatrix.git
synced 2024-10-26 23:14:50 +00:00
convert video
This commit is contained in:
parent
1fc98118de
commit
480068fabb
7 changed files with 37 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
|||
badapple.webm
|
||||
video/
|
||||
|
|
2
firmware/.gitignore
vendored
2
firmware/.gitignore
vendored
|
@ -6,5 +6,5 @@
|
|||
src/gfx_png.h
|
||||
src/audio_sample.h
|
||||
gfx/
|
||||
gfx_output/
|
||||
video_output/
|
||||
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
|
||||
|
|
|
@ -58,7 +58,9 @@ normalized = [int((v-minValue)/vrange*255) for v in data_out]
|
|||
|
||||
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))
|
||||
|
||||
print("done!")
|
||||
|
|
15
firmware/scripts/convert.sh
Executable file
15
firmware/scripts/convert.sh
Executable file
|
@ -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")
|
||||
|
||||
# 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)
|
||||
|
||||
with open("gfx_output/gfx_len.bin", "wb") as f:
|
||||
with open("video_output/gfx_len.bin", "wb") as f:
|
||||
f.write(lengths)
|
||||
|
|
|
@ -159,7 +159,7 @@ void printSDStats(RP2040_SdVolume volume) {
|
|||
File audioFile;
|
||||
|
||||
void sd_loadAudio() {
|
||||
if (!SD.exists("/badapple/audio.bin")) {
|
||||
if (!SD.exists("byebyem/audio.bin")) {
|
||||
Serial.println("Audio not found :(");
|
||||
return;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ void sd_loadAudio() {
|
|||
audioFile.close();
|
||||
}
|
||||
|
||||
audioFile = SD.open("/badapple/audio.bin", FILE_READ);
|
||||
audioFile = SD.open("byebyem/audio.bin", FILE_READ);
|
||||
Serial.println("Audio file opened");
|
||||
|
||||
audio_stop();
|
||||
|
@ -210,7 +210,7 @@ void sd_loadNextAudio() {
|
|||
}
|
||||
|
||||
bool sd_loadGfxFrameLengths() {
|
||||
auto path = "badapple/gfx_len.bin";
|
||||
auto path = "byebyem/gfx_len.bin";
|
||||
|
||||
if (!SD.exists(path)) {
|
||||
Serial.println("Frame lengths file not found :(");
|
||||
|
@ -242,7 +242,7 @@ File gfxFile;
|
|||
uint16_t frameIdx = 0;
|
||||
|
||||
bool sd_loadGfxBlob() {
|
||||
auto path = "badapple/gfx.bin";
|
||||
auto path = "byebyem/gfx.bin";
|
||||
|
||||
if (!SD.exists(path)) {
|
||||
Serial.println("Gfx blob file not found :(");
|
||||
|
@ -257,6 +257,9 @@ bool sd_loadGfxBlob() {
|
|||
|
||||
// Returns size of frame read or -1 if error
|
||||
int32_t sd_loadNextFrame() {
|
||||
if (frameIdx > 0) {
|
||||
// return -1;
|
||||
}
|
||||
if (!gfxFile || !gfxFile.available()) {
|
||||
Serial.println("Gfx file not available");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue