ffmpeg ffplay常用 命令整理 rtsp rtmp推流
列出电脑的设备名称 比如摄像头 后面ffplay通过这里的名称进行编码推流。循环读取rabbit.mp4 并推送到rtsp服务器。从MP4文件提取aac文件。从aac文件解码PCM文件。ffplay播放pcm文件。以tcp方式播放rtsp流。
循环读取rabbit.mp4 并推送到rtsp服务器
ffmpeg -re -stream_loop -1 -i rabbit.mp4 -rtsp_transport tcp -vcodec copy -codec copy -f rtsp rtsp://192.168.0.209:554/live/qmcy
推到rtmp服务器
ffmpeg -re -i test14.mp4 -c copy -f flv rtmp://192.168.8.156:1935/live/qmcy1111
从MP4文件提取aac文件
ffmpeg -i rabbit.mp4 -vn -codec copy rabbit.m4a
ffmpeg -i rabbit.mp4 -vn -acodec aac rabbit.m4a
ffmpeg -i rabbit.mp4 -vn -y -acodec copy rabbit.aac
从aac文件解码PCM文件
ffmpeg -i test.aac -f s16le test.pcm
列出电脑的设备名称 比如摄像头 后面ffplay通过这里的名称进行编码推流
fmpeg -list_devices true -f dshow -i dummy
ffplay -f dshow -i video="Integrated Webcam"
ffplay -f vfwcap -i 0
ffmpeg -f dshow -i video="Integrated Webcam" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://192.168.35.113:1935/live/stream
ffmpeg -f dshow -i video="Integrated Webcam" -f dshow -i audio="麦克风 (2- USB2.0 MIC)" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1935/live/123
或者
ffmpeg -f dshow -i video="USB2.0 PC CAMERA":audio="麦克风 (2- USB2.0 MIC)" -vcodec libx264 -r 25 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1935/live/123
//屏幕
ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://eguid.cc:1935/rtmp/destop
ffmpeg -f dshow -i video="Integrated Webcam" -vcodec h264 -acodec aac -strict -2 -f rtsp -rtsp_transport tcp rtsp://192.168.0.208/live/test1
重新编码推流
ffmpeg -i input.mp4 -vf scale=1080:1920 output.mp4
ffmpeg -i middle.mp4 -c:v libx264 -movflags faststart -b 600k -r 25 -s 640*360 -ab 48k -strict -2 test_C4.mp4
重新编码时候的码率
ffmpeg -rtsp_transport tcp -r 25 -i rtsp://uer:gd123456@192.168.2.121:554/Streaming/Channels/101 -an -vcodec libx264 -g 30 -crf 30 -strict -2 -s 600*400 -preset faster -profile:v main -x264-params bitrate=300 -sc_threshold 1000000000 -f flv rtmp://192.168.35.75:1987/live/qmcy1111
保存为MP4文件
ffmpeg -rtsp_transport tcp -i rtsp://admin:thinker13@192.168.0.240:554/streaming/channels/701 -acodec copy -vcodec copy video_test.mp4
ffplay篇:
ffplay播放pcm文件
-i 文件名
-f 使用格式
-ar 采样率
-ac 通道数
ffplay -ar 44100 -ac 2 -f s16le -i test.pcm
以tcp方式播放rtsp流
ffplay -i -rtsp_transport tcp rtsp://192.168.0.209:554/live/qmcy
rtsp://uer:gd123456@192.168.2.136:554/Streaming/Channels/101 //H265
ffmpeg 合并文件
MP4文件不支持pcm_mulaw编码必须把音频编码转为aac
ffmpeg -f concat -safe 0 -i contact.txt -c:v copy -c:a aac output1.mp4
或者保存为mkv格式
ffmpeg -f concat -safe 0 -i contact.txt -c copy output1.mkv
contact.txt格式内容为:
file '10-54-03-0.mp4'
file '10-54-06-1.mp4'
file '10-54-10-2.mp4'
ffmpeg静态编译程序 这样不用依赖于各种so库
John Van Sickle - FFmpeg Static Builds
ffmpeg png 转bmp
ffmpeg -i test.png test.bmp
ffmpeg截图:
ffmpeg -i 2023-06-29/10-54-10-2.mp4 -ss 1 -vframes 1 2023-06-29/822697379.jpg
视频不转码 音频转码
ffmpeg -i output1.mkv -vcodec copy -c:a aac -strict experimental output.m4a
aac转711
ffmpeg -i rabbit.AAC -c:a pcm_alaw -f alaw -ac 1 -ar 8000 rabbit.pcma
转音频推送rtmp
ffmpeg -re -stream_loop -1 -i rabbit.mp4 -rtsp_transport tcp -vcodec copy -acodec pcm_alaw -ac 1 -ar 44100 -f rtsp rtsp://192.168.131.130:554/live/qmcy
Rtsp转音频 推送rtsp
./ffqmcy -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a pcm_alaw -ac 1 -ar 8000 -vcodec copy -f rtsp rtsp://192.168.131.132:554/live/qmcy
/ffqmcy -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a pcm_alaw -ac 1 -ar 8000 -vcodec copy -f rtsp rtsp://192.168.131.132:554/live/qmcy
./ffqmcy -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a aac -vcodec copy -f flv rtmp://192.168.131.132:1935/qmcy/0000
./ffqmcy -re -stream_loop -1 -i ../hengshan.mp4 -c:a aac -vcodec libx264 -keyint_min 50 -g 30 -crf 30 -strict -2 -s 704*576 -preset faster -profile:v main -x264-params bitrate=4000 -sc_threshold 1000000000 -flags -global_header -f rtsp rtsp://192.168.131.132:554/live/qmcy
./ffqmcy -re -stream_loop -1 -i ../hengshan.mp4 -c:a aac -vcodec libx264 -g 30 -crf 30 -strict -2 -s 704*576 -preset faster -profile:v main -x264-params bitrate=4000 -sc_threshold 1000000000 -f rtsp rtsp://192.168.131.132:554/live/qmcy
./ffqmcy -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a aac -vcodec libx264 -g 25 -crf 30 -strict -2 -s 768*546 -preset faster -profile:v main -x264-params bitrate=1024 -sc_threshold 1000000000 -f flv rtmp://192.168.131.141:1935/qmcy/0000?sign=sdndudh21dje./ffqmcy -acodec aac -ar 8000 -ac 1 -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a aac -vcodec libx264 -g 1 -crf 30 -strict -2 -s 768*546 -preset faster -profile:v main -x264-params bitrate=1024 -sc_threshold 1000000000 -f flv rtmp://192.168.131.141:1935/qmcy/0000?sign=sdndudh21dje
./ffmpeg -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a aac -vcodec libx264 -g 1 -crf 30 -strict -2 -s 768*546 -preset faster -profile:v main -x264-params bitrate=1024 -sc_threshold 1000000000 -f flv rtmp://192.168.131.141:1935/qmcy/0000?sign=sdndudh21dje./ffmpeg -rtsp_transport tcp -i rtsp://admin:operation13@192.168.149.252/34020000001320000001 -c:a aac -vcodec libx264 -g 30 -crf 30 -strict -2 -s 1280*720 -preset faster -profile:v main -x264-params bitrate=300 -sc_threshold 1000000000 -f flv rtmp://192.168.131.141:1935/live/qmcy1111
./ffqmcy -re -stream_loop -1 -i ../hengshan.mp4 -rtsp_transport tcp -vcodec copy -acodec pcm_alaw -ac 1 -ar 44100 -f rtsp rtsp://192.168.131.132:554/live/qmcyffmpeg -i input.g711 -c:a aac -b:a 64k output.aac
./ffqmcy -rtsp_transport tcp -i rtsp://172.50.8.45:50554/gdlive/32080000001318310079 -acodec copy -vcodec copy video0.mkvvalgrind 检查内存泄漏
valgrind --leak-check=full --show-leak-kinds=all ./QMCYRTSPexport LD_LIBRARY_PATH=./3rd/ffmpeg/et44/lib/so:$LD_LIBRARY_PATH
scp ffqmcy root@172.50.8.53:/home/QMCY
ubuntu设置时区
timedatectl set-timezone Asia/Shanghai
gdb 忽略SIGPIPE信号
handle SIGPIPE nostop noprint nopass 或 handle SIGPIPE nostop noprint pass
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)