fix: handle videos without audio in _trim_video_to_duration
Dead ternary 'copy' if has_audio else 'copy' always specified acodec=copy, causing FFmpeg to fail on AI-generated videos with no audio stream. Now only adds acodec=copy when an audio stream is actually present.
This commit is contained in:
1 parent
f291121531
commit
755fc3593e
1 file changed
+6
-3
@@ -907,10 +907,13 @@ class VideoService:
|
||||
|
||||
try:
|
||||
# Use stream copy when possible for fast trimming
|
||||
input_stream = ffmpeg.input(video, t=target_duration)
|
||||
output_kwargs = {"vcodec": "copy"}
|
||||
if self.has_audio_stream(video):
|
||||
output_kwargs["acodec"] = "copy"
|
||||
(
|
||||
ffmpeg
|
||||
.input(video, t=target_duration)
|
||||
.output(output, vcodec='copy', acodec='copy' if self.has_audio_stream(video) else 'copy')
|
||||
input_stream
|
||||
.output(output, **output_kwargs)
|
||||
.overwrite_output()
|
||||
.run(capture_stdout=True, capture_stderr=True, quiet=True)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user