Remove anti-piracy XML in media (.mp4,.mkv) files using ffmpeg, mkvproedit

Here's a cross-platform cleanup script (anti-anti-piracy) to sanitize .mp4 and .mkv video files by:

  • Removing all metadata (title, album, creation_time, etc.)
  • Stripping attachments (fonts, XML, logos)
  • Avoiding re-encoding (safe & fast)
  • Renaming output with .cleaned suffix

✅ Prerequisites

You'll need:

🖥️ For Windows: install via Chocolatey:

bash 复制代码
choco install ffmpeg mkvtoolnix

🐧 For Linux (Debian/Ubuntu):

bash 复制代码
sudo apt install ffmpeg mkvtoolnix mkvtoolnix-gui

🧰 Shell Script: clean_media.sh

bash 复制代码
#!/bin/bash

# Clean .mp4 and .mkv files in current directory

shopt -s nullglob
for file in *.mp4 *.mkv; do
    ext="${file##*.}"
    base="${file%.*}"
    out="${base}.cleaned.${ext}"

    echo "Cleaning: $file → $out"

    if [[ "$ext" == "mp4" ]]; then
        ffmpeg -hide_banner -loglevel error \
            -i "$file" \
            -map 0 -c copy \
            -map_metadata -1 \
            -metadata creation_time= \
            "$out"

    elif [[ "$ext" == "mkv" ]]; then
        ffmpeg -hide_banner -loglevel error \
            -i "$file" \
            -map 0 -map -0:t \
            -c copy \
            -map_metadata -1 \
            -metadata creation_time= \
            "$out"

        # Optional: clean tags and attachments more deeply
        if command -v mkvpropedit >/dev/null 2>&1; then
            mkvpropedit "$out" \
                --tags all: \
                --edit info --delete title \
                --delete-attachments all
        fi
    fi
done

🧪 Example Before vs After

Before

  • Metadata: ©nam, ©alb, title, creation_time, etc.
  • Attachments: font.ttf, logo.jpg, tracking XML
  • Tags: <plist>, site names (getwsodo.com, etc.)

After

  • All metadata removed
  • Attachments deleted
  • No visible tags in ffprobe or mkvinfo

🛡️ Final Tip: Always Test on Copies First!

  • Some media players (e.g., Plex) rely on metadata like title or chapter info.
  • Cleaned videos will play fine but may lose cosmetic info.
相关推荐
hu556679812 小时前
FFmpeg 如何合并字幕
ffmpeg
屋檐上的大修勾13 小时前
使用ffmpeg本地发布rtmp/rtsp直播流
ffmpeg
紫金修道13 小时前
【编解码】基于CPU的高性能 RTSP 多路摄像头抓帧插件:设计与实现详解
ffmpeg
雄哥00713 小时前
Windows系统下FFmpeg的安装与环境配置指南
windows·ffmpeg
ALONE_WORK13 小时前
ffmpeg-rk3568-mpp 硬件加速版本
ffmpeg·视频编解码·mpp·视频推流
历程里程碑13 小时前
Protobuf vs JSON vs XML:小白该怎么选?
xml·大数据·数据结构·elasticsearch·链表·搜索引擎·json
那个失眠的夜2 天前
Mybatis延迟加载策略
xml·java·数据库·maven·mybatis
紫金修道2 天前
【编解码】RK3588 平台基于 FFmpeg RKMPP 硬解的多路 RTSP 抓帧插件实战
ffmpeg·rkmpp
mfxcyh2 天前
基于xml、注解、JavaConfig实现spring的ioc
xml·java·spring
vortex52 天前
SOAP 协议中的 XML 外部实体注入(XXE)漏洞
xml·网络安全·渗透测试