Skip to content

Commit ac817b4

Browse files
committed
wip
1 parent c4eac2f commit ac817b4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/ex_webrtc_recorder/converter/ffmpeg.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule ExWebRTC.Recorder.Converter.FFmpeg do
1818
System.cmd(
1919
"ffmpeg",
2020
# FIXME: we're assuming a lot here
21-
~w(-ss #{video_start_time} -i #{video_file} -ss #{audio_start_time} -i #{audio_file} -c:v vp8 -threads 8 -b:v 1.5M -cues_to_front 1 -g 150 -c:a copy -shortest #{output_file}),
21+
~w(-ss #{video_start_time} -i #{video_file} -ss #{audio_start_time} -i #{audio_file} -c:v vp8 -b:v 1.5M -cues_to_front 1 -g 150 -c:a copy -shortest #{output_file}),
2222
stderr_to_stdout: true
2323
)
2424

@@ -58,9 +58,11 @@ defmodule ExWebRTC.Recorder.Converter.FFmpeg do
5858

5959
defp calculate_start_times(video_start_ms, audio_start_ms) do
6060
diff = abs(video_start_ms - audio_start_ms)
61-
s = div(diff, 1000)
62-
ms = rem(diff, 1000)
63-
delayed_start_time = :io_lib.format("00:00:~2..0w.~3..0w", [s, ms]) |> to_string()
61+
millis = rem(diff, 1000)
62+
seconds = div(diff, 1000) |> rem(60)
63+
minutes = div(diff, 60_000)
64+
65+
delayed_start_time = :io_lib.format("00:~2..0w:~2..0w.~3..0w", [minutes, seconds, millis]) |> to_string()
6466

6567
if video_start_ms > audio_start_ms,
6668
do: {"00:00:00.000", delayed_start_time},

0 commit comments

Comments
 (0)