当前位置: 首页 > news >正文

ffmpeg 声音参数_ffmpeg转换参数和压缩输出大小的比率

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

ffmpeg 转换压缩比例

FFMPEG如果是压缩为FLV文件 3个编码可选

1. -c:v flv 标准FLV编码 这个好处是速度快 清晰度高的话 视频文件会比较大

2. -c:v vp6 VP6编码 这个大家都很少使用 其实这个也算不错

3. -c:v libx264 H.264编码 估计使用这个的比较多 优点是同等清晰度 视频文件更小 缺点就是转换慢的吐血

以1.11G大小的电影 转换为例子

libx264 500k 出片为 572.36M

flv编码 清晰度5 出片为 872.94M

2个看起来flv的清晰度 还不如libx264的

竟然大了足足300M……

音频都是一样 都是Pass 1

下面是以前的备注文档 贴出来共享下

壓縮配置選項

===============================

512Kbps

視頻bitrate 設置為 360k 最大416k 音頻設置為64k

1Mbps

視頻bitrate 設置為720k 最大832k 音頻設置為 128k

2Mbps HD

視頻bitrate 設置為1550k 最大1792k 音頻設置為128k

視頻壓縮大小

===============================

出片 Bitrate 10分钟的视频

320p 180 kbit/s ~13 MB

360p 300 kbit/s ~22 MB

480p 500 kbit/s ~37 MB

576p 850 kbit/s ~63 MB (SD/PAL)

720p 1000 kbit/s ~75 MB

FFMPEG參數

===============================================

-i 輸入文件 test.avi 或其他

-c:v libx264 使用h.264 編碼

-vcodec libx264 強制指定視頻編碼模式

-profile:v high 使用H.264的High模式 比較消耗資源

-pre slow 使用慢速模式 耗時間 清晰度高

//該參數還可選擇 ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo

-b:v 360k / 720k / 1550k 視頻比特率 (該參數比較重要 如果是轉換Web用途 是否正確直接影響視頻播放流暢程度)

-maxrate 500k 最大比特率

-bufsize 1000k 比特率緩衝大小

-s 000×000

視頻大小 建议值

240P 320×240 //Mobile iPhone MP4

360P 640×360 //SD FLV

480P 864×480 //HD MP4

720P 960×720 //HD MP4

-threads 0 處理器核心利用數量

-aspect 16:9 / 4:3 視頻比例

-pass N 1-3可選

音頻

-acodec libfaac 強制指定音頻處理模式

-ac 2 聲道選擇

-ar 44100 音頻赫茲

-ab 128k 比特率 64k/128k

-acodec libfaac -ac 2 -ar 44100 -ab 64k

In this article we show how to resize any video file.This method is one of the bests ways to resize a video file in Linux systems (almost any distribution), and an excellent alternative to Windows and Mac users.

Changing the resolution of a video file will be one of the most common operations that we will perform when working with video files, and as such ffmpeg is able to do it perfectly. There are several reasons why we should want to change the resolution of a video file, for example:

To reduce the size of the video. This is possible by reducing the resolution of the video. If we take for example a video in HD (1920x1080 pixels) but we know that we will never see on a screen that supports a higher resolution than say 1024x768, we can reduce the video resolution to adapt to this new resolution, saving plenty of storage space and if used on Internet, saving bandwidth also.

Many times the resolution is changed on video files to standardize its format. That is, if we have several videos and we want them all in the same resolution, will have to go through this process of changing resolution.

In the development of modern websites it is quite useful to have the videos in various resolutions depending on where they appear. We can develop sites with responsive designs in which the most suitable video for the user plays. For example, if we have a video in various formats-we say 1920x1080, 1280x720, and 640x360- we can design a responsive site that makes visitors reproduce the proper video resolution depending on visitor browser saving bandwith (keep in mind that mobile users usually pay for transferred data so it is better to transfer as less traffic as possible)

In this example we will reduce the resolution of a video in HD format (1920x1080 pixels) to 640x360 (this is a fairly used configuration for aspect ratio 16:9):

ffmpeg -i video_1920.mp4 -vf scale=640:360 video_640.mp4 -hide_banner

It is only necessary to indicate the scale video filter with the new desired resolution (640:360) with -vf scale=640:360. To consider:

We can indicate any resolution we want, but the resulting video will always have the same aspect ratio. That is, it will not distort the images, if video is in 16:9 aspect ratio, it will keep the video in 16:9 aspect ratio. The program will adjust the resulting video so it can fit in the resolution that we have given.

When changing resolution, the video must go throught the encoding process another time, so the process can be slow depending on the output format and the codec you're using for the output.

We have not mentioned it, but most of the time it does not make sense to transform a video to a higher resolution because, there can't be any improvement in video quality.

Changing the video aspect ratio

If we want to change the look of the video, knowing that the image will appear distorted, we can use an additional filter "setdar". Imagine that in the previous case we want to change the 16:9 aspect ratio to 4:3, and therefore the video at a resolution of 4:3 aspect ratio, which in this case it will be 640x480. The ffmpeg command to make this transformation would be:

ffmpeg -i video_1920.mp4 -vf scale=640:480,setdar=4:3 video_640x480.mp4 -hide_banner

The video output that we get in this case video_640x480.mp4 changes the appearance of the original video and has distorted images a bit, but it will get the resolution we want with new look.

