mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-14 02:17:13 +08:00
fix: trimmed transcode with delayed audio start
Signed-off-by: bigcat88 <bigcat88@icloud.com>
This commit is contained in:
parent
070a391439
commit
97c682e39f
@ -743,6 +743,8 @@ class VideoFromFile(VideoInput):
|
|||||||
if to_skip >= resampled.samples:
|
if to_skip >= resampled.samples:
|
||||||
continue
|
continue
|
||||||
audio_started = True
|
audio_started = True
|
||||||
|
if duration and frame_start > start_time:
|
||||||
|
duration_cap = min(duration_cap, math.ceil((start_time + duration - frame_start) * sample_rate))
|
||||||
if to_skip:
|
if to_skip:
|
||||||
pending_audio.append(audio_frame_from_ndarray(resampled.to_ndarray()[..., to_skip:]))
|
pending_audio.append(audio_frame_from_ndarray(resampled.to_ndarray()[..., to_skip:]))
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -487,6 +487,13 @@ def test_save_to_transcode_learns_unprobed_audio_params():
|
|||||||
assert trimmed_before_audio["audio_codecs"] == []
|
assert trimmed_before_audio["audio_codecs"] == []
|
||||||
assert trimmed_before_audio["audio_seconds"] is None
|
assert trimmed_before_audio["audio_seconds"] is None
|
||||||
|
|
||||||
|
buffer.seek(0)
|
||||||
|
trimmed_crossing_audio = transcode_and_probe(VideoFromFile(buffer, start_time=11.5, duration=1))
|
||||||
|
assert trimmed_crossing_audio["frames"] == fps
|
||||||
|
assert trimmed_crossing_audio["audio_codecs"] == ["aac"]
|
||||||
|
assert trimmed_crossing_audio["video_seconds"] == pytest.approx(1.0, abs=0.05)
|
||||||
|
assert trimmed_crossing_audio["audio_seconds"] == pytest.approx(0.5, abs=0.1)
|
||||||
|
|
||||||
|
|
||||||
def test_save_to_transcode_trimmed_fragmented_mp4_keeps_audio():
|
def test_save_to_transcode_trimmed_fragmented_mp4_keeps_audio():
|
||||||
"""Fragmented mp4 (MediaRecorder, DASH/HLS-derived files) delivers audio well behind
|
"""Fragmented mp4 (MediaRecorder, DASH/HLS-derived files) delivers audio well behind
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user