我爱看高清论坛

 找回密码
 立即注册
搜索
查看: 251|回复: 0

FFMPEG命令行,FFMPEG参数使用详解

[复制链接]

该用户从未签到

管理员

QQ上不处理问题.有问题请到论坛反馈区反馈.谢谢!

UID
2
注册时间
2015-5-19
最后登录
2024-4-28
在线时间
4108 小时
回帖
1486
主题
4587
精华
9
汤圆
192968
威望
125
积分
26029
阅读权限
200

优秀录制员优秀音轨剪辑员最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主论坛元老荣誉管理1周年勋章2周年勋章3周年勋章4周年勋章5周年勋章6周年勋章7周年勋章8周年勋章

发表于 2023-9-12 23:37:52 | 显示全部楼层
声明:本站所有作品片源均来源于互联网公开渠道,影视版权均归原电影公司所有,如有侵犯版权,请与52khd@52khd.cn联系,我们将立即删除. 52KHD宗旨点击进入

前言
致敬师哥雷神,但师哥的FFMPEG参数的这篇文章,里面一些参数在FFMPEG的最新版已经都去掉了
文章链接https://blog.csdn.net/leixiaohua1020/article/details/12751349
同为广院的工科研究生,我写了这篇文章进行补充,针对于FFMEPG 4.2.1 以上版本

FFMPEG的命令行格式
在FFMPEG的官网http://ffmpeg.org/ffmpeg.html给出的命令行格式是这样的
————————————————
版权声明:本文为CSDN博主「Bug 挖掘机」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011035397/article/details/108952604

  1. ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...

  2. ffmpeg [全局指令,可选] {[对输入媒体文件的操作,可选] -i 输入文件的路径} ...{[对输出文件的操作,可选] 输出文件的路径}
复制代码


实例1 转码
将input.avi转码成output.ts,并设置视频的码率为64 kbps(64 kbit/s)

  1. #实例1
  2. ffmpeg -i input.avi -b:v 64k -bufsize 64k output.ts
  3. ffmpeg -y -i input.avi -b:v 64k -bufsize 64k output.ts
  4. ffmpeg -n -i input.avi -b:v 64k -bufsize 64k output.ts

  5. #扩展1
  6. 可以同时编码为多种格式,并定义从输入流到输出流的映射:
  7. 在 64 kbits 时将 a.wav 转换为 a.mp2,在 128 kbits 时转换为 b.mp2。"-map: 索引"指定每个输出流使用哪个输入流,按输出流定义的顺序排列。

  8. ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
复制代码


参数详解
1.jpg

实例2 改变视频帧率

强制修改输入文件的帧率为1 fps(仅对原始格式数据有效,如m2v视频数据,yuv原始视频文件,jpeg图片等格式),并把输出文件帧率调整到24fps


  1. #实例2
  2. ffmpeg -r 1 -i input.m2v -r 24 output.avi

  3. #ffmpeg {对输入文件的操作} {对输出文件的操作}

  4. ffmpeg -s 1920x1080 -pix_fmt yuv422p -i src01_1920x1080_422.yuv -s 1280x720 -pix_fmt yuv420p src01_1280x720.yuv

  5. ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
复制代码

参数详解

2.jpg


实例3

  1. 示例3-1:
  2. 截取一张352x240尺寸大小的,格式为jpg的图片:
  3. ffmpeg -i test.asf -y -f image2 -t 0.001 -s 352x240 a.jpg

  4. 示例3-2:
  5. 把视频的前30帧转换成一个Animated Gif :
  6. ffmpeg -i test.asf -vframes 30 -y -f gif a.gif

  7. 示例3-3:
  8. 在视频的第8.01秒处截取 352*240 的缩略图
  9. ffmpeg -i test2.asf -y -f image2 -ss 08.010 -t 0.001 -s 352x240 b.jpg
复制代码


3.jpg


