![]() 超级会员
|
对LZ的脚本,看不太懂:blush; 这里说说俺的思路,仅供参考:
可以创建三个批处理,一个处理视频,一个处理音频。第三个让两个批处理“同时”运行,等视频处理完后,将两者再合并。 视频的(batch1.bat): 代码:
echo "video started" ffmpeg -i video.mp4 -b 1000000 output1.mp4 echo "video ended" exit 0 代码:
echo "audio started" ffmpeg -i audio.mp4 -b 1000000 output2.mp4 echo "audio ended" exit 0 代码:
echo "start calling audio batch..." start call batch2.bat echo "start calling video batch and wait it to finish..." start /wait call batch1.bat echo "both batch 1 and batch 2 have finished. merging two files..." ffmpeg -i video.mp4 -i audio.mp4 -filter_complex hstack output.mp4 echo "Job done!" |
||
![]() |
![]() 热心会员
|
引用:
更保险的是在 batch.bat 最后合并音视频前加一个循环等待 batch2 音频文件 ready 的检查。可以在 batch2 的最后 move 或 rename 音频文件,然后在 batch 里循环检查文件存在性。 |
|||
![]() |
![]() 超级会员
|
引用:
![]() 1)在batch2里添加一条,完成后,生成一个标志文件(比如audio_ended.txt)。也就是添加: 代码:
echo.>"audio_ended.txt" 代码:
:: Delete previous files Del *_ended.txt /Q :: Variables :: LookForFile="C:\Path\To\File.txt" SET LookForFile="audio_ended.txt" echo start calling audio batch... start call batch2.bat echo start calling video batch and wait it to finish... start /wait call batch1.bat :: For Loop: ensure another batch is also finished FOR /L %%i IN (1,1,300000) DO ( If Exist %LookForFile% ( echo merging those files ffmpeg -i video.mp4 -i audio.mp4 -filter_complex hstack output.mp4 echo "Job Done!" Pause Exit ) Else ( timeout /t 2 ) ) 此帖于 2019-10-13 00:50:06 被 midi 编辑. . 原因: 添加步骤 |
|||
![]() |
![]() 热心会员
|
引用:
:_WaitAudio if not exist %LookForFile% ( timeout /t 2 goto _WaitAudio) :_DoJob echo merging those files ffmpeg -i video.mp4 -i audio.mp4 -filter_complex hstack output.mp4 |
|||
![]() |