我有一批上传到 YouTube 的文件,现在我希望将它们备份到我的 MacBook 上。当我下载并提取音频时,我得到 *.m4a 或 *.作品:
#!/bin/sh
ID="$1"
youtube-dl -f bestaudio -x -i --audio-format best -o '%(playlist)s/%(playlist_index)s %(uploader)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list="$ID"
当文件扩展名是 m4a 时,我需要保留它并且不执行任何转换,当扩展名是 opus 时,我需要将其转换为 m4a。
如果我想转换每个文件,我可以这样做:
youtube-dl -f bestaudio -x -i --audio-format m4a -o '%(playlist)s/%(playlist_index)s %(uploader)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list="$ID"
但是无论如何都会执行转换。
当文件扩展名不是 m4a 时,如何提取并仅转换?
最佳答案
YouTube 提供的 m4a 文件通常包含不正确/不寻常的标题,因此由 youtube-dl 重写。如果您的所有软件都可以处理这些文件,只需添加 youtube-dl 选项
--fixup never
当您使用它时,要按 ID 下载 YouTube 播放列表,您只需将播放列表 ID 传递给 youtube-dl。所以,
youtube-dl (...) https://www.youtube.com/playlist?list="$ID"
最好写成
youtube-dl (...) "$ID"
,它允许您下载 Dailymotion、soundcloud 和其他播放列表,包括 YouTube 个人资料中的所有播放列表(如
youtube-dl https://www.youtube.com/user/ThirstForScience/playlists
)。
关于bash - 使用带有 yt-download 和 ffmpeg 的 bash 脚本来提取或隐藏,具体取决于格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50731609/