Skip to content
Notifications
Clear all

Walkthrough: How I add custom watermarks post-Opus using FFmpeg script.

1 Posts
1 Users
0 Reactions
1 Views
(@data_pipeline_rookie_43)
Reputable Member
Joined: 2 months ago
Posts: 131
Topic starter   [#14614]

Hey everyone! I've been using Opus Clip to chop up my long-form videos into shorts, which is awesome, but I hit a snag right away. Opus doesn't let you add a custom watermark to the clipped outputs, and I really need my little logo in the corner for branding.

After poking around the community here, I saw a few people mention FFmpeg as a solution, so I dove in. I'm pretty new to this data pipeline/automation stuff—I usually live in SQL and Python for ETL—so this was a fun (and sometimes frustrating) side quest. I finally got a simple script working to batch process my Opus clips.

Here's the basic FFmpeg command I wrapped in a Python script. It overlays a PNG watermark in the bottom-right corner, with a little padding. The key for me was making sure it worked for all the different vertical/short-form aspect ratios Opus spits out.

```python
import subprocess
import os

def add_watermark(input_dir, watermark_path, output_dir):
for filename in os.listdir(input_dir):
if filename.endswith(".mp4"):
input_path = os.path.join(input_dir, filename)
output_path = os.path.join(output_dir, f"watermarked_{filename}")

# FFmpeg command to overlay watermark
cmd = [
'ffmpeg',
'-i', input_path,
'-i', watermark_path,
'-filter_complex', '[1]scale=100:-1[wm];[0][wm]overlay=W-w-20:H-h-20:enable='gte(t,0)'',
'-codec:a', 'copy',
output_path
]

subprocess.run(cmd)
print(f"Processed: {filename}")

# Example usage
add_watermark('./opus_clips/', './logo.png', './final_clips/')
```

I run this after Opus does its thing. It's not fancy orchestration yet, but I'm thinking about how to slot this into an Airflow DAG or maybe a simple Prefect flow next, so the whole thing runs automatically whenever I have a new batch of clips.

Does this approach seem okay? For those more experienced with media pipelines, is there a better filter or a more efficient way to handle the scaling? Also, if anyone has ideas on how to monitor the quality or fail gracefully if a clip is corrupted, I'd love to hear it! This is my first step into this kind of post-processing.

-- rookie


rookie


   
Quote