Skip to content

Commit 09b2a0f

Browse files
authored
Merge branch 'main' into support-comyui-flux-loras
2 parents 5e11a89 + ae14612 commit 09b2a0f

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

.github/workflows/pr_tests_gpu.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ jobs:
177177

178178
torch_cuda_tests:
179179
name: Torch CUDA Tests
180+
needs: [check_code_quality, check_repository_consistency]
180181
runs-on:
181182
group: aws-g4dn-2xlarge
182183
container:
@@ -245,7 +246,7 @@ jobs:
245246

246247
run_examples_tests:
247248
name: Examples PyTorch CUDA tests on Ubuntu
248-
pip uninstall transformers -y && python -m uv pip install -U transformers@git+https://github.com/huggingface/transformers.git --no-deps
249+
needs: [check_code_quality, check_repository_consistency]
249250
runs-on:
250251
group: aws-g4dn-2xlarge
251252

@@ -264,6 +265,7 @@ jobs:
264265
- name: Install dependencies
265266
run: |
266267
python -m venv /opt/venv && export PATH="/opt/venv/bin:$PATH"
268+
pip uninstall transformers -y && python -m uv pip install -U transformers@git+https://github.com/huggingface/transformers.git --no-deps
267269
python -m uv pip install -e [quality,test,training]
268270
269271
- name: Environment

src/diffusers/utils/export_utils.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import struct
44
import tempfile
55
from contextlib import contextmanager
6-
from typing import List, Union
6+
from typing import List, Optional, Union
77

88
import numpy as np
99
import PIL.Image
@@ -139,8 +139,31 @@ def _legacy_export_to_video(
139139

140140

141141
def export_to_video(
142-
video_frames: Union[List[np.ndarray], List[PIL.Image.Image]], output_video_path: str = None, fps: int = 10
142+
video_frames: Union[List[np.ndarray], List[PIL.Image.Image]],
143+
output_video_path: str = None,
144+
fps: int = 10,
145+
quality: float = 5.0,
146+
bitrate: Optional[int] = None,
147+
macro_block_size: Optional[int] = 16,
143148
) -> str:
149+
"""
150+
quality:
151+
Video output quality. Default is 5. Uses variable bit rate. Highest quality is 10, lowest is 0. Set to None to
152+
prevent variable bitrate flags to FFMPEG so you can manually specify them using output_params instead.
153+
Specifying a fixed bitrate using `bitrate` disables this parameter.
154+
155+
bitrate:
156+
Set a constant bitrate for the video encoding. Default is None causing `quality` parameter to be used instead.
157+
Better quality videos with smaller file sizes will result from using the `quality` variable bitrate parameter
158+
rather than specifiying a fixed bitrate with this parameter.
159+
160+
macro_block_size:
161+
Size constraint for video. Width and height, must be divisible by this number. If not divisible by this number
162+
imageio will tell ffmpeg to scale the image up to the next closest size divisible by this number. Most codecs
163+
are compatible with a macroblock size of 16 (default), some can go smaller (4, 8). To disable this automatic
164+
feature set it to None or 1, however be warned many players can't decode videos that are odd in size and some
165+
codecs will produce poor results or fail. See https://en.wikipedia.org/wiki/Macroblock.
166+
"""
144167
# TODO: Dhruv. Remove by Diffusers release 0.33.0
145168
# Added to prevent breaking existing code
146169
if not is_imageio_available():
@@ -177,7 +200,9 @@ def export_to_video(
177200
elif isinstance(video_frames[0], PIL.Image.Image):
178201
video_frames = [np.array(frame) for frame in video_frames]
179202

180-
with imageio.get_writer(output_video_path, fps=fps) as writer:
203+
with imageio.get_writer(
204+
output_video_path, fps=fps, quality=quality, bitrate=bitrate, macro_block_size=macro_block_size
205+
) as writer:
181206
for frame in video_frames:
182207
writer.append_data(frame)
183208

0 commit comments

Comments
 (0)