diff options
author | Andrew Cady <d@jerkface.net> | 2022-12-26 03:23:11 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-12-26 03:23:49 -0500 |
commit | 985fcc318c4445486b36707e39086d90ce83944e (patch) | |
tree | f1442f64323e09955ce9c2ed561598bcdc499e6f | |
parent | 8923afcacc6ba3be381f6770ead8c2d09431b1fd (diff) |
fix the outstanding bugs -- re-encoding works!
-rw-r--r-- | vmail/htdocs/index.html | 10 | ||||
-rw-r--r-- | vmail/src/WebApp.hs | 16 |
2 files changed, 14 insertions, 12 deletions
diff --git a/vmail/htdocs/index.html b/vmail/htdocs/index.html index 69bd2fd..c8f6e19 100644 --- a/vmail/htdocs/index.html +++ b/vmail/htdocs/index.html | |||
@@ -364,13 +364,11 @@ stopRecordingButton.onclick = function() { | |||
364 | saveRecordingButton.onclick = function() { | 364 | saveRecordingButton.onclick = function() { |
365 | this.disabled = true; | 365 | this.disabled = true; |
366 | var onSuccess = function (url) { window.location.href = url; } | 366 | var onSuccess = function (url) { window.location.href = url; } |
367 | var onError = function () { return; } | 367 | var onError = function () { saveRecordingButton.disabled = false; } |
368 | var uuid = fileBaseName | 368 | var uuid = fileBaseName |
369 | var regex = /#t=([0-9.]+),([0-9.]+)$/ | 369 | var start = video.beginTime |
370 | var matches = video.src.match(regex) | 370 | var stop = video.endTime |
371 | if (matches && matches.length == 3) { | 371 | if (start && stop) { |
372 | var start = matches[1] | ||
373 | var stop = matches[2] | ||
374 | postMessageByUuidSaveByStartByEnd(uuid, start, stop, onSuccess, onError); | 372 | postMessageByUuidSaveByStartByEnd(uuid, start, stop, onSuccess, onError); |
375 | } else { | 373 | } else { |
376 | postMessageByUuidSaveByStartByEnd(uuid, 0, 0, onSuccess, onError); | 374 | postMessageByUuidSaveByStartByEnd(uuid, 0, 0, onSuccess, onError); |
diff --git a/vmail/src/WebApp.hs b/vmail/src/WebApp.hs index 2acc0fe..7fbd1c4 100644 --- a/vmail/src/WebApp.hs +++ b/vmail/src/WebApp.hs | |||
@@ -369,20 +369,24 @@ saveVideoClip :: FilePath -> [FilePath] -> Float -> Float -> IO () | |||
369 | saveVideoClip outputFile inputChunks _ stopTime | stopTime == 0 = do | 369 | saveVideoClip outputFile inputChunks _ stopTime | stopTime == 0 = do |
370 | let cmdScript = "cat \"$@\" > \"$output\"" :: String | 370 | let cmdScript = "cat \"$@\" > \"$output\"" :: String |
371 | cmd_ (AddEnv "output" outputFile) | 371 | cmd_ (AddEnv "output" outputFile) |
372 | (["sh", "-c", cmdScript, "sh"] ++ inputChunks) | 372 | (["sh", "-xc", cmdScript, "sh"] ++ inputChunks) |
373 | saveVideoClip outputFile inputChunks startTime stopTime = do | 373 | saveVideoClip outputFile inputChunks startTime stopTime = do |
374 | let cmdScript = "cat \"$@\" | ffmpeg -i - -c:v libvpx -c:a libvorbis -preset ultrafast -ss \"$start\" -t \"$stop\" \"$output\"" :: String | 374 | -- let cmdScript = "printf '%s\n' \"$@\" | sort -n | xargs cat | ffmpeg -i - -c:v libx264 -f mp4 -ss \"$start\" -t \"$stop\" \"$output\"" :: String |
375 | let cmdScript = "printf '%s\n' \"$@\" | sort -n | xargs cat | ffmpeg -i - -c:v libvpx -c:a libvorbis -ss \"$start\" -t \"$stop\" \"$output\"" :: String | ||
375 | cmd_ (AddEnv "start" $ show startTime) | 376 | cmd_ (AddEnv "start" $ show startTime) |
376 | (AddEnv "stop" $ show (stopTime - startTime)) | 377 | (AddEnv "stop" $ show (stopTime - startTime)) |
377 | (AddEnv "output" outputFile) | 378 | (AddEnv "output" outputFile) |
378 | (["sh", "-c", cmdScript, "sh"] ++ inputChunks) | 379 | (["sh", "-xc", cmdScript, "sh"] ++ inputChunks) |
379 | 380 | ||
380 | saveMessage :: HandlerG SaveMessageApi | 381 | saveMessage :: HandlerG SaveMessageApi |
381 | saveMessage addr uuid start stop = do | 382 | saveMessage addr uuid start stop = do |
382 | let inputDir = "./blobs" </> show uuid | 383 | let inputDir = "./blobs" </> show uuid |
383 | let outputFile = "./htdocs" </> show uuid ++ ".webm" | 384 | -- let outputExtension = "mp4" |
384 | let tempFile = outputFile ++ "~tmp.webm" | 385 | let outputExtension = "webm" |
385 | let outputUrl = unpack (toUrlPiece $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy StaticApi)) </> show uuid ++ ".webm" | 386 | let outputFile = "./htdocs" </> show uuid ++ "." ++ outputExtension |
387 | let tempFile = outputFile ++ "~tmp." ++ outputExtension | ||
388 | let currentUrl = unpack . toUrlPiece $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy StaticApi) | ||
389 | let outputUrl = currentUrl </> show uuid ++ "." ++ outputExtension | ||
386 | now <- liftIO getCurrentTime | 390 | now <- liftIO getCurrentTime |
387 | g <- queryG | 391 | g <- queryG |
388 | let changes :: [MessageChange] | 392 | let changes :: [MessageChange] |