1. 程式人生 > >windows下選單選項執行ffmpeg命令的bat指令碼

windows下選單選項執行ffmpeg命令的bat指令碼

編寫了一個windows平臺下的bat指令碼,通過選項便捷執行所需的ffmpeg轉碼命令。大大減少平常DOS下輸入命令引數等繁瑣操作,希望能幫助到所有閱讀到此文的讀者, 聯絡方式:[email protected]

源指令碼的下載路徑:https://github.com/zymill/hysAnalyser/blob/master/myEnc.bat

參考圖1(選項操作)

參考圖2(執行某項命令的轉碼命令介面)

 

指令碼詳情:(大家可根據自己需要編輯和驗證)下載路徑  (https://github.com/zymill/hysAnalyser/blob/master/myEnc.bat

@ECHO OFF&PUSHD %~DP0 &TITLE FFMPEG編碼選項
mode con cols=150 lines=40
color 2F
>NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
    ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
    ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
    "%TEMP%\Getadmin.vbs"
    DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
    Exit /b
)
:Menu
Cls
@ echo.
@ echo.    HysProject 編 碼 菜 單 選 項
@ echo.
@ echo.     H264編碼(es): 1080p    →     請輸入1
@ echo.                   720p     →     請輸入2
@ echo.
@ echo.     H265編碼(ts): 2160p    →     請輸入3
@ echo.                   1080p    →     請輸入4
@ echo.                   720p     →     請輸入5
@ echo.
@ echo.     H265編碼(es): 2160p    →     請輸入6
@ echo.                   1080p    →     請輸入7
@ echo.                   720p     →     請輸入8
@ echo.
@ echo.     退出                   →     請輸入9
@ echo.
set /p xj= 輸入數字按回車:
if /i "%xj%"=="1" Goto H264enc1080p
if /i "%xj%"=="2" Goto H264enc720p
if /i "%xj%"=="3" Goto H265enc2160p
if /i "%xj%"=="4" Goto H265enc1080p
if /i "%xj%"=="5" Goto H265enc720p
if /i "%xj%"=="6" Goto H265enc2160p2es
if /i "%xj%"=="7" Goto H265enc1080p2es
if /i "%xj%"=="8" Goto H265enc720p2es
if /i "%xj%"=="9" Goto myExit
@ echo.
echo      選擇無效,請重新輸入
ping -n 2 127.1>nul 
goto menu
:H264enc1080p
@ echo.
ECHO    H264編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1920x1080 -i bg1080p.yuv -r 25 -bf 0 -vcodec libx264 bg1080p.h264
goto h264finished
:H264enc720p
@ echo.
ECHO    H264編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1280x720 -i bg720p.yuv -r 25 -bf 0 -vcodec libx264 bg720p.h264
goto h264finished
:H265enc2160p
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 3840x2160 -i bg2160p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" -f mpegts h265_2160p.ts
goto h265finished
:H265enc1080p
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1920x1080 -i bg1080p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" -f mpegts h265_1080p.ts
goto h265finished
:H265enc720p
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1280x720 -i bg720p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" -f mpegts h265_720p.ts
goto h265finished
:H265enc2160p2es
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 3840x2160 -i bg2160p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" h265_2160p.h265
goto h265finished
:H265enc1080p2es
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1920x1080 -i bg1080p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" h265_1080p.h265
goto h265finished
:H265enc720p2es
@echo.
ECHO    H265編碼中..請稍等..
taskkill /f /im ffmpeg*>NUL 2>NUL
ffmpeg.exe -pix_fmt yuv420p -s 1280x720 -i bg720p.yuv -r 25 -bf 0 -vcodec libx265 -x265-params "keyint=25:bframes=0" h265_720p.h265
goto h265finished
:myExit
@ echo.
echo    正在退出..請稍等..
taskkill /f /im et*>NUL 2>NUL
goto Exit2
:h264finished
@ ECHO.
ECHO    h264編碼完成!
ping -n 3 127.8>nul
goto menu
:h265finished
@ ECHO.
ECHO    h265編碼完成!
ping -n 3 127.8>nul
goto menu
:Exit2
@ ECHO.
ECHO    退出完成!
ping -n 2 127.8>nul
goto menu