电脑客户端下载的B站视频,格式为.m4s
合并为.MP4或.AVI本地可以播放的格式
1)下载ffmpeg ,复制ffmpeg.exe到下载文件夹
2)创建一个.ps1格式的脚本,用任意文本编辑器打开,复制下面脚本保存
3)右键使用PowerShell运行, 等待完成后,mp4文件会输出到每个子目录
3)或者使用WIN+X键,调出PowerShell,输入 cd C:\....具体目录 ,再 .\merge.ps1
3)或者看图3,直接复制
*如果电脑有ffmpeg.exe可以修改配置区的地址变量
*如果懂ffmpeg 可以修改$pinfo.Arguments的变量
<# # # # # # #CONFIG # # # #>
$ffmpeg = ".\ffmpeg.exe"
$format= ".mp4" #mp4,avi,flv,f4v,webm,mpg,mpeg,mpe,ts...
<# # # # # # # # # # # # # #>
$pro_item=[System.Collections.ArrayList]::new()
ls -Directory|%{
if((Test-Path "$($_.FullName)\videoInfo.json") -eq $true){
$pro_item.Add($_) |Out-Null
}
}
$pro_item|%{
$js =Get-Content "$($_.FullName)\videoInfo.json" -Raw -Encoding utf8 |ConvertFrom-Json
Write-Host "找到"$js.title
$m4s_arr=ls $_.FullName *.m4s
foreach($m4s in $m4s_arr){
if($js.psobject.properties.Item($m4s.Name) -ne $null){continue}
$m4sbyte=Get-Content $m4s.FullName -Raw -Encoding Byte
$flag=0
if($m4sbyte[0..8] -ne 48){$flag++}#48=0x30='0'
if($flag -eq 0){
Set-Content $m4s.FullName -Encoding Byte -Value $m4sbyte[9..($m4sbyte.Count-1)] -Force
$js | Add-Member -MemberType NoteProperty -Name $m4s.Name -Value $true
}
}
$outfile="$($_.FullName)\$($js.title)$format"
if((Test-Path $outfile) -eq $false){
$pinfo =[System.Diagnostics.ProcessStartInfo]::new()
$pinfo.WorkingDirectory=$_.FullName
$pinfo.FileName =$ffmpeg
$pinfo.Arguments =' -i '+$m4s_arr[0].Name+' -i '+$m4s_arr[1].Name+' -codec copy '+$js.title+$format
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$p = [System.Diagnostics.Process]::new()
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
Write-Host "ffmpeg_info: $stdout"
}
ConvertTo-Json($js)| Set-Content "$($_.FullName)\videoInfo.json" -Encoding utf8 -Force
}
$size = @{label="Size_MB";expression={($_.length/1MB)}}
ls -Path './' -Filter "*$format" -Recurse |
Select-Object -Property $size,LastWriteTimeUtc,Name |Out-Host
pause