Fix a few cases where ffmpeg produces no output (#3161)

* Treat no output from ffmpeg as an error condition
* Distinguish file vs. video duration, and use later where appropriate
* Check for empty file in generateFile

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
alexandra-3
2022-11-21 16:21:27 +10:00
committed by GitHub
parent 045ba55def
commit abc9ec648a
6 changed files with 44 additions and 20 deletions

View File

@@ -43,8 +43,8 @@ func (g *generatorInfo) calculateFrameRate(videoStream *ffmpeg.FFProbeStream) er
numberOfFrames, _ := strconv.Atoi(videoStream.NbFrames)
if numberOfFrames == 0 && isValidFloat64(framerate) && g.VideoFile.Duration > 0 { // TODO: test
numberOfFrames = int(framerate * g.VideoFile.Duration)
if numberOfFrames == 0 && isValidFloat64(framerate) && g.VideoFile.VideoStreamDuration > 0 { // TODO: test
numberOfFrames = int(framerate * g.VideoFile.VideoStreamDuration)
}
// If we are missing the frame count or frame rate then seek through the file and extract the info with regex
@@ -68,7 +68,7 @@ func (g *generatorInfo) calculateFrameRate(videoStream *ffmpeg.FFProbeStream) er
"number of frames or framerate is 0. nb_frames <%s> framerate <%f> duration <%f>",
videoStream.NbFrames,
framerate,
g.VideoFile.Duration,
g.VideoFile.VideoStreamDuration,
)
}