50 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package processor
import (
"log"
"os"
"os/exec"
"time"
)
// trimMKV обрезает видеофайл и возвращает название созданного нового файла.
func trimMKV(inputFile, outputFile, startTime, finishTime string) (outputFileTrimmed string) {
outputFile = time.Now().Format("15-04-05") + outputFile
cmd := exec.Command("ffmpeg",
"-i", inputFile,
"-ss", startTime,
"-to", finishTime,
"-c", "copy",
outputFile)
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
log.Println("Видео успешно обрезано")
return outputFile
}
// mergeFfmpeg объединяет видеофайлы с помощью ffmpeg
func mergeFfmpeg(f *os.File) error {
cmd := exec.Command("ffmpeg",
"-f", "concat",
"-safe", "0",
"-i", f.Name(),
"-c", "copy",
time.Now().Format("15-04-05")+"_video.mkv")
err := cmd.Run()
if err != nil {
log.Println("Ошибка исполнения запроса ffmpeg: ", err)
return err
}
log.Println("Видео успешно объединено")
return nil
}