分类目录归档:视频技术

ffmpeg剪辑视频

标准例子:

ffmpeg -i input.mp4 -ss 01:19:27 -to 02:18:51 -c copy output.mp4

这里-ss 表示开始时间, -to 表示结束时间

从开始位置截取多少时长的内容:

ffmpeg -i input.mp4 -ss 00:01:10 -t 00:01:05 -c copy output.mp4

这里引用了-t : duration 参数, 控制了截取视频的时长

那么, 以上做法有什么缺点么?

有的, 一个是慢, 一直在seeking 那个时间的样子, 另一个是画面容易在开始时候黑屏

优化方式:

ffmpeg -ss 01:19:27 -i input.mp4 -to 02:18:51 -c copy output.mp4

这里的技巧是把-ss提前了, 相当于让ffmpeg索引到关键帧, 缺点是会重置时间, 所以这里的-to 参数就相当于-t duration了

参考文档:

https://www.arj.no/2018/05/18/trimvideo/

ffmpeg av1编码

AV1编码由来

Apple、亚马逊、思科、 Google、英特尔、 微软、Mozilla 以及 Netflix 等厂商又共同组建了 Alliance for Open Media(开放媒体联盟)并在 2018 年推出了对抗 H.265 的新视频编码 AV1(AOMedia Video 1)

AV1编码优缺点

1.     优点

可以在同等质量下, 相对于H265/VP9  节省 30%+的码率, 相当于H264节省50%+的码率

libaom-av1 can save about 30% bitrate compared to VP9 and H.265 / HEVC, and about 50% over H.264, while retaining the same visual quality.

H264: 112m     H265: 55M     av1:  32M

2.     缺点

解码/编码非常耗费CPU, 目前未见到有编码级别的硬件加速

1)     解码, 从youtube的介绍看AV1 需要一台功能强大的计算机, 暗示了CPU耗费巨大, 测试了macOS和win10, 都能正常播放, 但是耗费的CPU比VP9多20~50%

从文档看, 解码级别的硬件加速已经有了, 包括intel 12代cpu和 nvidia的CUDA都可以

2)     编码: 目前没看到有硬件加速方式, 评价最好的为svt-av1编码

a)    Libaom-av1

             默认av1编码 参数  速率 基本处于不可用状态, 只有0.00x 倍, 需要通过调整-cpu-used参数和使用2pass 方式实现性能码率的均衡, 不过也挺慢的

可以看到在cpuused 5 附近, 码率和质量达到了比较好的平衡

ffmpeg -y -i Black.Widow.mp4 -ss 00:39:06 -to 00:42:00 -c:v libaom-av1 -strict -2 -b:v 3000K -maxrate 6000K -cpu-used 8 -pass 1 -f matroska NUL & d:/ffmpeg/bin/ffmpeg -i Black.Widow.mp4 -ss 00:39:06 -to 00:42:00 -c:v libaom-av1 -strict -2 -b:v 1500K -maxrate 3000K -cpu-used 5 -pass 2 black.libaom-av1.sample.2pass.mkv

b)    Svt-av1 : intel 和 Netflix的方案

libsvtav1 is the Intel x86-64 codec for AV1. Compile with --enable-libsvtav1. See ​FFmpeg doc and ​upstream doc.

The range of options are similar to that of libaom (aomenc). It is supposed to be faster than libaom while having comparable quality.

40 核 Intel(R) Xeon(R) CPU Silver4210 @2.2G , windows server 2019 平台, 默认参数下可以实现2X 的编码, 代价是质量稍微有点模糊

ffmpeg -y -i Black.Widow.mp4 -ss 00:39:06 -to 00:42:00 -c:v libsvtav1 -preset 4

c)     Rav1e

Rav1e claims to be the fastest software AV1 encoder, but that really depends on the setting.  速度不行, 目前看暂不可用

d)    爱奇艺自研方案

为了进一步提高编码效率,爱奇艺基于AV1标准独立自主研发出QAV1编码器,极大缓解了AV1计算复杂度高、编码时间长的问题,进而加速AV1应用效率。测试显示,与目前最流行的编码器X265相比,QAV1编码器可以节省40%以上码率,进而可以减小将近一半的带宽;在同等的压缩率下,QAV1编码器比由Netflix与英特尔联合推出的开源编码器SVT-AV1快5倍左右。借助QAV1编码器,AV1视频播放会更加流畅,同时帮助用户节省大量流量。

e)    商业化方案 微帧科技

参考文档

https://trac.ffmpeg.org/wiki/Encode/AV1

https://sspai.com/post/59174

https://gitlab.com/AOMediaCodec/SVT-AV1

https://www.streamingmedia.com/Articles/Editorial/Featured-Articles/AV1-Has-Arrived-Comparing-Codecs-from-AOMedia-Visionular-and-Intel-Netflix-142941.aspx?utm_source=related_articles&utm_medium=gutenberg&utm_campaign=editors_selection

