Skip to content

Commit

Permalink
thumbnail name fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaipa5 committed Sep 16, 2024
1 parent cbad0f4 commit 74bb56a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func CreateClip(m3u8Content io.Reader, streamUrl, startTime, endTime, filename s
}

// Cut Video
if err := cutVideo(filename+"_temp.mp4", cutTimeStart, cutTimeEnd, filename+".mp4"); err != nil {
if err := cutVideo(filename+"_temp.mp4", cutTimeStart, cutTimeEnd, filename); err != nil {
return fmt.Errorf("| error | ffmpeg | video could not be cut: %v", err)
}

Expand Down
5 changes: 2 additions & 3 deletions ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package hlsClipper
import (
"fmt"
"os/exec"
"path/filepath"
)

// FFmpeg - segment merger
Expand All @@ -14,7 +13,7 @@ func mergeSegments(concatFile, outputFile string) error {

// FFmpeg - video cutter
func cutVideo(inputFile, startTime, endTime, outputFile string) error {
cmd := exec.Command("ffmpeg", "-i", tmpPath+inputFile, "-ss", startTime, "-to", endTime, "-c", "copy", clipsPath+outputFile)
cmd := exec.Command("ffmpeg", "-i", tmpPath+inputFile, "-ss", startTime, "-to", endTime, "-c", "copy", clipsPath+outputFile+".mp4")
if err := cmd.Run(); err != nil {
return err
}
Expand All @@ -26,7 +25,7 @@ func cutVideo(inputFile, startTime, endTime, outputFile string) error {

//Create thumbnail
if createThumbnail {
thumbCmd := exec.Command("ffmpeg", "-i", clipsPath+outputFile, "-ss", "00:00:02", "-vf", "scale=640:360", "-vframes", "1", clipsPath+filepath.Base(outputFile)+"_thumb.jpg")
thumbCmd := exec.Command("ffmpeg", "-i", clipsPath+outputFile+".mp4", "-ss", "00:00:02", "-vf", "scale=640:360", "-vframes", "1", clipsPath+outputFile+"_thumb.jpg")
err := thumbCmd.Run()
if err != nil {
return fmt.Errorf("| error | ffmpeg | thumbnail could not be created | %v", err)
Expand Down

0 comments on commit 74bb56a

Please sign in to comment.