If on the other hand, we do not want to rely on using an aspect ratio which could be "more normal" (4:3, 16:9) or if we want to make changes to other resolutions with undefined aspect ratio and we are not afraid of possible deformations of images that will appear, we can use the "setsar" filter that will save you from having to keep those aspect ratios. In this way we could transform the previous video to a resolution of 200x400 for example, with the following command:

ffmpeg -i video_1920.mp4 -vf scale=200:400,setsar=1:1 video_200x400.mp4 -hide_banner

The result in 200x400 resolution from 1920x1080 resolution makes the video output to have a distorted appearance.

Examples of video resizing

We are going to see some examples of video resizing using ffmpeg. We have an original video with a resolution of 320x180 pixels. Here it is.

As we have seen previously we can resize the video to half its original size. We are resizing it from a 320x180 pixels resolution to a 160x90 pixels resolution with the following command:

ffmpeg -i video_320x180.mp4 -vf scale=160:90 video_180x90.mp4 -hide_banner

The video has gone from a size of 1.18MB to a 354KB video (one quarter). Here is the result:

Note that the video is smaller, but we can tell the browser to make it bigger with some loss of quality compared to the original.

Now let's change the original video aspect ratio from 16:9 to 4:3. To do this we are resizing video from 320x180 to 320x240 with the following command:

ffmpeg -i video_320x180.mp4 -vf scale=320:240,setdar=4:3 video_320x240.mp4 -hide_banner

And here is the result (you can see that images appear distorted):

And now at last we will resize the video as if it has to fit in a vertical screen, so we resize from 320x180 pixels to 180x320 pixels. Here is the command which will do the task:

ffmpeg -i video_320x180.mp4 -vf scale=180:320,setsar=1:1 video_180x320.mp4 -hide_banner

And here is the distorted result:

Note that in this videos I have also included a source in webm format for maximum compatibility. I have done this way so if your browser is not able to work directly with mp4 files you can see the results in a similar webm file.

相关文章:

  • 网页顶部进度条-NProcess.js
  • log4j 源码解析_log4j的使用详细解析
  • 一个简单的存储过程的学习以及使用
  • 除中文外的正则_优质中文NLP资源集合,做项目一定用得到!
  • 快速幂取模算法代码
  • 三十天学会绘画pdf_素描基础必学的观察法,全套PDF电子书下载!
  • .NET Core 版本不支持的问题
  • all方法 手写promise_Promise 所有方法实现
  • Java 的单元测试
  • 以下不属于时序逻辑电路的有_学习笔记:时序电路基础
  • 【字符串处理】关于KMP算法输出的是什么代码
  • 好分数阅卷3.0_揭秘!自考阅卷的批改套路!
  • 手机沙盒隔离软件_最好别装手机杀毒软件,不仅没用反而是累赘!
  • 一个简单的注册页面
  • 主进程和子进程_Python 简明教程 26,Python 多进程编程
  • 《Javascript数据结构和算法》笔记-「字典和散列表」
  • 【译】React性能工程(下) -- 深入研究React性能调试
  • 【跃迁之路】【641天】程序员高效学习方法论探索系列(实验阶段398-2018.11.14)...
  • Hibernate【inverse和cascade属性】知识要点
  • JavaScript对象详解
  • MYSQL如何对数据进行自动化升级--以如果某数据表存在并且某字段不存在时则执行更新操作为例...
  • WePY 在小程序性能调优上做出的探究
  • 函数式编程与面向对象编程[4]:Scala的类型关联Type Alias
  • 利用DataURL技术在网页上显示图片
  • 爬虫进阶 -- 神级程序员:让你的爬虫就像人类的用户行为!
  • 少走弯路,给Java 1~5 年程序员的建议
  • 首页查询功能的一次实现过程
  • 看到一个关于网页设计的文章分享过来!大家看看!
  • 说说我为什么看好Spring Cloud Alibaba
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • ​马来语翻译中文去哪比较好?
  • #pragma pack(1)
  • (01)ORB-SLAM2源码无死角解析-(56) 闭环线程→计算Sim3:理论推导(1)求解s,t
  • (1)(1.19) TeraRanger One/EVO测距仪
  • (Redis使用系列) SpringBoot 中对应2.0.x版本的Redis配置 一
  • (笔试题)合法字符串
  • (草履虫都可以看懂的)PyQt子窗口向主窗口传递参数,主窗口接收子窗口信号、参数。
  • (超简单)构建高可用网络应用:使用Nginx进行负载均衡与健康检查
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (规划)24届春招和25届暑假实习路线准备规划
  • (力扣题库)跳跃游戏II(c++)
  • (求助)用傲游上csdn博客时标签栏和网址栏一直显示袁萌 的头像
  • (心得)获取一个数二进制序列中所有的偶数位和奇数位, 分别输出二进制序列。
  • (转载)CentOS查看系统信息|CentOS查看命令
  • *setTimeout实现text输入在用户停顿时才调用事件!*
  • .NET 8 中引入新的 IHostedLifecycleService 接口 实现定时任务
  • .NET 使用 JustAssembly 比较两个不同版本程序集的 API 变化
  • .NET/C# 使用 ConditionalWeakTable 附加字段(CLR 版本的附加属性,也可用用来当作弱引用字典 WeakDictionary)
  • .NET应用架构设计:原则、模式与实践 目录预览
  • .考试倒计时43天!来提分啦!
  • ??在JSP中,java和JavaScript如何交互?
  • @Autowired自动装配
  • [].shift.call( arguments ) 和 [].slice.call( arguments )
  • []常用AT命令解释()
  • [2016.7.Test1] T1 三进制异或