windows media server 2008 Limit user rights

Microsoft tell us,you can limit user rights in WMS by:

By default, Windows Media Services can only be accessed by users in the Administrators group. To limit user rights effectively while still enabling users to administer Windows Media Services, you can remove users from the Administrators group and then add them to Windows Media Services only. To add users directly to Windows Media Services, you must use Component Services to configure access permissions for the Windows Media Services Component Object Model (COM) object.

To provide a user administrative rights to Windows Media Services
On your server, start the DCOM config utility.

Locate Windows Media Services in the list, and open its properties.

On the Security tab, edit the access permissions.

The Access Permissions list shows the users and user groups that can administer Windows Media Services.

Add the users or groups that you want to be able to administer Windows Media Services, and then close the dialog boxes.

The new settings will take effect when you restart Windows Media Services.

微软告诉我们,可以限制用户权限,使用非管理员的帐号:

默认情况下,只有 Administrators 组中的用户才可以访问 Windows Media Services。若要有效地限制用户权限,同时仍允许用户管理 Windows Media Services,您可以从 Administrators 组中删除用户,然后将其仅添加到 Windows Media Services。若要将用户直接添加到 Windows Media Services,您必须使用“组件服务”为 Windows Media Services 组件对象模型 (COM) 对象配置访问权限。
为用户提供对 Windows Media Services 的管理权限的步骤
在您的服务器上,启动 DCOM 配置实用工具。

在列表中找到 Windows Media Services,并打开其属性。

在“安全”选项卡上,编辑访问权限。

“访问权限”列表显示了可以管理 Windows Media Services 的用户和用户组。

添加希望能够管理 Windows Media Services 的用户或组,然后关闭对话框。

在重新启动 Windows Media Services 后,新的设置将生效。

In fact,when you open DCOMcnfg,you will find that the Security Permission of “Windows Media Services” is grey and disabled.

实际上,当你打开组件管理器,你会发现”Windows Media Services”的权限设置选项是灰色的,无法修改.

This is the new security feather of win2008 R2 x64. Some core system components only grant the local internal account, TrustedInstaller, Full Control permission instead of the local Administrators group.

这个是win2008 R2 x64的安全特性.一些核心系统组件只能允许本地帐号,TrustedInstaller有完全控制权限,而不是本地管理员组.

To be able to modify the settings of “Windows Media Services” on a Windows Server 2008 R2 system, you need to grant the local Administrators group permissions to its registry key as follows:

要在Windows Server 2008 R2 上修改 “Windows Media Services” ,你需要授予本地管理员组有注册表权限:

1. Check the Appid of WMS in “Component Services management console (dcomcnfg.exe)”.On my machine it is {A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF}
2. Run Regedit.exe and browse to “HKEY_CLASSES_ROOT\AppID\{A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF}” key.
3. Secondary-mouse click on the {A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF} key and select Permissions…
4. Click the Advanced button in the Permissions window and select the Owner tab. Under Change owner to select the local Administrators group and click on Apply, then OK.
5. Then under Permissions window, select the local Administrators group and under Permissions for Administrators select Full Control and click on Apply, then OK.
NOTE: DO NOT modify/change any permissions for the TrustedInstaller account.

1.在组件管理器中查到WMS的appid,在我的机器上,它的ID是{A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF}
2.使用regedit,定位到HKEY_CLASSES_ROOT\AppID\{A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF}”
3.右键点击{A2EFA5CB-3B0E-11D2-9EFD-006097D2D7CF},选权限
4.在权限设置窗口中点高级,选择所有者标签,选中administrators为所有者
5.授予administrators组有读/写等所有权
注意:务必不要修改TrustedInstaller的权限

Now,re-run Component Services management console (dcomcnfg.exe), you can follow the steps of Microsoft to configure access permissions for the Windows Media Services Component Object Model (COM) object.

现在,重新执行组件管理器,你就能根据前文中微软的步骤来配置Windows Media Services的访问权限了.

PS.There is a bug of Windows Media Services in win2003(not in win2008),if you(limit user) exit the wmsadmin and then start it again, you will get error code 0xc00d0006 and the server no longer shows up in the wmsadmin. You have to once again add it using “localhost” every time .

PS. windows 2003 的 Windows Media Services有个bug(win2008没有):每次退出wmsadmin再次开启,受限用户会收到错误0xc00d0006提示说无法与服务器建立连接,并且服务器不再显示在wmsadmin中,你必须再次添加”localhost”进去.

see more about:

http://technet.microsoft.com/en-us/library/cc753241(WS.10).aspx
http://blogs.msdn.com/b/emeadaxsupport/archive/2010/01/26/unable-to-edit-the-dcom-settings-for-iis-wamreg-admin-service-on-a-windows-server-2008-r2-when-trying-to-configure-kerberos-authentication-for-role-centers.aspx