合并b站缓存下载视频电脑客户端Win-PowerShell脚本

电脑客户端下载的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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值