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.
相关推荐
qq_589568102 小时前
idea中.xml文件的块注释快捷键
xml·java·intellij-idea
东东今天敲代码了吗5 小时前
Ubuntu20.04 离线安装 FFmpeg 静态编译包
linux·运维·服务器·ubuntu·ffmpeg
一杯科技拿铁18 小时前
从 XML 到 JSON,再到 CBOR:数据交换格式的演进之路
xml·json
还算善良_18 小时前
【乐企板式文件生成工程】关于乐企板式文件(PDF/OFD/XML)生成工程介绍
xml·pdf
Mr Aokey19 小时前
注解退散!纯XML打造MyBatis持久层的终极形态
xml·java·mybatis
_oP_i1 天前
wps创建编辑excel customHeight 属性不是标准 Excel Open XML导致比对异常
xml·excel·wps
BuHuaX2 天前
Unity_数据持久化_IXmlSerializable接口
xml·unity·c#·游戏引擎·游戏策划
feiyangqingyun2 天前
Qt结合ffmpeg实现图片参数调节/明亮度对比度饱和度设置/滤镜的使用
qt·ffmpeg·明亮度饱和度对比度
学而知不足~2 天前
FFmpeg02:常用命令实战
ffmpeg