33 lines
818 B
Go
33 lines
818 B
Go
/*
|
|
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()
|
|
}
|