Skip to content

Commit

Permalink
Merge pull request gordon-cs#130 from sillsdev/fix-transition-time
Browse files Browse the repository at this point in the history
Fix transition time
  • Loading branch information
chrisvire authored Jun 28, 2022
2 parents fc8044b + ff39ba0 commit a0f4508
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func MergeTempVideos(Images []string, Transitions []string, TransitionDurations
fmt.Printf("%dth merge has transition %s and duration %f\n", i, transition, transition_duration)
}
//add time to the video that is sacrificied to xfade
settb += fmt.Sprintf("[%d:v]tpad=stop_mode=clone:stop_duration=%f[v%d];", i, transition_duration/2, i)
settb += fmt.Sprintf("[%d:v]tpad=stop_mode=clone:stop_duration=%f[v%d];", i, transition_duration, i)

//get the current video length in seconds
video_each_length[i] = GetVideoLength(fmt.Sprintf(path.Join(tempPath, "temp%d-%d.mp4"), i, totalNumImages))
Expand Down Expand Up @@ -415,5 +415,15 @@ func GetVideoLength(inputPath string) float64 {
output, err := cmd.CombinedOutput()
CheckCMDError(output, err)

return ParseVideoLength(string(output))
var value float64
if strings.Contains(cmd.Path, "ffprobe") {
length, err := strconv.ParseFloat(strings.TrimSpace(string(output)), 64)
if err != nil {
log.Fatal(err)
}
value = length
} else {
value = ParseVideoLength(string(output))
}
return value
}
20 changes: 10 additions & 10 deletions src/ffmpeg/ffmpeg_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ func CmdTrimLengthOfVideo(duration string, tempPath string) *exec.Cmd {
exectauble command
*/
func CmdGetVideoLength(inputPath string) *exec.Cmd {
// cmd := exec.Command("ffprobe",
// "-v", "error",
// "-show_entries", "format=duration",
// "-of", "default=noprint_wrappers=1:nokey=1",
// inputPath,
// )
cmd := exec.Command("ffmpeg",
"-hide_banner",
"-i", inputPath,
"-f", "null", "-",
cmd := exec.Command("ffprobe",
"-v", "error",
"-show_entries", "format=duration",
"-of", "default=noprint_wrappers=1:nokey=1",
inputPath,
)
// cmd := exec.Command("ffmpeg",
// "-hide_banner",
// "-i", inputPath,
// "-f", "null", "-",
// )

return cmd
}
Expand Down

0 comments on commit a0f4508

Please sign in to comment.