Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
jwong-nd committed Nov 8, 2024
1 parent 7a793a2 commit f09ae14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/aind_behavior_video_transformation/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ def _run_compression(
for params in convert_video_args
]
for job in as_completed(jobs):
out_path, error = job.result()
if error:
error_traces.append(error)
result = job.result()
if isinstance(result, tuple):
error_traces.append(result[1])
else:
logging.info(f"FFmpeg job completed: {out_path}")
logging.info(f"FFmpeg job completed: {result}")
else:
# Execute serially
for params in convert_video_args:
out_path, error = convert_video(
result = convert_video(
*params, self.job_settings.ffmpeg_thread_cnt
)
if error:
error_traces.append(error)
if isinstance(result, tuple):
error_traces.append(result[1])
else:
logging.info(f"FFmpeg job completed: {out_path}")
logging.info(f"FFmpeg job completed: {result}")

if error_traces:
for e in error_traces:
Expand Down
6 changes: 3 additions & 3 deletions src/aind_behavior_video_transformation/transform_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from os import symlink
from pathlib import Path
from subprocess import CalledProcessError
from typing import Optional, Tuple
from typing import Optional, Tuple, Union

from pydantic import BaseModel, Field

Expand Down Expand Up @@ -190,7 +190,7 @@ def convert_video(
output_dir: Path,
arg_set: Optional[Tuple[str, str]],
ffmpeg_thread_cnt: int = 0,
) -> tuple[str, Optional[str]]:
) -> Union[str, Tuple[str, str]]:
"""
Converts a video to a specified format using ffmpeg.
Expand Down Expand Up @@ -245,7 +245,7 @@ def convert_video(
subprocess.run(
ffmpeg_command, check=True, capture_output=True, text=True
)
return (str(out_path), None)
return str(out_path)

except CalledProcessError as e:
error_msg = (
Expand Down

0 comments on commit f09ae14

Please sign in to comment.