Add base code

This commit is contained in:
2024-11-09 22:57:47 +01:00
parent 967f80d734
commit c7b40276cf
14 changed files with 975 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/*
Copyright © 2024 Matteo Schiff <matteo@underdesk.net>
*/
package video
import (
"os"
ffmpeg "github.com/u2takey/ffmpeg-go"
)
func ExtractVideo(videoFile string, audioFile string) {
if _, err := os.Stat(audioFile); err == nil {
// Audio already extracted, skip this step
return
}
// Use ffmpeg-go to extract audio at 16 kHz
ffmpeg.
Input(videoFile).
Output(audioFile, ffmpeg.KwArgs{
"ar": 16000, // Set audio sampling rate to 16 kHz
"ac": 1, // Set the number of audio channels to 1 (mono)
//"f": "segment", // Enable segmenting
//"segment_time": 600, // Split files every 600 seconds (10 minutes)
//"reset_timestamps": 1, // Reset timestamps in each segment
}).
OverWriteOutput(). // Overwrite if the output file already exists
Run()
}