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.
相关推荐
runner365.git2 小时前
ffmpeg8.0合入whisper,语音识别模型终于进入ffmpeg
ffmpeg·whisper·语音识别
spencer_tseng6 小时前
Stream not available [SysDictDataMapper.xml]
xml·java
小徐敲java1 天前
视频推流服务器与FFmpeg 安装配置
服务器·ffmpeg·音视频
qq_297574671 天前
MySQL迁移到瀚高数据库 常用转换函数对照表(附XML示例,直接复用)
xml·数据库·mysql
假装我不帅2 天前
ffmpeg操作mp3去除封面信息
ffmpeg
好好研究2 天前
SpringBoot整合SpringMVC
xml·java·spring boot·后端·mvc
封奚泽优3 天前
下载网页中的.m3u8视频文件
ffmpeg
Vertira3 天前
win10/10 下载并安装ffmpeg.exe 的官方详细方法 (已解决)
ffmpeg
xmRao3 天前
Qt+FFmpeg 实现音频重采样
qt·ffmpeg·音视频
从此不归路3 天前
Qt5 进阶【12】JSON/XML 数据协议处理:与后端/配置文件的对接
xml·开发语言·c++·qt·json