Imports System.IO
Imports System.Diagnostics
Imports System
Public Class VideoEditorForm
Private ffmpegPath As String = "C:\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe" '将此路径更改为您的 FFmpeg 实际安装路径
'储选中的视频文件路径
Private selectedVideoPath As String
'剪的起始时间(以秒为单位)
Private cropStartTime As Integer
'剪的结束时间(以秒为单位)
Private cropEndTime As Integer
' 存储选中的文件路径列表
Private selectedFilePaths As New List(Of String)
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim openFileDialog As New OpenFileDialog()
openFileDialog.Filter = "Video Files (*.mp4;*.avi;*.mkv; *.wmv)|*.mp4;*.avi;*.mkv; *.wmv"
If openFileDialog.ShowDialog() = DialogResult.OK Then
selectedVideoPath = openFileDialog.FileName
End If
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
If String.IsNullOrEmpty(selectedVideoPath) Then
MessageBox.Show("请先选择要保存的视频文件!")
Exit Sub
End If
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Filter = "MP4 Video (*.mp4)|*.mp4|AVI Video (*.avi)|*.avi|MKV Video (*.mkv)|*.mkv"
If saveFileDialog.ShowDialog() = DialogResult.OK Then
Dim outputPath As String = saveFileDialog.FileName
Dim fileExtension As String = Path.GetExtension(outputPath)
Dim process As New Process()
process.StartInfo.FileName = ffmpegPath
Select Case fileExtension.ToLower()
Case ".mp4"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -c:v libx264 -c:a aac " & Chr(34) & outputPath & Chr(34)
Case ".avi"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -c:v mpeg4 -c:a mp3 " & Chr(34) & outputPath & Chr(34)
Case ".mkv"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -c:v copy -c:a copy " & Chr(34) & outputPath & Chr(34)
End Select
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.Start()
While Not process.HasExited
Dim output As String = process.StandardOutput.ReadLine()
'以在此处理进程的输出信息
End While
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim openFileDialog As New OpenFileDialog()
openFileDialog.Filter = "Video Files (*.mp4;*.avi;*.mkv; *.wmv)|*.mp4;*.avi;*.mkv; *.wmv"
If openFileDialog.ShowDialog() = DialogResult.OK Then
selectedVideoPath = openFileDialog.FileName
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim openFileDialog As New OpenFileDialog()
openFileDialog.Multiselect = True
openFileDialog.Filter = "视频文件|*.mp4;*.avi;*.mkv;*.flv;*.wmv"
If openFileDialog.ShowDialog() = DialogResult.OK Then
Dim filePaths() As String = openFileDialog.FileNames
Dim concatListFile As String = Path.GetTempFileName()
Using sw As New StreamWriter(concatListFile)
For Each filePath As String In filePaths
sw.WriteLine("file '" & filePath & "'")
Next
End Using
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Filter = "MP4 Video (*.mp4)|*.mp4|AVI Video (*.avi)|*.avi|MKV Video (*.mkv)|*.mkv"
If saveFileDialog.ShowDialog() = DialogResult.OK Then
Dim outputPath As String = saveFileDialog.FileName
Dim fileExtension As String = Path.GetExtension(outputPath)
Dim process As New Process()
process.StartInfo.FileName = ffmpegPath
Select Case fileExtension.ToLower()
Case ".mp4"
process.StartInfo.Arguments = "-f concat -safe 0 -i " & Chr(34) & concatListFile & Chr(34) & " -c:v libx264 -c:a aac " & Chr(34) & outputPath & Chr(34)
Case ".avi"
process.StartInfo.Arguments = "-f concat -safe 0 -i " & Chr(34) & concatListFile & Chr(34) & " -c:v mpeg4 -c:a mp3 " & Chr(34) & outputPath & Chr(34)
Case ".mkv"
process.StartInfo.Arguments = "-f concat -safe 0 -i " & Chr(34) & concatListFile & Chr(34) & " -c:v copy -c:a copy " & Chr(34) & outputPath & Chr(34)
End Select
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.Start()
While Not process.HasExited
Dim output As String = process.StandardOutput.ReadLine()
'以在此处理进程的输出信息
End While
End If
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'择导出保存的路径和格式
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Filter = "MP4 文件|*.mp4|AVI 文件|*.avi|MKV 文件|*.mkv|FLV 文件|*.flv|WMV 文件|*.wmv"
If saveFileDialog.ShowDialog() = DialogResult.OK Then
Dim exportPath As String = saveFileDialog.FileName
'此处进行导出保存的后续处理
Console.WriteLine("导出保存的路径: " & exportPath)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If String.IsNullOrEmpty(selectedVideoPath) Then
MessageBox.Show("请先选择要裁剪的视频文件!")
Exit Sub
End If
'取用户输入的裁剪起始时间和结束时间
If Not Integer.TryParse(TextBoxCropStart.Text, cropStartTime) OrElse Not Integer.TryParse(TextBoxCropEnd.Text, cropEndTime) Then
MessageBox.Show("请输入有效的裁剪时间(整数,以秒为单位)!")
Exit Sub
End If
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Filter = "MP4 Video (*.mp4)|*.mp4|AVI Video (*.avi)|*.avi|MKV Video (*.mkv)|*.mkv"
If saveFileDialog.ShowDialog() = DialogResult.OK Then
Dim outputPath As String = saveFileDialog.FileName
Dim fileExtension As String = Path.GetExtension(outputPath)
Dim process As New Process()
process.StartInfo.FileName = ffmpegPath
Select Case fileExtension.ToLower()
Case ".mp4"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -ss " & cropStartTime & " -to " & cropEndTime & " -c:v libx264 -c:a aac " & Chr(34) & outputPath & Chr(34)
Case ".avi"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -ss " & cropStartTime & " -to " & cropEndTime & " -c:v mpeg4 -c:a mp3 " & Chr(34) & outputPath & Chr(34)
Case ".mkv"
process.StartInfo.Arguments = "-i " & Chr(34) & selectedVideoPath & Chr(34) & " -ss " & cropStartTime & " -to " & cropEndTime & " -c:v copy -c:a copy " & Chr(34) & outputPath & Chr(34)
End Select
process.StartInfo.U
没有合适的资源?快使用搜索试试~ 我知道了~
VS2010旗舰版VB.NET版本视频剪辑源代码QZQ-2024-8-11 -简化版.zip
共40个文件
vb:8个
mp4:5个
exe:3个
需积分: 5 0 下载量 147 浏览量
2024-08-11
20:28:46
上传
评论
收藏 72.3MB ZIP 举报
温馨提示
VS2010旗舰版VB.NET版本视频剪辑源代码QZQ-2024-8-11 -简化版.zip
资源推荐
资源详情
资源评论
收起资源包目录
VS2010旗舰版VB.NET版本视频剪辑源代码QZQ-2024-8-11 -简化版.zip (40个子文件)
VS2010旗舰版VB.NET版本视频剪辑源代码QZQ-2024-8-11 -简化版
ffmpeg-master-latest-win64-gpl-shared.zip 57.5MB
a代码.txt 8KB
4.mp4 1.02MB
a
Form1.Designer.vb 6KB
a.vbproj.user 143B
My Project
Settings.Designer.vb 3KB
Application.myapp 479B
Resources.Designer.vb 3KB
AssemblyInfo.vb 1KB
Application.Designer.vb 1KB
Settings.settings 279B
Resources.resx 5KB
obj
x86
Release
Debug
a.pdb 52KB
a.Resources.resources 180B
a.VideoEditorForm.resources 180B
a.xml 636B
DesignTimeResolveAssemblyReferencesInput.cache 6KB
a.vbproj.GenerateResource.Cache 975B
TempPE
My Project.Resources.Designer.vb.dll 8KB
a.vbproj.FileListAbsolute.txt 5KB
a.exe 29KB
DesignTimeResolveAssemblyReferences.cache 3KB
Form1.vb 8KB
a.vbproj 5KB
bin
Release
Debug
a.pdb 52KB
Form1.Designer.vb 6KB
a.xml 636B
Form1.vb 8KB
a.vshost.exe.manifest 490B
a.exe 29KB
a.vshost.exe 11KB
Form1.resx 6KB
Form1.resx 6KB
a.suo 22KB
样板1.mp4 12.06MB
a代码0.txt 14KB
1.mp4 606KB
3.mp4 588KB
2.mp4 525KB
a.sln 845B
共 40 条
- 1
资源评论
EYYLTV
- 粉丝: 3153
- 资源: 1283
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功