概述
1、查看支持的YUV格式
ffmpeg -pix_fmts
2、对YUV格式进行转换
ffmpeg -pix_fmt yuv420p -s 176x144 -i carphone_qcif.yuv -pix_fmt nv12 carphone_qcif_nv12.yuv
参考网址:https://lists.ffmpeg.org/pipermail/ffmpeg-user/2015-November/029187.html
3、对YUV进行缩放
ffmpeg -s:v 1920x1080 -r 25 -i input.yuv -vf scale=960:540 -c:v rawvideo -pix_fmt yuv420p out.yuv
参考网址:https://stackoverflow.com/questions/21984833/scaling-resizing-raw-yuv-video-with-ffmpeg
4、对264码流进行解码
ffmpeg -i 720P.264 -s 1280x720 -pix_fmt yuv422p 720P-out.yuv
5、将YUV转换成avi
ffmpeg -s wxh -pix_fmt yuv420p -i input.yuv -vcodec mpeg4 output.avi
ffmpeg -s wxh -pix_fmt yuv420p -i input.yuv -vcodec h264 output.avi
参考网址:https://stackoverflow.com/questions/15778774/using-ffmpeg-to-losslessly-convert-yuv-to-another-format-for-editing-in-adobe-pr
6、将264裸码流转换成avi
ffmpeg -f h264 -i source.264 -c:v libx264 -an dest.avi
Use -c:v copy instead to copy the source stream without re-encoding
参考网址:https://stackoverflow.com/questions/33108985/ffmpeg-264-to-avi
7、从avi中提取裸码流
7.1 提取码流
ffmpeg.exe -i BQSquare_416x240_37.avi -f rawvideo -vcodec copy xx.264
参考网址:http://forum.doom9.org/archive/index.php/t-79190.html
参考网址:https://askubuntu.com/questions/258744/how-to-convert-a-raw-video-using-ffmpeg
7.2 提取若干帧数码流
ffmpeg.exe -i BQSquare_416x240_37.avi -f rawvideo -vcodec copy -vframes 100 xx.264
对于提取特定的帧,需要用特殊的方法:假设提取260帧,帧率是26, 则可用-ss 10.0 其中10.0=260/26
8、Extract some YUV frames from large yuv File
从第0帧开始截取30帧:
ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v select="gt(n, -1)" -vframes 30 out30.yuv
or
ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v select="between(n, 0, 29)" out30.yuv
参考网址:https://superuser.com/questions/573747/drop-every-even-or-odd-frames-using-ffmpeg
参考网址:http://ffmpeg.org/ffmpeg-filters.html#aselect_002c-select
关于c:v
c:v is an abbreviated version of codec:v
vcodec is an alias of codec:v
参考网址:https://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-February/035335.html
9. 将多个同类文件合并成一个文件
ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg
参考网址:https://ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f
参考网址:https://blog.csdn.net/u012587637/article/details/51670975
参考网址:https://ffmpeg.org/ffmpeg-formats.html#concat-1
10. 只指定输入,不指定输出
ffmpeg -i input.mp4 -f null /dev/null
参考网址:https://stackoverflow.com/questions/20323640/ffmpeg-deocde-without-producing-output-file
11. 指定输出比特率
参考网址:https://superuser.com/questions/1106343/determine-video-bitrate-using-ffmpeg
参考网址:https://video.stackexchange.com/questions/16356/how-to-use-ffprobe-to-obtain-certain-information-about-mp4-h-264-files
参考网址:https://github.com/zeroepoch/plotbitrate
参考网址:https://askubuntu.com/questions/196890/how-to-find-the-bitrate-of-an-mp3-file-via-command-line
12. yuv转h264,不带B帧
查看libx264可配置选项:ffmpeg.exe -help encoder=libx264
ffmpeg.exe -s 1920x1080 -i XXXX_1920x1080.yuv -b:v 1024k -r 25 -vcodec libx264 -x264-params bframes=0:b-adapt=0 xxxx.264
参考网址:https://trac.ffmpeg.org/wiki/Encode/H.264
13. yuv转h265,不带B帧
ffmpeg.exe -s 1920x1080 -i XXXX_1920x1080.yuv -b:v 1024k -r 25 -vcodec libx265 -x265-params bframes=0:b-adapt=0 xxxx.265
参考网址:https://trac.ffmpeg.org/wiki/Encode/H.265
参考网址:https://x265.readthedocs.io/en/default/presets.html#presets
各编码器参数:https://github.com/stoyanovgeorge/ffmpeg/wiki/Video-Encoding-with-FFMPEG
14. 解码h264码流但只输出某一段YUV
ffmpeg
-i xxxx.264
-vf "select=gte(n,0)*lt(n,100)"
xxxxx.yuv
参考网址:https://forum.videohelp.com/threads/388116-ffmpeg-most-efficient-way-to-extract-frame-ranges
15. 获得音视频信息
ffprobe -v quiet -print_format json -show_format -show_streams test.mp4
参考网址:https://www.cnblogs.com/Finley/p/8646711.html
16. FFMPEG上采样
ffmpeg -i test.tif -vf scale=504:376 -sws_flags bilinear out.bmp
参考网址:https://trac.ffmpeg.org/wiki/Scaling
ffmpeg插值方法:https://ffmpeg.org/ffmpeg-scaler.html
A、附录
参考网址:
http://processors.wiki.ti.com/index.php/Open_Source_Video_Processing_Tools_-_MPlayer,_FFMpeg,_AviSynth,_MKVToolnix,_MP4Box
官网翻译文档:https://www.bookstack.cn/read/other-doc-cn-ffmpeg/ffmpeg-doc-cn-40.md
最后
以上就是结实酸奶为你收集整理的【FFMPE系列】之FFMPEG常用命令的全部内容,希望文章能够帮你解决【FFMPE系列】之FFMPEG常用命令所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复