ffplay/mpv
查看所有的解码器 | ffplay -decoders >>decoders.txt |
ffplay无延时无缓存播放 | ffplay -fflags nobuffer -i “%1” |
ffplay指定size播放 | ffplay -x 480 -y 270 -i “%1” |
ffplay指定解码器 | ffplay -vcodec hevc_cuvid “%1” [h264_cuvid hevc h264 mpeg4] |
jetson指定解码器 | ffplay -vcodec h264_nvmpi “%1” |
mpv指定size播放 | mpv -x –geometry=300 “%1” |
mpv指定dxva2解码播放 | mpv –vo=gpu –hwdec=dxva2 “%1” [dxva2-copy/d3d11va/d3d11va-copy/nvdec/nvdec-copy/cuda/cuda-copy –vo=direct3d] |
mpv指定自动GPU解码播放 | mpv –vo=gpu –gpu-api=auto –hwdec=auto “%1” |
ffmpeg推流相关
%URL% 为xx.mp4或 rtsp://xx等视频源 | |
rtp推流 | ffmpeg -re -i %URL% -vcodec copy -f rtp rtp://127.0.0.1:12345 |
udp推流 | ffmpeg -re -i %URL% -vcodec copy -f mpegts udp://127.0.0.1:12345 |
rtsp推流 | ffmpeg -re -fflags +genpts -stream_loop -1 -i %URL% -vcodec copy -f rtsp rtsp://127.0.0.1:554 |
rtmp推流 | ffmpeg -re -i %URL% -c copy -f flv rtmp://127.0.0.1/live |
rtsp推流(640×480转码mpeg4) | ffmpeg -re -fflags +genpts -stream_loop -1 -i %URL% -vf “scale=640:480:flags=bicubic,setsar=1/1” -vcodec mpeg4 -b:v 420k -c:a aac -ac 2 -b:a 64k -r 15 -sn -map_metadata -1 -map_chapters -1 -f rtsp rtsp://127.0.0.1:554 |
ffmpeg测试流写入flv | ffmpeg -probesize 32768 -i “rtsp://xxx” -acodec copy -vcodec copy -f flv out.flv |
ffmpeg字幕相关
subtitles | %URL% 为xx.mp4或 rtsp://xx等视频源 |
增加srt/ass字幕流 设默认 | ffmpeg -i %URL% -i sub.srt -c copy -disposition:s:0 default out.mkv |
拷贝视音频轨 增加双轨字幕流 设默认 | ffmpeg -i %URL% -i %~DPsub0.ass -i %~DPsub1.ass -map 1:s -c copy -map 2:s -c copy -map 0:v -c copy -map 0:a -c copy -disposition:s:0 default -shortest out.mkv |
提取srt字幕流 | ffmpeg -i %URL% sub.srt |
字幕流转换 | 1)原始文本输出 ffmpeg -i %URL% -an -vn -bsf:s mov2textsub -scodec copy -f rawvideo sub.txt ffmpeg -i %URL% -an -vn -c:s copy -f rawvideo -map 0:s sub.txt 2)ass格式输出 ffmpeg -i %URL% -an -vn -scodec copy sub.ass |
ffmpeg设备音频相关
%URL% 为xx.mp4或 rtsp://xx等视频源 | |
列出设备 | ffmpeg -list_devices true -f dshow -i dummy |
摄像头采集(采10秒) | ffmpeg -f dshow -i video=”Integrated Camera” -t 10 -vcodec libx264 out.mp4 |
列出硬解等 | ffmpeg -codecs | grep cuvid ffmpeg -hwaccels 显示所有可用的硬件加速器 |
分离提取音频(aac/ac3/dts) | ffmpeg -i %URL% -map 0:a:0 -acodec copy -y %~DP01.ac3 ffmpeg -i %URL% -map 0:a:1 -acodec copy -y %~DP02.aac |
ac3合并0,1音频轨到视频 | ffmpeg -i %URL% -i %~DP00.ac3 -i %~DP01.ac3 -map 0:v -c copy -map 1:a -c copy -map 2:a -c copy -shortest -map 0:s -scodec copy out.mkv |
拷贝视音频字幕 默认字幕轨0 | ffmpeg -i %URL% -map 0:v:0 -vcodec copy -map 0:a -acodec copy -map 0:s -scodec copy -disposition:s:0 default -y out.mkv |
拷贝视频,音轨调换 默认音轨0 | ffmpeg -i %URL% -map 0:0 -map 0:2 -map 0:1 -c copy -disposition:a:0 default -y out.mkv |
-disposition:a:0 default | 有时不能生效 是需要将音轨分离再合并来解决 |
ffmpeg转码相关
%URL% 为xx.mp4或 rtsp://xx等视频源 | |
WMV转264的ts | ffmpeg -i test.wmv -c:v libx264 -strict -2 1.ts |
MP4转TS | ffmpeg -i 1.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 1.ts ffmpeg -i 2.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb 2.ts |
MP4合并 | ffmpeg -i “concat:1.ts|2.ts” -acodec copy -vcodec copy -absf aac_adtstoasc output.mp4 |
转H264/H265裸流 | ffmpeg -i %URL% -codec copy -bsf: h264_mp4toannexb -f h264 out.264 ffmpeg -i %URL% -vframes 200 -r 25 -s 3840×2160 -aspect 16:9 -b:v 12000000 -vcodec hevc -y out.265 nvenc/nvenc_h264/h264_nvenc ffmpeg -i %URL% -vcodec h264_nvenc -y out.264 hevc_nvenc/nvenc_hevc ffmpeg -i %URL% -vcodec nvenc_hevc -y out.265 ffmpeg -i %URL% -vcodec hevc -y 265.mp4 |
硬解硬编 | ffmpeg -c:v h264_cuvid -i input -c:v h264_nvenc -preset slow output.mkv |
ffmpeg像素相关
yuvj444p.yuv为完全取样的的YUV文件 | |
生成yuvj444p | ffmpeg -f lavfi -i testsrc -frames 10 -pix_fmt yuvj444p -s 320×320 yuvj444p.yuv |
yuvj444p转换成422 | ffmpeg -pix_fmt yuvj444p -s 320×320 -i yuvj444p.yuv -pix_fmt yuvj420p yuvj420p.yuv |
yuvj444p转换成420 | ffmpeg -pix_fmt yuvj444p -s 320×320 -i yuvj444p.yuv -pix_fmt yuv422p yuv422p.yuv |
yuvj444p转换成411 | ffmpeg -pix_fmt yuvj444p -s 320×320 -i yuvj444p.yuv -pix_fmt yuvj411p yuvj411p.yuv |
yuvj444p转换成rgb24 | ffmpeg -pix_fmt yuvj444p -s 320×320 -i yuvj444p.yuv -pix_fmt rgb24 yuv2rgb.rgb |
rgb24转成yuvj444p | ffmpeg -s 320×320 -pix_fmt rgb24 -i yuv2rgb.rgb -pix_fmt yuvj444p -s 320×320 rgb2yuvj444p.yuv |