Skip to content

Commit

Permalink
upgrade ffmpeg to v4, add more debug logs (#1973)
Browse files Browse the repository at this point in the history
- fixes #1971 
- fixes #1972
  • Loading branch information
brian-mann authored Jun 18, 2018
1 parent 453313f commit 5c08e2a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
40 changes: 29 additions & 11 deletions packages/server/lib/video_capture.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
if not written
## when no data has been written this will
## result in an 'pipe:0: End of file' error
## for ffmpeg so we need to account for that
## for so we need to account for that
## and not log errors to the console
logErrors = false

Expand Down Expand Up @@ -73,15 +73,19 @@ module.exports = {
.inputOptions("-use_wallclock_as_timestamps 1")
.videoCodec("libx264")
.outputOptions("-preset ultrafast")
.on "start", (line) ->
debug("ffmpeg started")
.on "start", (command) ->
debug("capture started %o", { command })

started.resolve(new Date)
# .on "codecData", (data) ->
# console.log "codec data", data
# .on("error", options.onError)

.on "codecData", (data) ->
debug("capture codec data: %o", data)

.on "stderr", (stderr) ->
debug("capture stderr log %o", { message: stderr })

.on "error", (err, stdout, stderr) ->
debug("ffmpeg errored:", err.message)
debug("capture errored: %o", { error: err.message, stdout, stderr })

## if we're supposed log errors then
## bubble them up
Expand All @@ -94,7 +98,7 @@ module.exports = {
ended.reject(err)

.on "end", ->
debug("ffmpeg ended")
debug("capture ended")

ended.resolve()
.save(name)
Expand All @@ -117,18 +121,35 @@ module.exports = {
"-preset fast"
"-crf #{videoCompression}"
])
.on "start", (command) ->
debug("compression started %o", { command })

.on "codecData", (data) ->
debug("compression codec data: %o", data)

total = utils.timemarkToSeconds(data.duration)

.on "stderr", (stderr) ->
debug("compression stderr log %o", { message: stderr })

.on "progress", (progress) ->
## bail if we dont have total yet
return if not total

debug("compression progress: %o", progress)

progressed = utils.timemarkToSeconds(progress.timemark)

onProgress(progressed / total)

.on "error", (err, stdout, stderr) ->
debug("compression errored: %o", { error: err.message, stdout, stderr })

reject(err)

.on "end", ->
debug("compression ended")

## we are done progressing
onProgress(1)

Expand All @@ -140,7 +161,4 @@ module.exports = {
resolve()
.save(cname)

# setTimeout ->
# cmd.kill()
# , 100
}
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@cypress/commit-info": "^1.2.2",
"@cypress/icons": "0.5.4",
"@cypress/mocha-teamcity-reporter": "^1.0.0",
"@ffmpeg-installer/ffmpeg": "1.0.3",
"@ffmpeg-installer/ffmpeg": "1.0.15",
"ansi_up": "^1.3.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-latest": "^6.16.0",
Expand Down

0 comments on commit 5c08e2a

Please sign in to comment.