gpt4 book ai didi

vba - 在 vba 中使用 ffmpeg 更改视频格式

转载 作者:行者123 更新时间:2023-12-04 23:17:19 25 4
gpt4 key购买 nike

我想更改演示文稿中显示的嵌入视频的视频格式。我使用以下代码将视频文件导出到另一个文件夹:

        Dim Finame As Variant
Dim oApp As Object
Dim StoreFolder As Variant
Dim Videoname As Variant
Dim FileNameFolder As Variant

MkDir "C:\template\videoZip"

Set oApp = CreateObject("Shell.Application")
FileNameFolder = "C:\template\videoZip\"
Finame = ActivePresentation.Path & "\" & ActivePresentation.Name
StoreFolder = "C:\template\created_files\"
oApp.Namespace("C:\template\videoZip\").CopyHere Finame
Name "C:\template\videoZip\" & ActivePresentation.Name As "C:\template\videoZip\" & ActivePresentation.Name & ".zip"


oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace("C:\template\videoZip\" & ActivePresentation.Name & ".zip").items

Dim firstCount As Integer
Dim lastCount As Integer

For j = 1 To videoNum
firstCount = oApp.Namespace(StoreFolder).items.count
Videoname = "C:\template\videoZip\ppt\media\media" & j & ".mp4"
oApp.Namespace(StoreFolder).CopyHere Videoname
lastCount = oApp.Namespace(StoreFolder).items.count
If firstCount = lastCount Then
MsgBox "The video has problems loading and it will not be shown (Only mp4 supported)"
End If
Next j

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.deletefolder "C:\template\videoZip"
End If

正如我所说,通过这种和平的代码,我可以获得演示文稿中的所有视频。现在我想改变它们的格式。我听说可以使用 ffmpeg。也欢迎其他更改格式的解决方案。

最佳答案

至少在 Linux 上,转换视频文件的语法是

ffmpeg -i media1.mp4 media1.avi

然后你有很多选项来处理大小、编解码器、修剪等。参见 ffmpeg documentation为了那个原因。

有一个 thread on SO关于执行 shell 命令并等待它们返回。
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
Dim errorCode As Integer
wsh.Run("C:\pathto\ffmpeg.exe -i media1.mp4 media1.avi", windowStyle, waitOnReturn)

关于vba - 在 vba 中使用 ffmpeg 更改视频格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16899482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com