读书人

在ASP.net中怎么像56优酷等视频网站样

发布时间: 2012-04-03 12:38:19 作者: rapoo

在ASP.net中如何像56优酷等视频网站样把上传的视频自动转为Flv格式的?
在ASP.net中如何像56优酷等视频网站样把上传的视频自动转为Flv格式的?

上网搜了一下,说是要用到ffmpeg但是不知道具体要怎么做。。。请知道的告知一下。。

[解决办法]
以下代码是用vb.net写的,你可以转换成c#.net


Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Diagnostics
'此程序实现视频预览与转换
Partial Class v
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
' preview frame

Dim ffmpeg As Process
' creating process
Dim video As String
Dim thumb As String
video = Page.MapPath("1.wmv")
' setting video input name with path
thumb = Page.MapPath("") + "\frame.jpg"
' thumb name with path !
ffmpeg = New Process()

'ffmpeg.StartInfo.Arguments = " -i """ + video + """ -s 108*80 -vframes 1 -f image2 -vcodec mjpeg """ + thumb + """"
ffmpeg.StartInfo.Arguments = " -i """ + video + """ -y -s 350x240 -vframes 1 -f image2 -vcodec mjpeg """ + thumb + """"
' arguments !
ffmpeg.StartInfo.FileName = Page.MapPath("\App_Code\ffmpeg.exe")
ffmpeg.Start()
' start !

End Sub
Protected Sub convert_Click(ByVal sender As Object, ByVal e As EventArgs)
'converting video

Dim ffmpeg As Process
' creating process
Dim video As String
Dim mpg As String
video = Page.MapPath("1.wmv")
' setting video input name with path
mpg = Page.MapPath("") + "\u.wmv"
' thumb name with path !
ffmpeg = New Process()

ffmpeg.StartInfo.Arguments = " -i """ + video + """ -target vcd """ + mpg + """"
' arguments !
ffmpeg.StartInfo.FileName = Page.MapPath("\App_Code\ffmpeg.exe")
ffmpeg.Start()
' start !
End Sub

End Class

读书人网 >asp.net

热点推荐