FFMPEG参数大全

  1. 查询指令  
  2. Print help / information / capabilities:
  3. -L                  show license 查看许可证信息
  4. -h topic            show help     查看帮助
  5. -? topic            show help     查看帮助
  6. -help topic         show help     查看帮助
  7. --help topic        show help     查看帮助
  8. -version            show version   查看版本
  9. -buildconf          show build configuration   查看构建的配置文件信息
  10. -formats            show available formats     查看可以解复用(拆解成视频,音频,字幕文件)和复用(合并成视频,音频,字幕)的格式(包括视频,音频,字幕的编解码格式)和驱动的格式
  11. -muxers             show available muxers    单独查看可以合并的视频,音频,字幕编码格式
  12. -demuxers           show available demuxers   单独查看可以拆解的视频,音频,字幕编码格式
  13. -devices            show available devices     单独查看复用和解复用,可用驱动
  14. -codecs             show available codecs     查看编码器和解码器
  15. -decoders           show available decoders   
  16. -encoders           show available encoders
  17. -bsfs               show available bit stream filters
  18. -protocols          show available protocols
  19. -filters            show available filters
  20. -pix_fmts           show available pixel formats
  21. -layouts            show standard channel layouts
  22. -sample_fmts        show available audio sample formats
  23. -colors             show available color names
  24. -sources device     list sources of the input device
  25. -sinks device       list sinks of the output device
  26. -hwaccels           show available HW acceleration methods

  27. 全局指令
  28. Global options (affect whole program instead of just one file:
  29. -loglevel loglevel  set logging level
  30. -v loglevel         set logging level
  31. -report             generate a report
  32. -max_alloc bytes    set maximum size of a single allocated block
  33. -y                  overwrite output files
  34. -n                  never overwrite output files
  35. -ignore_unknown     Ignore unknown stream types
  36. -filter_threads     number of non-complex filter threads
  37. -filter_complex_threads  number of threads for -filter_complex
  38. -stats              print progress report during encoding
  39. -max_error_rate maximum error rate  ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
  40. -bits_per_raw_sample number  set the number of bits per raw sample
  41. -vol volume         change audio volume (256=normal)

  42. 文件操作
  43. Per-file main options:
  44. -f fmt              force format
  45. -c codec            codec name
  46. -codec codec        codec name
  47. -pre preset         preset name
  48. -map_metadata outfile[,metadata]:infile[,metadata]  set metadata information of outfile from infile
  49. -t duration         record or transcode "duration" seconds of audio/video
  50. -to time_stop       record or transcode stop time
  51. -fs limit_size      set the limit file size in bytes
  52. -ss time_off        set the start time offset
  53. -sseof time_off     set the start time offset relative to EOF
  54.   例子ffmpeg -sseof -10 -i input.mp4 output.mp4    #-10是指负值,负10秒
  55.   该获得一段不知道长度的视频的最后10秒,
  56.   请注意,在stream copy模式下(通过使用-c copy或等效模式),剪切将出现在最近的关键帧上,因此它可能会缩短您确切的所需时间.如果需要更高的准确性,则必须重新编码而不是流复制.
  57. -seek_timestamp     enable/disable seeking by timestamp with -ss
  58. -timestamp time     set the recording timestamp ('now' to set the current time)
  59. -metadata string=string  add metadata
  60. -program title=string:st=number...  add program with specified streams
  61. -target type        specify target file type ("vcd", "svcd", "dvd", "dv" or "dv50" with optional prefixes "pal-", "ntsc-" or "film-")
  62. -apad               audio pad
  63. -frames number      set the number of frames to output
  64. -filter filter_graph  set stream filtergraph
  65. -filter_script filename  read stream filtergraph description from a file
  66. -reinit_filter      reinit filtergraph on input parameter changes
  67. -discard            discard
  68. -disposition        disposition

  69. 视频相关
  70. Video options:
  71. -vframes number     set the number of video frames to output
  72. -r rate             set frame rate (Hz value, fraction or abbreviation)
  73. -s size             set frame size (WxH or abbreviation)
  74. -aspect aspect      set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
  75. -bits_per_raw_sample number  set the number of bits per raw sample
  76. -vn                 disable video
  77. -vcodec codec       force video codec ('copy' to copy stream)
  78. -timecode hh:mm:ss[:;.]ff  set initial TimeCode value.
  79. -pass n             select the pass number (1 to 3)
  80. -vf filter_graph    set video filters
  81. -ab bitrate         audio bitrate (please use -b:a)
  82. -b bitrate          video bitrate (please use -b:v)
  83. -dn                 disable data

  84. 音频相关
  85. Audio options:
  86. -aframes number     set the number of audio frames to output
  87. -aq quality         set audio quality (codec-specific)
  88. -ar rate            set audio sampling rate (in Hz)
  89. -ac channels        set number of audio channels
  90. -an                 disable audio
  91. -acodec codec       force audio codec ('copy' to copy stream)
  92. -vol volume         change audio volume (256=normal)
  93. -af filter_graph    set audio filters

  94. 字幕相关
  95. Subtitle options:
  96. -s size             set frame size (WxH or abbreviation)
  97. -sn                 disable subtitle
  98. -scodec codec       force subtitle codec ('copy' to copy stream)
  99. -stag fourcc/tag    force subtitle tag/fourcc
  100. -fix_sub_duration   fix subtitles duration
  101. -canvas_size size   set canvas size (WxH or abbreviation)
  102. -spre preset        set the subtitle options to the indicated preset

  103. 高级选项
  104. -map
复制代码



更多参数请查看
FFMPEG官方文档(英文)
http://ffmpeg.org/ffmpeg.html
FFMPEG官方文档(中文)
https://www.jianshu.com/p/da47b00c42ce

参考链接

https://blog.csdn.net/hemingwang0902/article/details/4382205
https://blog.csdn.net/xiaomucgwlmx/article/details/82852987
https://blog.csdn.net/leixiaohua1020/article/details/12751349
https://www.jianshu.com/p/049d03705a81
https://www.jianshu.com/p/124aee284a61
————————————————
版权声明:本文为CSDN博主「Bug 挖掘机」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011035397/article/details/108952604


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|我爱看高清论坛 ( 鄂ICP备15010622号-1 )

GMT+8, 2024-4-28 19:39

Powered by 52KHD.CN

© 2015-2023 俩木成林博客(看高清)

快速回复 返回顶部 返回列表