批量转换b站下载视频电脑版

电脑客户端下载的B站视频,格式为.m4s  合并为.MP4或.AVI

使用win10 win11自带的powershell控制台

1)下载ffmpeg ,复制ffmpeg.exe到下载目录

2)WIN+X键,选择PowerShell,输入 cd  下载目录

3)复制以下整段代码到控制台,然后等待

配置区可以修改格式

<# # # # # # #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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值