PowerShell 多平台一键生成 Blu-ray Live 分轨
前言
本人 n 年前的需求,需要自动化的将 Blu-ray Live 转换成 FLAC 格式的文件(自听&发种)。
⚠️ 注意:本脚本仅支持输出 flac !
前提
- 计算机安装有 PowerShell (Windows 已内置) Linux 、 MacOS 自行下载安装
- 计算机安装有 ffmpeg (Windows 需要添加到 Path 路径中)Linux 、 MacOS 通过软件源或使用 make 编译安装
用法
将下面脚本放在一个文件夹中,并在该文件夹启动 PowerShell 终端,然后输入以下命令
. .\Get-SplitedBDAudioTrack.ps1 ; Get-SplitedBDAudioTrack -a 01.flac -c 1.txt -o "E:\PPP 7th\Demux"
-a 是 eac3to 生成的 [code]flac[/code] 或者 wav 的路径
-c 是 eac3to 生成的章节文件的路径
-o 是输出文件夹
代码
#使用记事本另存为 Get-SplitedBDAudioTrack.ps1 编码为 UTF-8
function Get-SplitedBDAudioTrack {
[CmdletBinding()]
param (
[Parameter(
Mandatory = $true,
Position = 0,
HelpMessage = "Path to one or more locations.")]
[ValidateNotNullOrEmpty()]
[alias("a")]
[string]
$AudioTrackPath,
[Parameter(
Position = 1,
HelpMessage = "Path to one or more locations.")]
[ValidateNotNullOrEmpty()]
[alias("c")]
[string]
$ChaptersFilePath,
[Parameter(
Mandatory = $true,
Position = 2,
HelpMessage = "Path to one or more locations.")]
[ValidateNotNullOrEmpty()]
[alias("o")]
[string]
$OutputDirectory
)
process {
$ChaptersFile = Get-Content $ChaptersFilePath
if (-not $ChaptersFile[0].StartsWith("CHAPTER")) {
Write-Error -Message "Not a chapters file.";
return 1;
}
$Chapters = New-Object 'System.Collections.Generic.Dictionary[[int],[string]]'
$j = 0;
for ($i = 0; $i -lt $ChaptersFile.Length; $i++) {
$Chapters.Add((++$j), $ChaptersFile[$i].Split("=")[1]);
$i++;
}
for ($i = 1; $i -le $j; $i++) {
if ($i + 1 -gt $j) {
ffmpeg -ss $Chapters[$i] -i $AudioTrackPath -acodec flac ($OutputDirectory + "\" + $i.ToString("00") + ".flac")
break;
}
ffmpeg -ss $Chapters[$i] -to $Chapters[$i + 1] -i $AudioTrackPath -acodec flac ($OutputDirectory + "\" + $i.ToString("00") + ".flac")
}
}
}
本文作者:Aoba_xu
本文链接:https://www.cnblogs.com/aobaxu/p/16217308.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步