FFmpeg命令
0
MKV转MP4
# 很慢
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -vcodec h264 target.mp4
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -c copy target.mp4
# 音频
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -vcodec copy -acodec aac target.mp4
-y 默认覆盖
由于录制媒体流时直接使用-c copy
所以导致数据之中很多的重传的错包,所以需要有些特殊处理。
Too many packets buffered for output stream 0:1.
[aac @ 0x24a2100] Qavg: 61578.551
[aac @ 0x24a2100] 2 frames left in the queue on closing
Conversion failed!
添加参数-threads 2
和max_muxing_queue_size 1024
ffmpeg -threads 2 -i 000000.ts -max_muxing_queue_size 1024 -c:a aac -c:v h264 video.mp4
[aac @ 0x2290a80] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[mp4 @ 0x2102d40] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 0x20c9380] MB rate (121500000) > level limit (16711680)
...
More than 1000 frames duplicated
添加参数-vsync 2
ffmpeg -i 000000.ts -vsync 2 -c:a aac -c:v h264 video.mp4
RTP推流
ffmpeg -re -stream_loop -1 -i 文件路径 -map 0:v:0 -c:v h264 -r 帧数 -crf 质量 -map 0:a:0 -c:a libopus -ab 96k -ac 2 -ar 48000 -f tee "[select=v:f=rtp:ssrc=视频ssrc:payload_type=视频payloadType]rtp://ip:port?rtcpport=port|[select=a:f=rtp:ssrc=音频ssrc:payload_type=音频payloadType]rtp://ip:port?rtcpport=port"
屏幕录制
ffmpeg -f gdigrab -video_size 1920x1080 -i desktop -c:v libx264 output.mp4