Skip to content

Commit

Permalink
Merge pull request #41 from pppontusw/increase-timeout-further
Browse files Browse the repository at this point in the history
Increase timeout to 1 hour
  • Loading branch information
pppontusw authored Apr 21, 2024
2 parents 00c9016 + 4708add commit 5357cb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions nhltv_lib/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def concat_video(
f"ffmpeg -y -nostats -loglevel 0 -f concat -safe 0 -i "
f"{concat_list_path} -c copy {extra_args} {output_file}"
)
call_subprocess_and_raise_on_error(command, timeout=30)
call_subprocess_and_raise_on_error(command)


def cut_video(input_file: str, output_file: str, length: int) -> None:
Expand All @@ -24,7 +24,7 @@ def cut_video(input_file: str, output_file: str, length: int) -> None:
command = (
f"ffmpeg -ss 0 -i {input_file} -t {length} " f"-c copy {output_file}"
)
call_subprocess_and_raise_on_error(command, timeout=30)
call_subprocess_and_raise_on_error(command)


def get_video_length(input_file: str) -> int:
Expand All @@ -35,7 +35,7 @@ def get_video_length(input_file: str) -> int:
)

proc_out: List[bytes] = call_subprocess_and_raise_on_error(
command, timeout=30
command
)
return int(proc_out[0].split(b".")[0])

Expand All @@ -61,7 +61,7 @@ def show_video_streams(input_file: str) -> List[bytes]:
f" -select_streams v -loglevel error"
)
proc_out: List[bytes] = call_subprocess_and_raise_on_error(
command, timeout=30
command
)
return proc_out

Expand Down
6 changes: 3 additions & 3 deletions nhltv_lib/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def call_subprocess(command: str) -> subprocess.Popen:


def call_subprocess_and_get_stdout_iterator(
command: str, timeout: int = 1800
command: str, timeout: int = 3600
) -> Tuple[subprocess.Popen, Iterator[bytes]]:
"""
Starts a subprocess with command and returns the process object
Expand All @@ -36,7 +36,7 @@ def call_subprocess_and_get_stdout_iterator(
return proc, iter(stdout.splitlines())


def call_subprocess_and_report_rc(command: str, timeout: int = 1800) -> bool:
def call_subprocess_and_report_rc(command: str, timeout: int = 3600) -> bool:
"""
Calls a subprocess and returns True if the return code is 0 after it finishes
"""
Expand All @@ -55,7 +55,7 @@ def call_subprocess_and_report_rc(command: str, timeout: int = 1800) -> bool:


def call_subprocess_and_raise_on_error(
command: str, error: Callable = ExternalProgramError, timeout: int = 1800
command: str, error: Callable = ExternalProgramError, timeout: int = 3600
) -> List[bytes]:
"""
Calls subprocess with command and raises *error* if returncode is not 0
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_concat_video(mock_call_subp_and_raise):
"ffmpeg -y -nostats -loglevel 0 -f concat -safe 0 -i "
"conc.txt -c copy outp.mkv"
)
mock_call_subp_and_raise.assert_called_once_with(command, timeout=30)
mock_call_subp_and_raise.assert_called_once_with(command)


def test_concat_video_w_extraargs(mock_call_subp_and_raise):
Expand All @@ -46,19 +46,19 @@ def test_concat_video_w_extraargs(mock_call_subp_and_raise):
"ffmpeg -y -nostats -loglevel 0 -f concat -safe 0 -i "
"conc.txt -c copy btree -c outp.mkv"
)
mock_call_subp_and_raise.assert_called_once_with(command, timeout=30)
mock_call_subp_and_raise.assert_called_once_with(command)


def test_cut_video(mock_call_subp_and_raise):
cut_video("input", "output", 10800)
command = "ffmpeg -ss 0 -i input -t 10800 -c copy output"
mock_call_subp_and_raise.assert_called_once_with(command, timeout=30)
mock_call_subp_and_raise.assert_called_once_with(command)


def test_show_video_streams(mock_call_subp_and_raise):
a = show_video_streams("file")
command = "ffprobe -i file -show_streams -select_streams v -loglevel error"
mock_call_subp_and_raise.assert_called_once_with(command, timeout=30)
mock_call_subp_and_raise.assert_called_once_with(command)
assert a == [b"14401.1"]


Expand All @@ -68,7 +68,7 @@ def test_get_video_length(mock_call_subp_and_raise):
"ffprobe -v error -show_entries format=duration -of "
"default=noprint_wrappers=1:nokey=1 input"
)
mock_call_subp_and_raise.assert_called_once_with(command, timeout=30)
mock_call_subp_and_raise.assert_called_once_with(command)


def test_split_video_into_cuts(mock_call_subp):
Expand Down

0 comments on commit 5357cb4

Please sign in to comment.