ffmpeg、ffplay、ffprobe 常用调试命令

(1)播放原始视频yuv数据, 以1920*1280的xxx.yuv为例

ffplay -f rawvideo -video_size 1920x1080 xx.yuv

(2)播放原始音频(需要大致知道格式)
ffplay -ar 48000 -channels 1 -f s16le -i   xx.pcm

(3)抓取视频中的某一帧,保存为图片(以下是存取 第199帧)
ffmpeg -i rtmp2file.264 -vf select=`eq(n\,199)`  -frames:v 1 frame1.png 

(4)分析我抓取rtmp流保存的文件
ffprobe rtmp2fileC.flv -select_streams v -show_packets > 1122-show_packets.txt

(5)从服务端将直播流存成文件
rtmpdump -r rtmp://202.108.14.1:1935/live/abc_1234  -o rtmpdump1.flv

ffmpeg -y -err_detect aggressive   -i rtmp://202.108.14.1:1935/live/abc_1234 -c:v copy -an mmi5_stream_by_ffmpeg.flv

ffmpeg -y -err_detect aggressive   -i rtmp://202.108.14.1:1935/live/abc_1234 -c copy /Users/wangzhong/recorder/Log/rtmp2file.flv
ffmpeg -y -i rtmp://202.108.14.1:1935/live/abc_1234 -c:v copy -an /Users/wangzhong/recorder/Log/rtmp2fileD.flv  -debug_ts

(6)将文件以rtmp协议推流直播出去
ffmpeg  -i /Users/wangzhong/Downloads/video_files/bs_720.mp4 -map 0:v:0 -c:v copy -map 0:a:0 -c:a libvo_aacenc -ac 2 -ar 44100 -b:a 32k -af "asetpts=PTS-STARTPTS" -flags +global_header -f flv rtmp://10.11.50.195:1935/live/123

(7)用ffplay播放,-fflags no buffer低延时
ffplay -fflags nobuffer rtmp://202.108.14.1:1935/live/abc_123 
ffplay rtmp://202.108.14.1:1935/live/abc_2234 -fflags nobuffer

(8)自己制造一些特定格式的音视频流(含几个B帧、是否cabac编码、每帧6个slice、码率、帧率、分辨率、关键帧间隔30帧),分两步,
第一步:重新编码
ffmpeg -i VID_20161122_104326.mp4 -map 0:v:0 -b:v 3000
k -vf "scale=w=1280:h=720" -c:v libx264 -x264opts bframes=2:keyint=30:min-keyint=5:ref=1:rc-lookahead=15:subme=2:trellis=0:weightp=1:no-mixed-refs:me=dia:no-metree:cabac=0:slices=6  -r 30 -map 0:a:0 -c:a libvo_aacenc -ac 2 -ar 44100 -b:a 32k  -flags +global_header  -f flv bframes2_720P_20161122_104326.flv

第二步:抽取纯视频
ffmpeg -i bframes2_720P_20161122_104326.flv -c:v copy -bsf:v h264_mp4toannexb -an  bframes2_720P_20161122_104326.264

(9)ffmpeg命令行以电脑摄像头作为直播视频源

ffmpeg -fflags +nobuffer -avioflags direct -rtbufsize 65536000 -f dshow -i video="Logitech HD Pro Webcam C920" -map 0:v:0 -b:v 1000k -c:v libx264 -x264opts  keyint=15:min-keyint=10:ref=1:rc-lookahead=10:subme=2:trellis=0:weightp=1:no-mixed-refs:me=dia:no-mbtree  -an   -f flv -y rtmp_url

//-avioflags direct该参数可以消除ffmpeg编码引起的画面断层
ffmpeg  -avioflags direct -f dshow -i video="Logitech HD Pro Webcam C920" -map 0:v:0 -b:v 1000k -c:v libx264 -x264opts  keyint=15:min-keyint=10:ref=1:rc-lookahead=10:subme=2:trellis=0:weightp=1:no-mixed-refs:me=dia:no-mbtree  -an   -f flv -y rtmp_url

//-f dshow -video_size 1280x720  设置dshow的渲染分辨率
ffmpeg  -avioflags direct -f dshow -video_size 1280x720 -i video="Logitech HD Pro Webcam C920" -map 0:v:0 -b:v 1000k -c:v libx264 -x264opts  keyint=15:min-keyint=10:ref=1:rc-lookahead=10:subme=2:trellis=0:weightp=1:no-mixed-refs:me=dia:no-mbtree  -an   -f flv -y  rtmp_url

你可能感兴趣的:(音视频,ffmpeg)