Skip to content

Commit a4163eb

Browse files
committed
feat: improve ffmpeg audio handling, adjust dependencies
- Add conditional check for valid audio files in ffmpeg command. - Update opencv-python and numpy versions in requirements. - Remove redundant dependency update section from README.
1 parent 72e7923 commit a4163eb

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ pip install ruff
122122
ruff check .
123123
```
124124

125-
### Dependency Updates
126-
127-
Dependabot is configured to check for updates weekly (pip) and monthly (actions).
128-
129125
## Running Tests
130126

131127
Unit tests live in the `tests/` folder. Run them with:

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cupy-cuda12x>=13.0.0
22
moviepy==2.2.1
3-
numpy<3.0.0
4-
opencv-python==4.12.0.88
3+
numpy<2.0.0
4+
opencv-python==4.9.0.80
55
pytest==9.0.2
66
python-dotenv==1.2.1
77
random2==1.0.2

shorts.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,14 @@ def render_video_gpu(
10191019
"-pix_fmt", "rgb24",
10201020
"-r", f"{fps}",
10211021
"-i", "-",
1022-
"-i", str(temp_audio),
1022+
]
1023+
1024+
has_valid_audio = temp_audio.exists() and temp_audio.stat().st_size > 0
1025+
1026+
if has_valid_audio:
1027+
cmd_ffmpeg.extend(["-i", str(temp_audio)])
1028+
1029+
cmd_ffmpeg.extend([
10231030
"-c:v", "hevc_nvenc", # Use hardware encoder
10241031
"-preset", "p7",
10251032
"-tune", "hq",
@@ -1030,14 +1037,12 @@ def render_video_gpu(
10301037
"-pix_fmt", "yuv420p",
10311038
"-g", f"{int(fps * 2)}",
10321039
"-bf", "2",
1033-
"-c:a", "aac",
1034-
"-b:a", "192k",
1035-
"-shortest",
1036-
str(output_path)
1037-
]
1040+
])
1041+
1042+
if has_valid_audio:
1043+
cmd_ffmpeg.extend(["-c:a", "aac", "-b:a", "192k"])
10381044

1039-
if not temp_audio.exists():
1040-
cmd_ffmpeg = [x for x in cmd_ffmpeg if x not in ["-i", str(temp_audio), "-c:a", "aac"]]
1045+
cmd_ffmpeg.extend(["-shortest", str(output_path)])
10411046

10421047
# redirect stderr to a file to prevent buffer deadlock
10431048
log_path = output_path.with_suffix(".ffmpeg.log")

0 commit comments

Comments
 (0)