使用PowerShell使用FFMPEG压缩大量视频

This post will likely win the award this month for "least useful and most obscure use of two totally unrelated tools to do a task that few folks ever would need to do and fewer would be interested in reading about" but I wanted to save it for myself for reference.

该帖子可能会因“对两种完全不相关的工具的最有用和最晦涩的使用来完成很少有人需要做而很少有兴趣阅读的任务”而获得本月的奖项,但我想将其保存下来自己供参考。

I've got a bunch of old TV shows that are in MPEG2 format that were recorded with BeyondTV from SnapStream. I don't want to toss them, but they are fat and wasting space. I'd like to have them available if I wanted to watch them on my PlayStation Portable, but using PSPVideo9 is tedious for more than a few files. Also, the version of FFMPEG that comes with PSPVideo9 is really old.

我有一堆老式的电视节目,它们都是MPEG2格式的,是用SnapStreamBeyondTV录制的。 我不想扔它们,但它们很肥,浪费空间。 如果想在PlayStation Portable上观看它们,我想让它们可用,但是使用PSPVideo9会花费很多文件。 另外,PSPVideo9随附的FFMPEG版本确实很旧。

You can get a binary copy of FFMPEG (as the project team releases source but not binaries) from this friendly fellow here.

您可以在这里从这个友好的同伴那里获得FFMPEG二进制副本(因为项目团队发布了源文件,但没有二进制文件)。

FFmpeg is a collection of free software that can record, convert and stream digital audio and video. It includes libavcodec, a leading audio/video codec library. FFmpeg is developed under Linux, but it can be compiled under most operating systems, including Windows. The project was started by Gerard Lantau, an alterego of Fabrice Bellard, and is now maintained by Michael Niedermayer. Notable is that most FFmpeg developers are part of either the MPlayer, xine or VideoLAN project as well. [Wikipedia]

FFmpeg是一组免费软件,可以记录,转换和流传输数字音频视频 它包括libavcodec (领先的音频/视频编解码器库)。 FFmpeg是在Linux开发的,但可以在大多数操作系统(包括Windows)下进行编译 该项目是由杰拉德屿,一开始的Alterego法布里斯·贝拉,现在由Michael Niedermayer维持。 值得注意的是,大多数FFmpeg开发人员也属于MPlayer xineVideoLAN项目。 [ Wikipedia ]

FFmpeg doesn't like WMV files very much, and they are compressed pretty well already. I wanted to run this ffmpeg command line...

FFmpeg不太喜欢WMV文件,并且它们已经被很好地压缩了。 我想运行这个ffmpeg命令行...

ffmpeg -i 'oldname.*' -f mp4 -r 25 -s 320×240 -b 768 -ar 44000 -ab 112 'newname.mp4'

ffmpeg -i'oldname。*'- f mp4 -r 25 -s 320×240 -b 768 -ar 44000 -ab 112'newname.mp4'

...on all my files that weren't WMV and convert my files to MP4 video at 320x240 and a decent bit rate.

...对所有不是WMV的文件,并将其以320x240的比特率和不错的比特率转换为MP4视频。

I used PowerShell to exclude this command line, build the filenames and ran this PowerShell command (pipeline) on my folder:

我使用PowerShell排除了此命令行,构建了文件名并在我的文件夹中运行了此PowerShell命令(管道):

dir -exclude *.wmv | foreach-object { $newname = $_.Basename + ".mp4"; ffmpeg -i "$_" -f mp4 -r 25 -s 320×240 -b 768 -ar 44000 -ab 112 $newname }

dir -exclude * .wmv | foreach-object {$ newname = $ _。Basename +“ .mp4”; ffmpeg -i“ $ _” -f mp4 -r 25 -s 320×240 -b 768 -ar 44000 -ab 112 $ newname}

Ran for a few hours and the PlayStation Portable is now happy with my copies of old TV shows that aren't on DVD yet.

跑了几个小时,PlayStation Portable现在对我还没有DVD的旧电视节目的副本感到满意。

NOTE: The System.IO.FileInfo object, returned from PowerShell's 'dir', doesn't have a "BaseName" property, so I've added a custom ScriptProperty to my "My.Types.ps1xml" file:

注意:从PowerShell的“ dir”返回的System.IO.FileInfo对象没有“ BaseName”属性,因此我向“ My.Types.ps1xml”文件中添加了自定义ScriptProperty:

<Types>
   <Type>
     <Name>System.IO.FileInfo</Name>
      <Members>
         <ScriptProperty>
           <Name>Basename</Name>
           <GetScriptBlock>
            $this.Name.Remove($this.Name.Length - $this.Extension.Length);
           </GetScriptBlock>
         </ScriptProperty>
      </Members>
   </Type>
</Types>

<类型> <类型> <名称> System.IO.FileInfo </名称> <会员> <ScriptProperty> <名称>基本名称</名称> <GetScriptBlock> $ this.Name.Remove($ this.Name.Length-$ this.Extension.Length); </ GetScriptBlock> </ ScriptProperty> </成员> </ Type> </ Types>

As outlined in this post called "BaseName for FileInfo objects" on the PowerShell team blog.

PowerShell团队博客上名为“ FileInfo对象的BaseName”的文章所述

翻译自: https://www.hanselman.com/blog/using-ffmpeg-to-squish-lots-of-videos-using-powershell

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值