diff --git a/app.py b/app.py
index fad5c3e..34c2be0 100644
--- a/app.py
+++ b/app.py
@@ -4254,6 +4254,13 @@ async def translate_clip(
print(f"❌ Translation Error: {e}")
raise HTTPException(status_code=500, detail=str(e))
+ # AI Act art. 50(2): the voice in this file was synthesised, so the file
+ # says so in a way a machine can read. Best-effort by design — see
+ # ffmpeg_utils.mark_ai_generated.
+ from ffmpeg_utils import mark_ai_generated
+ await loop.run_in_executor(
+ None, lambda: mark_ai_generated(output_path, "AI voice dubbing"))
+
# Update InMemory Jobs
if req.clip_index < len(job['result']['clips']):
job['result']['clips'][req.clip_index]['video_url'] = f"/videos/{req.job_id}/{output_filename}"
diff --git a/dashboard/src/components/TranslateModal.jsx b/dashboard/src/components/TranslateModal.jsx
index 3172941..ca8b819 100644
--- a/dashboard/src/components/TranslateModal.jsx
+++ b/dashboard/src/components/TranslateModal.jsx
@@ -130,6 +130,13 @@ export default function TranslateModal({ isOpen, onClose, onTranslate, isProcess
The audio will be dubbed with AI-generated voice in the selected language, matching the original speaker's characteristics.
+ {/* AI Act art. 50: we mark the file, the person publishing it is the
+ one who owes the audience the disclosure. Saying so here is the
+ only place they will read it. */}
+
+ The dubbed file is tagged as AI-generated content. When you publish it, disclose that the voice is synthetic.
+
+
{/* Processing State */}
{isProcessing && (
diff --git a/ffmpeg_utils.py b/ffmpeg_utils.py
index b398513..a271810 100644
--- a/ffmpeg_utils.py
+++ b/ffmpeg_utils.py
@@ -84,6 +84,55 @@ METADATA_SCRUB = ["-map_metadata", "-1", "-map_chapters", "-1",
LOUDNORM_FILTER = "loudnorm=I=-14:TP=-2.0:LRA=11"
+# AI Act art. 50(2): a provider whose system generates synthetic audio or video
+# has to mark the output in a machine-readable way. The regulation asks for the
+# marking, not for a particular standard, and the cheap one that survives every
+# player and every upload is a container tag: `ffprobe -show_format` reads it
+# back, and TikTok/Reels/YouTube ignore it. Stamped by a stream copy, so it is
+# a remux (no quality loss, ~0.2 s) and never a re-encode.
+#
+# Deliberately narrow: it goes on outputs where a machine actually synthesised
+# voice or a person (dubbing, AI actors), not on an ordinary clip, whose audio
+# and pixels are the user's own footage. Marking everything would make the tag
+# mean nothing.
+AI_DISCLOSURE = "AI-generated content produced with OpenShorts (openshorts.app)"
+
+
+def mark_ai_generated(path, detail=""):
+ """Stamp AI Act art. 50(2) machine-readable tags on a finished file.
+
+ Returns True when the file now carries the tags. Never raises: a missing
+ tag must not lose the user the video they just paid minutes for.
+ """
+ note = f"{AI_DISCLOSURE}: {detail}" if detail else AI_DISCLOSURE
+ tmp = f"{path}.aitag.mp4"
+ # `comment` and not a custom `ai_generated` key: mp4 only carries the
+ # standard iTunes-style tags, and ffmpeg drops anything else without
+ # warning (verified with ffprobe -show_entries format_tags).
+ # -map 0 because ffmpeg's default picks one stream per type: a dubbed file
+ # that ever ships two audio tracks would come back with one.
+ cmd = ["ffmpeg", "-y", "-i", path, "-map", "0", "-c", "copy",
+ "-metadata", f"comment={note}",
+ "-movflags", "+faststart", tmp]
+ try:
+ r = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
+ if r.returncode != 0 or not os.path.exists(tmp) or os.path.getsize(tmp) == 0:
+ print(f"[ai-tag] skipped for {os.path.basename(path)}: {r.stderr[-300:]}")
+ if os.path.exists(tmp):
+ os.remove(tmp)
+ return False
+ os.replace(tmp, path)
+ return True
+ except Exception as e:
+ print(f"[ai-tag] skipped for {os.path.basename(path)}: {e}")
+ if os.path.exists(tmp):
+ try:
+ os.remove(tmp)
+ except OSError:
+ pass
+ return False
+
+
def audio_encode_args():
"""AAC encode args for a delivered clip, with loudness normalisation."""
args = ["-c:a", "aac"]
diff --git a/saasshorts.py b/saasshorts.py
index 63dc715..d947424 100644
--- a/saasshorts.py
+++ b/saasshorts.py
@@ -18,7 +18,7 @@ import json
import time
import subprocess
-from ffmpeg_utils import video_encode_args, DELIVERY
+from ffmpeg_utils import video_encode_args, DELIVERY, mark_ai_generated
import httpx
from urllib.parse import urljoin
from typing import Optional, List, Dict, Callable
@@ -1458,6 +1458,10 @@ def generate_full_video(
hook_text = script.get("hook_text", "")
composite_video(talking_head, broll_clips, srt_path, hook_text, final_path)
+ # AI Act art. 50(2): actor, voice and b-roll are all synthetic here, so the
+ # file carries a machine-readable marking. Best effort, never fatal.
+ mark_ai_generated(final_path, "AI actor, AI voiceover and generated b-roll")
+
log("🎉 Video generation complete!")
# Cost estimate
diff --git a/tests/test_ffmpeg_utils.py b/tests/test_ffmpeg_utils.py
index 4d39723..1e66147 100644
--- a/tests/test_ffmpeg_utils.py
+++ b/tests/test_ffmpeg_utils.py
@@ -4,10 +4,12 @@ import pytest
import ffmpeg_utils
from ffmpeg_utils import (
+ AI_DISCLOSURE,
DELIVERY,
METADATA_SCRUB,
QUALITY,
QUALITY_FAST,
+ mark_ai_generated,
reset_encoder_cache,
video_encode_args,
)
@@ -96,3 +98,48 @@ def test_encode_args_stay_free_of_metadata_flags():
# video_encode_args a pure codec/quality list.
for tier in (QUALITY, QUALITY_FAST, DELIVERY):
assert not any(a.startswith("-map_metadata") for a in video_encode_args(tier))
+
+
+def _tiny_mp4(path):
+ subprocess.run(
+ ["ffmpeg", "-y", "-f", "lavfi", "-i", "testsrc=size=320x240:rate=10:duration=1",
+ "-f", "lavfi", "-i", "sine=frequency=440:duration=1",
+ "-c:v", "libx264", "-c:a", "aac", "-pix_fmt", "yuv420p", str(path)],
+ capture_output=True, check=True)
+
+
+def _comment_tag(path):
+ r = subprocess.run(
+ ["ffprobe", "-v", "error", "-show_entries", "format_tags=comment",
+ "-of", "default=noprint_wrappers=1:nokey=1", str(path)],
+ capture_output=True, text=True, check=True)
+ return r.stdout.strip()
+
+
+def test_ai_disclosure_survives_in_a_tag_a_machine_can_read():
+ # AI Act art. 50(2) wants the marking readable by a machine, so it has to
+ # come back out of the file. `comment` is the only tag mp4 keeps: a custom
+ # key is dropped by ffmpeg without any warning.
+ pytest.importorskip("shutil")
+ import shutil, tempfile, os
+ if not shutil.which("ffmpeg") or not shutil.which("ffprobe"):
+ pytest.skip("ffmpeg/ffprobe not installed")
+ with tempfile.TemporaryDirectory() as d:
+ p = os.path.join(d, "clip.mp4")
+ _tiny_mp4(p)
+ assert mark_ai_generated(p, "AI voice dubbing") is True
+ tag = _comment_tag(p)
+ assert AI_DISCLOSURE in tag
+ assert "AI voice dubbing" in tag
+
+
+def test_ai_disclosure_never_destroys_the_file_it_cannot_tag():
+ # The tag is a nicety; the video the user just paid minutes for is not.
+ import tempfile, os
+ with tempfile.TemporaryDirectory() as d:
+ p = os.path.join(d, "broken.mp4")
+ with open(p, "wb") as f:
+ f.write(b"not a video")
+ assert mark_ai_generated(p) is False
+ assert open(p, "rb").read() == b"not a video"
+ assert not os.path.exists(p + ".aitag.mp4")