ffmpeg 使用笔记(一)

来源:互联网 发布:基尼系数统计学算法 编辑:程序博客网 时间:2024/05/16 09:16

推流

ffmpeg -re -i a.mp4 -c copy -f flv rtmp://192.168.2.169/live?vhost=play/11-re 按照时间戳顺序推流 不加的话直接把所有文件都推过去-f  输出格式-c  音视频格式 copy 与源流一样

循环推流

  • 真正循环
ffmpeg -threads 2 -re -fflags +genpts -stream_loop -1 -i ./test.mp4 -c copy test.flv推完一次会停止几十秒之后再重推-stream_loop -1 flag before the input (-i):The -fflags +genpts will regenerate the pts timestamps so it loops smoothly, otherwise the time sequence will be incorrect as it loops.FFmpeg >= 2.8.4 is required in this case.
  • 假循环
ffmpeg -re -safe 0 -f concat -i test.txt -vcodec copy -acodec copy -f flv rtmp://xxx-safe 0 可以用绝对路径,否则只能用相对路径cat test.txtfile 'a.mp4'file 'a.mp4'file 'a.mp4'

捕捉桌面推流

ffmpeg -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 1920*1080  -i desktop -b 3000k  -f flv rtmp://xxx

模糊水印

ffmpeg.exe -i out.flv -vf delogo=10:20:200:300:0 -f flv pl.flv 10  离左边距    0左上角20  离上边距    0左上角200 模糊区域的宽300 模糊区域的高

添加水印

ffmpeg -re -i a.flv -vf "movie=1.png,scale=200:300[watermask];[in][watermask] overlay=50:100[out]"   -f flv  rtmp://xxx200 水印宽300 水印高50  水印位置 离左边距100 水印位置 离上边距

截图

ffmpeg -ss 01:00:00 -i a.mp4  -t 00:10:00 -r 0.2 -f image2 ll\i-%3d.jpgrecorder rec {    record keyframes;    record_max_frames 1;    record_interval 5s;     record_suffix .jpg;    record_path /usr/local/sms/rec;    record_unique on;     record_lock on;     exec_record_done /usr/local/sms/sbin/ffmpeg -i $path -r 1 -f image2  -y $path;    on_record_done http://127.0.0.1:80/test1;}   

画中画

ffmpeg -i a.mp4 -i a.mp4 -filter_complex "[1:v]scale=w=176:h=144:force_original_aspect_ratio=decrease[ckout];[0:v][ckout]overlay=x=10:y=0[out]" -map "[out]" -movflags faststart b.mp4
原创粉丝点击