Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xuwx1
LightX2V
Commits
343c2cea
"scripts/vscode:/vscode.git/clone" did not exist on "c480a3f6ea1be75d683551cdc7491aef2cf312e5"
Commit
343c2cea
authored
Jul 21, 2025
by
gaclove
Browse files
Enhance array_to_video function with detailed docstring and output pixel format option
parent
397ce244
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
lightx2v/models/runners/wan/wan_audio_runner.py
lightx2v/models/runners/wan/wan_audio_runner.py
+23
-0
No files found.
lightx2v/models/runners/wan/wan_audio_runner.py
View file @
343c2cea
...
@@ -137,7 +137,27 @@ def array_to_video(
...
@@ -137,7 +137,27 @@ def array_to_video(
resolution
:
Optional
[
Union
[
Tuple
[
int
,
int
],
Tuple
[
float
,
float
]]]
=
None
,
resolution
:
Optional
[
Union
[
Tuple
[
int
,
int
],
Tuple
[
float
,
float
]]]
=
None
,
disable_log
:
bool
=
False
,
disable_log
:
bool
=
False
,
lossless
:
bool
=
True
,
lossless
:
bool
=
True
,
output_pix_fmt
:
str
=
"yuv420p"
,
)
->
None
:
)
->
None
:
"""Convert an array to a video directly, gif not supported.
Args:
image_array (np.ndarray): shape should be (f * h * w * 3).
output_path (str): output video file path.
fps (Union[int, float, optional): fps. Defaults to 30.
resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]],
optional): (height, width) of the output video.
Defaults to None.
disable_log (bool, optional): whether close the ffmepg command info.
Defaults to False.
output_pix_fmt (str): output pix_fmt in ffmpeg command.
Raises:
FileNotFoundError: check output path.
TypeError: check input array.
Returns:
None.
"""
if
not
isinstance
(
image_array
,
np
.
ndarray
):
if
not
isinstance
(
image_array
,
np
.
ndarray
):
raise
TypeError
(
"Input should be np.ndarray."
)
raise
TypeError
(
"Input should be np.ndarray."
)
assert
image_array
.
ndim
==
4
assert
image_array
.
ndim
==
4
...
@@ -175,6 +195,7 @@ def array_to_video(
...
@@ -175,6 +195,7 @@ def array_to_video(
output_path
,
output_path
,
]
]
else
:
else
:
output_pix_fmt
=
output_pix_fmt
or
"yuv420p"
command
=
[
command
=
[
"/usr/bin/ffmpeg"
,
"/usr/bin/ffmpeg"
,
"-y"
,
# (optional) overwrite output file if it exists
"-y"
,
# (optional) overwrite output file if it exists
...
@@ -194,6 +215,8 @@ def array_to_video(
...
@@ -194,6 +215,8 @@ def array_to_video(
"-"
,
# The input comes from a pipe
"-"
,
# The input comes from a pipe
"-vcodec"
,
"-vcodec"
,
"libx264"
,
"libx264"
,
"-pix_fmt"
,
f
"
{
output_pix_fmt
}
"
,
"-an"
,
# Tells FFMPEG not to expect any audio
"-an"
,
# Tells FFMPEG not to expect any audio
output_path
,
output_path
,
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment