Skip to content

Instantly share code, notes, and snippets.

@Akagi201
Last active November 4, 2020 06:22
Show Gist options
  • Save Akagi201/0ead2f811e133130c19f to your computer and use it in GitHub Desktop.
Save Akagi201/0ead2f811e133130c19f to your computer and use it in GitHub Desktop.

video subtitle

ffmpeg -i *.mp4 -vf subtitles=*.srt output.mp4

element stream to ts

  • ffmpeg -i audio.aac -i ch2.h264 -acodec copy -vcodec copy -f mpegts out.ts

rtsp 2 rtmp

  • ffmpeg -rtsp_transport tcp -i rtsp://fuck.com/fuck/fuck -c copy -f flv rtmp://shit.com/shit/shit

截图片

  • ./ffmpeg -y -err_detect ignore_err -i "rtmp://uplive.b0.upaiyun.com/live/loading timeout=10" -f image2 -vframes 1 a.jpg
  • ./ffmpeg -y -err_detect ignore_err -i "rtmp://uplive.b0.upaiyun.com/live/loading live=1 timeout=10" -f image2 -vframes 1 a.jpg

推流图片

  • ./ffmpeg -loop 1 -i akhead.jpg -r 10 -f flv rtmp://uplive.v0.upaiyun.com/live/english

查看 ffmpeg 全部帮助

  • ffmpeg --help full

推纯音频

  • ffmpeg -re -i xxx.aac -vn -acodec copy -f flv -y rtmp://xxxx

实时转低码率

  • ffmpeg -i rtmp://10.0.5.135/uplive.b0.upaiyun.com/live/123 -b 1000k -s 960:540 -f flv rtmp://10.0.5.132/uplive.v0.upaiyun.com/live/small

循环推流

for((;;)); do \
    ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/hightest_h1080p.mov \
    -vcodec copy -acodec copy \
    -f flv -y rtmp://127.0.0.1:1935/live/livestream; \
    sleep 1; \
done

纯 AAC 推流

  • ffmpeg -re -i time.aac -bsf:a aac_adtstoasc -c copy -f flv rtmp://uplive.b0.upaiyun.com/live/english

转码为低码率

  • ffmpeg -i time.flv -c libx264 -profile:v high -preset:v slow -b:v 300k -s 640x480 -r 25 -acodec libfdk_aac -ac 2 -b:a 48k -ar 44100 -y time.300kbps.flv

切割mp4

  • ffmpeg -ss 00:00:00 -i mpeg4conformance.mp4 -vcodec copy -acodec copy -t 00:00:10 o.mp4

解析所有的帧

webcam

常用命令

下载m3u8视频

  • ffmpeg -i M3U8 URL -c copy mpegts.ts

桌面直播

  • ffmpeg -f x11grab -follow_mouse centered -r 100 -s cif -i :0.0 -f flv $RTMP_PUSH_URL

转h.264裸流文件

  • -acodec none

watermark

使用FFMPEG发布RTSP流

  • 上传: ffmpeg -i a.mp4 -vcodec libx264 -f rtsp rtsp://127.0.0.1:5050/ok
  • 接收: ffmpeg -rtsp_flags listen -f rtsp -i rtsp://127.0.0.1:5050/ok b.mp4

压制

转码到webm

webcam capture

@nmreadelf
Copy link

我是菜鸟,搜google,居然搜到你这儿了

@yangtao0410
Copy link

不错

@elesos
Copy link

elesos commented Oct 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment