无限制下载器下载视频,利用bat脚本使用FFmpeg合并音视频文件

kuaikan 2026-10-11 7

无限制下载器下载视频,利用bat脚本使用FFmpeg合并音视频文件

油猴脚本

点击查看代码
js
// ==UserScript==
// @name         Unlimited_downloader
// @name:zh-CN   无限制下载器
// @namespace    ooooooooo.io
// @version      0.1.9
// @description  Get video and audio binary streams directly, breaking all download limitations. (As long as you can play, then you can download!)
// @description:cmd      ffmpeg -i videoA.mp4 -i videoB.mp4 -map 0:v -map 1:a -c:v copy -c:a copy videoC.mp4
// @description:control  document.querySelector('video').playbackRate = 16
// @description:url      https://greasyfork.org/zh-CN/scripts/445751-unlimited-downloader
// @description:ffmpeg   https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
// @description:zh-Cn  直接获取视频和音频二进制流,打破所有下载限制。(只要你可以播放,你就可以下载!)
// @author       dabaisuv
// @match        *://*/*
// @exclude      https://mail.qq.com/*
// @exclude      https://wx.mail.qq.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @run-at       document-start
// ==/UserScript==

(
function () {
    'use strict';
    
console.log(`Unlimited_downloader: begin......${location.href}`);


    
//Setting it to 1 will automatically download the video after it finishes playing.
    
window.autoDownload = 1;


    
window.isComplete = 0;
    
window.audio = [];
    
window.video = [];
    
window.downloadAll = 0;
    
window.quickPlay = 1.0;

    
const _endOfStream = window.MediaSource.prototype.endOfStream
    
window.MediaSource.prototype.endOfStream = function () {
        
window.isComplete = 1;
        
return _endOfStream.apply(this, arguments)
    }
    
window.MediaSource.prototype.endOfStream.toString = function() {
        
console.log('endOfStream hook is detecting!');
        
return _endOfStream.toString();
    }

    
const _addSourceBuffer = window.MediaSource.prototype.addSourceBuffer
    
window.MediaSource.prototype.addSourceBuffer = function (mime) {
        
console.log("MediaSource.addSourceBuffer ", mime)
        
if (mime.toString().indexOf('audio') !== -1) {
            
window.audio = [];
            
console.log('audio array cleared.');
        } 
else if (mime.toString().indexOf('video') !== -1) {
            
window.video = [];
            
console.log('video array cleared.');
        }
        
let sourceBuffer = _addSourceBuffer.call(this, mime)
        
const _append = sourceBuffer.appendBuffer
        sourceBuffer.appendBuffer = 
function (buffer) {
            
console.log(mime, buffer);
            
if (mime.toString().indexOf('audio') !== -1) {
                
window.audio.push(buffer);
            } 
else if (mime.toString().indexOf('video') !== -1) {
                
window.video.push(buffer)
            }
            _append.call(
this, buffer)
        }

        sourceBuffer.appendBuffer.toString = 
function () {
            
console.log('appendSourceBuffer hook is detecting!');
            
return _append.toString();
        }
        
return sourceBuffer
    }

    
window.MediaSource.prototype.addSourceBuffer.toString = function () {
        
console.log('addSourceBuffer hook is detecting!');
        
return _addSourceBuffer.toString();
    }

    
function download() {
        
let a = document.createElement('a');
        a.href = 
window.URL.createObjectURL(new Blob(window.audio));
        a.download = 
'audio_' + document.title + '.mp4';
        a.click();
        a.href = 
window.URL.createObjectURL(new Blob(window.video));
        a.download = 
'video_' + document.title + '.mp4';
        a.click();
        
window.downloadAll = 0;
        
window.isComplete = 0;


        
// window.open(window.URL.createObjectURL(new Blob(window.audio)));
        
// window.open(window.URL.createObjectURL(new Blob(window.video)));
        
// window.downloadAll = 0

        
// GM_download(window.URL.createObjectURL(new Blob(window.audio)));
        
// GM_download(window.URL.createObjectURL(new Blob(window.video)));
        
// window.isComplete = 0;

        
// const { createFFmpeg } = FFmpeg;
        
// const ffmpeg = createFFmpeg({ log: true });
        
// (async () => {
        
//     const { audioName } = new File([new Blob(window.audio)], 'audio');
        
//     const { videoName } = new File([new Blob(window.video)], 'video')
        
//     await ffmpeg.load();
        
//     //ffmpeg -i audioLess.mp4 -i sampleAudio.mp3 -c copy output.mp4
        
//     await ffmpeg.run('-i', audioName, '-i', videoName, '-c', 'copy', 'output.mp4');
        
//     const data = ffmpeg.FS('readFile', 'output.mp4');
        
//     let a = document.createElement('a');
        
//     let blobUrl = new Blob([data.buffer], { type: 'video/mp4' })
        
//     console.log(blobUrl);
        
//     a.href = URL.createObjectURL(blobUrl);
        
//     a.download = 'output.mp4';
        
//     a.click();
        
// })()
        
// window.downloadAll = 0;
    }

    
setInterval(() => {
        
if (window.downloadAll === 1) {
            download();
        }
    }, 
2000);

    
//    setInterval(() => {
    
//        if(window.quickPlay !==1.0){
    
//              document.querySelector('video').playbackRate = window.quickPlay;
    
// }
    
//
    
//   }, 2000);

    
if (window.autoDownload === 1) {
        
let autoDownInterval = setInterval(() => {
            
//document.querySelector('video').playbackRate = 16.0;
            
if (window.isComplete === 1) {
                download();
            }
        }, 
2000);
    }

    (
function (that) {
        
let removeSandboxInterval = setInterval(() => {
            
if (that.document.querySelectorAll('iframe')[0] !== undefined) {
                that.document.querySelectorAll(
'iframe').forEach((v, i, a) => {
                    
let ifr = v;
                    
// ifr.sandbox.add('allow-popups');
                    ifr.removeAttribute(
'sandbox');
                    
const parentElem = that.document.querySelectorAll('iframe')[i].parentElement;
                    a[i].remove();
                    parentElem.appendChild(ifr);
                });
                
clearInterval(removeSandboxInterval);
            }
        }, 
1000);
    })(
window);




    
// Your code here...
})();

