利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(upload): reject attached album art as video material
Rudy Celeklif4ba7ce2b42a
diff --git a/app/services/material_upload.py b/app/services/material_upload.pyindex da2d7813..333b318b 100644--- a/app/services/material_upload.py+++ b/app/services/material_upload.py@@ -198,7 +198,9 @@ def _validate_video("-i",file_path,"-map",- "0:v:0",+ # Uppercase V excludes attached pictures/album covers. A cover+ # in an audio container is not a renderable video material.+ "0:V:0","-f","null","-",diff --git a/test/services/test_material_cover_picture.py b/test/services/test_material_cover_picture.pynew file mode 100644index 00000000..39741526--- /dev/null+++ b/test/services/test_material_cover_picture.py@@ -0,0 +1,41 @@+import shutil+import subprocess+import tempfile+import unittest+from pathlib import Path+from unittest.mock import patch++from PIL import Image++from app.services import material_upload++[email protected](shutil.which("ffmpeg"), "FFmpeg is required for media fixtures")+class TestMaterialCoverPicture(unittest.TestCase):+ def test_audio_album_cover_is_not_a_video_material(self):+ with tempfile.TemporaryDirectory() as directory:+ cover = Path(directory) / "cover.jpg"+ Image.new("RGB", (32, 32), "red").save(cover)+ media = Path(directory) / "audio-with-cover.mp4"+ subprocess.run([+ shutil.which("ffmpeg"), "-y", "-v", "error", "-f", "lavfi", "-i",+ "anullsrc=r=8000:cl=mono", "-i", str(cover), "-t", "0.2", "-map", "0:a",+ "-map", "1:v", "-c:a", "aac", "-c:v", "copy", "-disposition:v", "attached_pic", str(media),+ ], check=True, capture_output=True, timeout=20)+ with patch.object(material_upload.utils, "get_ffmpeg_binary", return_value=shutil.which("ffmpeg")):+ with self.assertRaises(material_upload.MaterialUploadError):+ material_upload._validate_video(str(media))++ def test_video_with_an_attached_cover_remains_valid(self):+ with tempfile.TemporaryDirectory() as directory:+ cover = Path(directory) / "cover.jpg"+ Image.new("RGB", (32, 32), "red").save(cover)+ media = Path(directory) / "video-with-cover.mp4"+ subprocess.run([+ shutil.which("ffmpeg"), "-y", "-v", "error", "-f", "lavfi", "-i",+ "color=c=blue:s=32x32:r=10:d=0.2", "-i", str(cover), "-map", "0:v", "-map", "1:v",+ "-c:v:0", "libx264", "-pix_fmt", "yuv420p", "-c:v:1", "copy",+ "-disposition:v:1", "attached_pic", str(media),+ ], check=True, capture_output=True, timeout=20)+ with patch.object(material_upload.utils, "get_ffmpeg_binary", return_value=shutil.which("ffmpeg")):+ material_upload._validate_video(str(media))diff --git a/test/services/test_material_upload.py b/test/services/test_material_upload.pyindex 953a8dc9..43b952f1 100644--- a/test/services/test_material_upload.py+++ b/test/services/test_material_upload.py@@ -385,7 +385,7 @@ class TestMaterialUploadService(unittest.TestCase):command = run.call_args.args[0]self.assertEqual(command[0], "/portable/imageio/ffmpeg")- self.assertIn("0:v:0", command)+ self.assertIn("0:V:0", command)self.assertIn("-xerror", command)self.assertNotIn("ffprobe", " ".join(command).lower())