{"id":3215,"date":"2026-03-14T18:14:53","date_gmt":"2026-03-14T10:14:53","guid":{"rendered":"https:\/\/www.xfan.top\/?p=3215"},"modified":"2026-03-19T21:12:06","modified_gmt":"2026-03-19T13:12:06","slug":"ffmpeg-%e6%9b%bf%e6%8d%a2%e9%9f%b3%e9%a2%91%e6%b5%81-bat","status":"publish","type":"post","link":"https:\/\/www.xfan.top\/index.php\/2026\/03\/14\/3215\/","title":{"rendered":"ffmpeg \u66ff\u6362\u97f3\u9891\u6d41.bat"},"content":{"rendered":"\n<p>\u529f\u80fd\uff1a\u5c06<kbd>\u89c6\u9891.mp4<\/kbd>\u7684\u97f3\u9891\u6d41\u66ff\u6362\u4e3a<kbd>\u97f3\u9891.wav<\/kbd><br>\u4e3b\u8981\u9002\u7528\u4e8epcm\u97f3\u9891\u6d41\u3001avi\u5c01\u88c5\u7684\u89c6\u9891\u6587\u4ef6\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7528\u6cd5: \u62d6\u62fd\u4e24\u4e2a\u6587\u4ef6\u5230\u672c\u811a\u672c\u4e0a<br>\u6216\u8005\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528:<br>\u66ff\u6362\u97f3\u9891\u6d41.bat \"\u89c6\u9891.mp4\" \"\u97f3\u9891.wav\"<\/p>\n\n\n\n<p>\u8f93\u51fa\u6587\u4ef6\u5c06\u81ea\u52a8\u751f\u6210\u5728\u89c6\u9891\u540c\u76ee\u5f55\u4e0b\uff0c\u6587\u4ef6\u540d\u4e3a: \u539f\u89c6\u9891\u540d_replace.avi<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@echo off\nchcp 65001 &gt;nul\nsetlocal enabledelayedexpansion\ntitle \u89c6\u9891\u97f3\u9891\u66ff\u6362\u5de5\u5177\n\necho ================================\necho     \u89c6\u9891\u97f3\u9891\u66ff\u6362\u5de5\u5177\necho ================================\necho.\n\nif \"%~1\"==\"\" goto noargs\nif \"%~2\"==\"\" goto noargs\n\nset \"INPUT_VIDEO=%~1\"\nset \"INPUT_AUDIO=%~2\"\n\n:: \u81ea\u52a8\u751f\u6210\u8f93\u51fa\u6587\u4ef6\u540d\uff08\u5728\u539f\u89c6\u9891\u540c\u76ee\u5f55\u4e0b\uff09\nfor %%F in (\"%INPUT_VIDEO%\") do (\n    set \"VIDEO_DIR=%%~dpF\"\n    set \"VIDEO_NAME=%%~nF\"\n    set \"OUTPUT_AVI=!VIDEO_DIR!!VIDEO_NAME!_replace.avi\"\n)\n\necho &#91;\u4fe1\u606f] \u8f93\u5165\u89c6\u9891: %INPUT_VIDEO%\necho &#91;\u4fe1\u606f] \u8f93\u5165\u97f3\u9891: %INPUT_AUDIO%\necho &#91;\u4fe1\u606f] \u8f93\u51fa\u6587\u4ef6: %OUTPUT_AVI%\necho.\n\n:: \u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\nif not exist \"%INPUT_VIDEO%\" (\n    echo \u9519\u8bef: \u89c6\u9891\u6587\u4ef6\u4e0d\u5b58\u5728!\n    pause\n    exit \/b 1\n)\n\nif not exist \"%INPUT_AUDIO%\" (\n    echo \u9519\u8bef: \u97f3\u9891\u6587\u4ef6\u4e0d\u5b58\u5728!\n    pause\n    exit \/b 1\n)\n\n:: \u68c0\u67e5FFmpeg\u662f\u5426\u5b89\u88c5\nwhere ffmpeg &gt;nul 2&gt;nul\nif errorlevel 1 (\n    echo \u9519\u8bef: \u672a\u627e\u5230FFmpeg\uff0c\u8bf7\u5148\u5b89\u88c5FFmpeg\n    echo \u4e0b\u8f7d\u5730\u5740: https:\/\/ffmpeg.org\/download.html\n    pause\n    exit \/b 1\n)\n\n:: \u83b7\u53d6\u89c6\u9891\u4fe1\u606f\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams v:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_VIDEO%\" 2^&gt;^&amp;1') do set \"VIDEO_CODEC=%%a\"\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams v:0 -show_entries stream^=width -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_VIDEO%\" 2^&gt;^&amp;1') do set \"VIDEO_WIDTH=%%a\"\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams v:0 -show_entries stream^=height -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_VIDEO%\" 2^&gt;^&amp;1') do set \"VIDEO_HEIGHT=%%a\"\n\necho &#91;\u4fe1\u606f] \u89c6\u9891\u7f16\u7801: !VIDEO_CODEC!\necho &#91;\u4fe1\u606f] \u5206\u8fa8\u7387: !VIDEO_WIDTH!x!VIDEO_HEIGHT!\necho.\n\n:: \u83b7\u53d6\u97f3\u9891\u4fe1\u606f\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams a:0 -show_entries stream^=codec_name -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_AUDIO%\" 2^&gt;^&amp;1') do set \"AUDIO_CODEC=%%a\"\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams a:0 -show_entries stream^=sample_rate -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_AUDIO%\" 2^&gt;^&amp;1') do set \"SAMPLE_RATE=%%a\"\nfor \/f \"delims=\" %%a in ('ffprobe -v error -select_streams a:0 -show_entries stream^=channels -of default^=noprint_wrappers^=1:nokey^=1 \"%INPUT_AUDIO%\" 2^&gt;^&amp;1') do set \"CHANNELS=%%a\"\n\necho &#91;\u4fe1\u606f] \u97f3\u9891\u7f16\u7801: !AUDIO_CODEC!\necho &#91;\u4fe1\u606f] \u91c7\u6837\u7387: !SAMPLE_RATE! Hz\necho &#91;\u4fe1\u606f] \u58f0\u9053\u6570: !CHANNELS!\necho.\n\n:: \u786e\u5b9aPCM\u683c\u5f0f\nif \"!AUDIO_CODEC!\"==\"\" (\n    set \"PCM_FORMAT=pcm_s24le\"\n    echo &#91;\u8b66\u544a] \u4f7f\u7528\u9ed8\u8ba4PCM\u683c\u5f0f: pcm_s24le\n) else if \"!AUDIO_CODEC!\"==\"unknown\" (\n    set \"PCM_FORMAT=pcm_s24le\"\n    echo &#91;\u8b66\u544a] \u4f7f\u7528\u9ed8\u8ba4PCM\u683c\u5f0f: pcm_s24le\n) else (\n    set \"PCM_FORMAT=!AUDIO_CODEC!\"\n    echo &#91;\u4fe1\u606f] \u4f7f\u7528PCM\u683c\u5f0f: !AUDIO_CODEC!\n)\n\n:: \u786e\u8ba4\u7ee7\u7eed\nset \/p \"CONTINUE=\u662f\u5426\u7ee7\u7eed\uff1f(Y\/N): \"\nif \/i not \"!CONTINUE!\"==\"Y\" (\n    echo \u7528\u6237\u53d6\u6d88\u64cd\u4f5c\n    pause\n    exit \/b 0\n)\n\necho &#91;\u4fe1\u606f] \u5f00\u59cb\u5904\u7406\u89c6\u9891\u548c\u97f3\u9891...\necho.\n\n:: \u6784\u5efaFFmpeg\u547d\u4ee4\nset \"FFMPEG_CMD=ffmpeg -i \"%INPUT_VIDEO%\" -i \"%INPUT_AUDIO%\" -c:v copy -c:a !PCM_FORMAT! -map 0:v:0 -map 1:a:0 -shortest -y -f avi\"\n\n:: \u6dfb\u52a0\u97f3\u9891\u53c2\u6570\nif not \"!SAMPLE_RATE!\"==\"\" (\n    set \"FFMPEG_CMD=!FFMPEG_CMD! -ar !SAMPLE_RATE!\"\n) else (\n    echo &#91;\u8b66\u544a] \u4f7f\u7528\u9ed8\u8ba4\u91c7\u6837\u7387: 48000 Hz\n    set \"FFMPEG_CMD=!FFMPEG_CMD! -ar 48000\"\n)\n\nif not \"!CHANNELS!\"==\"\" (\n    set \"FFMPEG_CMD=!FFMPEG_CMD! -ac !CHANNELS!\"\n) else (\n    echo &#91;\u8b66\u544a] \u4f7f\u7528\u9ed8\u8ba4\u58f0\u9053\u6570: 2\n    set \"FFMPEG_CMD=!FFMPEG_CMD! -ac 2\"\n)\n\nset \"FFMPEG_CMD=!FFMPEG_CMD! \"%OUTPUT_AVI%\"\"\n\necho \u6267\u884c\u547d\u4ee4:\necho !FFMPEG_CMD!\necho.\n\n:: \u6267\u884c\u8f6c\u6362\necho &#91;\u4fe1\u606f] \u6b63\u5728\u8f6c\u6362\uff0c\u8bf7\u7a0d\u5019...\n!FFMPEG_CMD!\n\nif !errorlevel! equ 0 (\n    echo.\n    echo &#91;\u6210\u529f] \u8f6c\u6362\u5b8c\u6210\uff01\n    echo &#91;\u4fe1\u606f] \u8f93\u51fa\u6587\u4ef6: %OUTPUT_AVI%\n\n    :: \u663e\u793a\u6587\u4ef6\u5927\u5c0f\n    for %%F in (\"%OUTPUT_AVI%\") do (\n        set \"size=%%~zF\"\n        set \/a \"sizeMB=!size!\/1048576\"\n        echo &#91;\u4fe1\u606f] \u6587\u4ef6\u5927\u5c0f: !sizeMB! MB\n    )\n) else (\n    echo.\n    echo &#91;\u9519\u8bef] \u8f6c\u6362\u5931\u8d25\uff01\n)\n\necho.\npause\nexit \/b 0\n\n:noargs\necho \u7528\u6cd5: \u62d6\u62fd\u4e24\u4e2a\u6587\u4ef6\u5230\u672c\u811a\u672c\u4e0a\necho \u987a\u5e8f: \u89c6\u9891\u6587\u4ef6, \u97f3\u9891\u6587\u4ef6\necho.\necho \u6216\u8005\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528:\necho %~nx0 \"\u89c6\u9891.mp4\" \"\u97f3\u9891.wav\"\necho.\necho \u8f93\u51fa\u6587\u4ef6\u5c06\u81ea\u52a8\u751f\u6210\u5728\u89c6\u9891\u540c\u76ee\u5f55\u4e0b\uff0c\u6587\u4ef6\u540d\u4e3a: \u539f\u89c6\u9891\u540d_replace.avi\necho.\npause<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u529f\u80fd\uff1a\u5c06\u89c6\u9891.mp4\u7684\u97f3\u9891\u6d41\u66ff\u6362\u4e3a\u97f3\u9891.wav\u4e3b\u8981\u9002\u7528\u4e8epcm\u97f3\u9891\u6d41\u3001avi\u5c01\u88c5\u7684\u89c6\u9891\u6587\u4ef6\u3002 \u7528\u6cd5: \u62d6\u62fd\u4e24\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3215","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/3215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/comments?post=3215"}],"version-history":[{"count":3,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/3215\/revisions"}],"predecessor-version":[{"id":3223,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/3215\/revisions\/3223"}],"wp:attachment":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/media?parent=3215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/categories?post=3215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/tags?post=3215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}