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.
相关推荐
wpyok1689 小时前
密钥检测错误代码xml构建
xml
林开落L9 小时前
从入门到了解:Protobuf、JSON、XML 核心解析(C++ 示例)
xml·c++·json·protobuffer·结构化数据序列化机制
炼金术10 小时前
SkyPlayer v1.2.0 : AI 字幕-端侧 Whisper 实时语音识别实践
ffmpeg·openai
硫酸锌0112 小时前
使用ffmpeg合并文件夹内的所有*.mp4格式视频
ffmpeg·音视频
源文雨12 小时前
shell调用ffmpeg递归转换所有wav至flac的脚本
ffmpeg·bash·音视频·音频·unix·shell·音频编码
西部秋虫12 小时前
迷你视频会议系统(FlashMeeting)
opencv·ffmpeg·视频会议·回声抑制
介一安全1 天前
【Web安全】XML注入全手法拆解
xml·web安全·安全性测试
浩瀚之水_csdn1 天前
av_packet_alloc详解
ffmpeg
Echo_NGC22372 天前
【FFmpeg 使用指南】Part 3:码率控制策略与质量评估体系
人工智能·ffmpeg·视频·码率
xmRao2 天前
Qt+FFmpeg 实现 PCM 音频转 AAC 编码
qt·ffmpeg·pcm