Skip to content

Commit

Permalink
Work around issue #9 by setting framerate to 1 if it is not at least 1
Browse files Browse the repository at this point in the history
  • Loading branch information
petergeneric committed Jan 18, 2021
1 parent 50bb163 commit e172baa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ffmpegutil/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ func MuxVideoOnly(partition *ubv.UbvPartition, h264File string, mp4File string)
return
}

if videoTrack.Rate <= 0 {
log.Println("Invalid guessed Video framerate of ", videoTrack.Rate, " for ", mp4File, ". Setting to 1")
videoTrack.Rate = 1
}

cmd := exec.Command(getFfmpegCommand(), "-i", h264File, "-c", "copy", "-r", strconv.Itoa(videoTrack.Rate), "-y", "-loglevel", "warning", mp4File)

runFFmpeg(cmd)
Expand Down Expand Up @@ -46,6 +51,11 @@ func MuxAudioAndVideo(partition *ubv.UbvPartition, h264File string, aacFile stri

audioDelaySec := float64(videoTrack.StartTimecode.UnixNano()-audioTrack.StartTimecode.UnixNano()) / 1000000000.0

if videoTrack.Rate <= 0 {
log.Println("Invalid guessed Video framerate of ", videoTrack.Rate, " for ", mp4File, ". Setting to 1")
videoTrack.Rate = 1
}

cmd := exec.Command(getFfmpegCommand(), "-i", h264File, "-itsoffset", strconv.FormatFloat(audioDelaySec, 'f', -1, 32), "-i", aacFile, "-map", "0:v", "-map", "1:a", "-c", "copy", "-r", strconv.Itoa(videoTrack.Rate), "-y", "-loglevel", "warning", mp4File)

runFFmpeg(cmd)
Expand Down

0 comments on commit e172baa

Please sign in to comment.