背景
翻看某本书时,看到有些很重要的win10上很重要的
ffmpeg命令
批处理脚本,特此记录下,便于查阅:
脚本
视频转码为MP4.bat
set size=1280x720 set vbit=1000k set abit=128k set filename=%~dpn1 set ext=%~x1 ffmpeg -i "%filename%%ext%" -s %size% -vcodec h264 -acodec aac -b:v %vbit% -b:a %abit% -y "%filename%_%size%_%vbit%_%abit%.mp4" pause
截取视频片段.bat
set start=5 set lenth=10 set filename=%~dpn1 set ext=%~x1 ffmpeg -ss %start% -t %lenth% -i "%filename%%ext%" -vcodec copy -acodec copy "%filename%_%start%_%lenth%_%ext%" pause
截取视频片段转GIT动图.bat
set size=640x360 set start=5 set lenth=10 set rate=25 set filename=%~dpn1 set ext=%~x1 ffmpeg -ss %start% -t %lenth% -i "%filename%%ext%" -r %rate% -s %size% "%filename%_%start%_%lenth%.gif" pause
视频截图为JPG格式.bat
set time=5 set filename=%~dpn1 set ext=%~x1 ffmpeg -ss %time% -i "%filename%%ext%" -frames:v 1 -y "%filename%_%time%.jpg" pause
视频截图缩放JPG.bat
set size=640x360 set time=5 set filename=%~dpn1 set ext=%~x1 ffmpeg -ss %time% -i "%filename%%ext%" -s %size% -frames:v 1 -y "%filename%_%size%_%time%.jpg" pause
FLV重新封装为MP4.bat
set filename=%~dpn1 set ext=%~x1 ffmpeg -i "%filename%%ext%" -vcodec copy -acodec copy "%filename%.mp4" pause
文件直播.bat
set file="D:\zjiac_code\uploadPath\test\danao.mp4" set rtmp=rtmp://192.168.196.100:1935/live/stream set size=960x540 set vbit=500k set abit=64k ffmpeg -re -i "%file%" -s "%size%" -c:v h264 -c:a aac -b:v %vbit% -b:a %abit% -f flv -y "%rtmp%" pause
画中画直播.bat (没测试出来,先记住吧)
chcp 65001 set v="hm1091_techfront" set a=" 外接麦克风 (Synaptics Audio)" set url=rtmp://192.168.196.100:1935/live/livestream ffmpeg -f dshow -i video=%v%:audio=%a% -f gdigrab -framerate 15 -i desktop -filter_complex "[0]scale=640:360[pip];[1][pip]overplay=main_w-overlay_w-0:main_h-overlay_h-40" -vcodec libx264 -acodec aac -b:v 750k -b:a 64k -s 1366x768 -f flv %url% pause
自动播放AutoRecord.bat
set input=rtmp://192.168.196.100:1935/live/stream set dir=%userprofile%\Videos set file=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2% ffmpeg -i "%input%" -vcodec copy -acodec copy -f flv -y "%dir%\%file%.flv" pause
关闭cmd进程命令
taskkill /f /im cmd.exe /t pause
拖入FFPLAY播放.bat
set input=%1 ffplay -x 640 -y 360 %input% pause
屏幕桌面捕获.bat
set file=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2% set dir=%~dp0 ffmpeg -f gdigrab -framerate 15 -i desktop -vcodec h264 -acodec aac -b:v 3000k -b:a 64k "%dir%\%file%.mp4" pause
以上内容来自《零基础搭建直播室与云直播平台 》一书。
相关源码地址: https://gitee.com/senior-study-course/learn-live-play.git
大功告成!!!