视频处理软件ffmpeg下载地址

下载链接 https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip

bat 文件脚本

点击查看代码
bat
@echo off
rem 原文件示例:audio_14应用1.mp4、video_14应用1.mp4
rem 输入文件名,输入"audio_14应用1"或"video_14应用1"
rem 可直接使用命令行参数方式,但需要使用引号将有空格的文件名包起来。
if "%~1"=="" (
 
set /p str=请输入合并文件名:
) 
else (
 
set str=%~1
)
rem 切割字符串文件名,切除前6个字符
set a=%str:~6%
rem 音频输出文件
set audio=audio.aac

rem ---使用临时文件方式---
rem 临时文件记录音频格式
rem set tempfile="temp.txt"
rem 判断是否为aac格式音频
rem ffprobe -hide_banner -v error -show_streams -show_entries stream=codec_name "audio_%a%.mp4"|find /I "codec">%tempfile%
rem set /p str=<./%tempfile%
rem set f=%str:~11%

rem ---使用命令行方式---
for /F %%i in ('ffprobe -hide_banner -v error -show_streams -show_entries stream^=codec_name "audio_%a%.mp4" ^| find /I "codec"') do ( set commitid=%%i)
set f=%commitid:~11%

if %f% == aac (
rem 生成音频文件
ffmpeg -i "audio_
%a%.mp4" -acodec copy %audio%
ffmpeg -i "video_
%a%.mp4" -i %audio% -map 0:v -map 1:a -c:v copy -c:a copy "%a%.mp4"
) 
else (
ffmpeg -i "video_
%a%.mp4" -i "audio_%a%.mp4" -map 0:v -map 1:a -c:v copy -c:a copy "%a%.mp4"
)

rem 每次执行完删除音频文件
if exist "audio.aac" (
 
del "audio.aac"
)
rem if exist %tempfile% (
rem  del %tempfile%
rem )
rem pause

浏览器控制台命令

document.querySelector('video').playbackRate = 16
或者使用chrome应用中的插件修改播放速度

4 替代工具

为了更高效地下载视频,你可以尝试以下工具,代替脚本+bat的方式:

让我们一起探索如何使用FFmpeg和bat脚本轻松合并音视频文件吧!

签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回