在我的Ubuntu Linux18.04机器上,我有一大堆WMA文件(不要问),它们与另一台受DRM保护的计算机上的几个文件混在一起。后者不会播放,甚至会破坏一些玩家的软件。
是否有一种快速简便的方法来恢复整个子目录树并检测哪些WMA文件受到DRM保护?我已经看到了基于Windows和Powershell的解决方案,但是没有针对*ix的解决方案。
请注意,我不是在寻找一种(法律上令人怀疑的)方法来去除DRM保护;我只需要找出哪些DRM是受保护的,而不是一个一个地尝试它们,这样我就可以删除它们。
建议停止使用WMA,改用更合理的格式是不必要的;如果可能的话,我永远不会使用WMA。然而,支付我的餐券的人要求我支持这一点,所以我别无选择。
发布于 2021-12-22 14:57:50
是否有一种快速简便的方法来恢复整个子目录树并检测哪些WMA文件受到DRM保护?
好的!您需要的是提供任何类型的程序来检测文件是否受DRM保护。递归部分很容易。您可能正在使用bash,所以这个脚本会递归、检查、打印DRM‘’ed文件;如果用rm替换echo,它也可以删除它们。
# to make bash understand **; ZSH doesn't need this
shopt -s globstar
shopt -s nocaseglob
for candidate in **/**.wma ; do
magic_command_that_fails_with_drm "${candidate}" || echo "${candidate}"
done如果您的命令行程序与这些文件可靠地崩溃,那么它可以作为magic_command_that_fails_with_drm工作。否则,尝试mplayer -really-quiet -vo null -ao pcm:fast:file=...:
#!/bin/bash
# to make bash understand **; ZSH doesn't need this
shopt -s globstar
shopt -s nocaseglob
for candidate in **/**.wma ; do
tmpfile=$(mktemp)
mplayer -really-quiet -vo null -ao "pcm:fast:file=${tmpfile}" "${candidate}" 2> /dev/null
# check whether file exists and is non-empty
if [ ! -s "${tmpfile}" ]; then
echo "${candidate}"
fi
# delete the PCM file again.
rm "${tmpfile}"
done发布于 2023-02-24 15:17:46
您可以对字符串“DRM”使用ffprobe (随ffmpeg一起提供)和grep:
find . -iname "*.wma" \
| while read -r f; do
ffprobe "$f" 2>&1 | grep -q ' DRM' && echo "$f";
done或者和一条线一样:
find . -iname "*.wma" | while read -r f; do ffprobe "$f" 2>&1 | grep -q ' DRM' && echo "$f"; donehttps://unix.stackexchange.com/questions/683466
复制相似问题