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.
相关推荐
Android技术之家1 天前
实测:Jetpack Compose 替代 XML 布局,3 步实现高性能界面迁移
xml
一点晖光1 天前
centos安装ffmpeg环境
linux·ffmpeg·centos
汐ya~1 天前
提示词工程:AI 总误解指令?用XML标签提升3倍准确率
xml·人工智能·prompt·提示词工程·大模型llm
hahjee1 天前
libxslt XSLT转换库:鸿蒙PC上的XML转换工具
xml·华为·harmonyos
炒毛豆1 天前
前端直播开发入门:搞懂推流拉流,掌握播放器核心
ffmpeg
八月的雨季 最後的冰吻1 天前
FFmepg-- 32-ffplay源码- PacketQueue 的线程安全机制 以及 serial 字段的作用
安全·ffmpeg
凯新生物2 天前
mPEG-SS-PLGA-DTX:智能药物递送系统
eureka·flink·ffmpeg·etcd
学而知不足~2 天前
字幕转码杂记
ffmpeg
飞睿科技2 天前
ESP Audio Effects音频库迎来专业升级,v1.2.0 新增动态控制核心
人工智能·物联网·ffmpeg·智能家居·语音识别·乐鑫科技·esp