gpt4 book ai didi

c# - 在上传 HTML5 vid 服务器端实现转换

转载 作者:太空宇宙 更新时间:2023-11-03 11:35:49 26 4
gpt4 key购买 nike

我想在上传时将 wmv 转换为 mp4、webm 和 ogv。有没有办法在代码隐藏中实现 miro 视频转换器或类似的东西?

我用的是ACT的AsyncUpload

aspx 页面

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">

<script type="text/javascript">
function uploadError(sender, args) {
if (document.getElementById('<%=lblStatus.ClientID%>').innerText.indexOf('must be a video') == -1)
document.getElementById('<%=lblStatus.ClientID%>').innerText = "Upload error!", "<span style='color:red;'>" + args.get_errorMessage() + "</span>";
}

function StartUpload(sender, args) {
document.getElementById('<%=lblStatus.ClientID%>').innerText = 'Uploading';
}

function UploadComplete(sender, args) {
var filename = args.get_fileName();
var contentType = args.get_contentType();
if (contentType.indexOf('video') == -1) {
document.getElementById('<%=lblStatus.ClientID%>').innerText = "Uploaded file must be a video!", "<span style='color:red;'>" + args.get_errorMessage() + "</span>";
document.getElementById('<%=AsyncFileUpload1.ClientID%>').text.style.backgroundColor = "Red";
}
else {

var text = "" + filename + "\n" + "Size: " + parseInt((args.get_length()) / 1048576) + " MB" + " (" + args.get_length()+") bytes";
document.getElementById('<%=lblStatus.ClientID%>').innerText = text;
}
}
</script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">

<h1>Add Movies to storage</h1>

<p>File upload<p>
<br />
<asp:AsyncFileUpload ID="AsyncFileUpload1" Width="400px" runat="server" OnClientUploadError="uploadError"
OnClientUploadStarted="StartUpload" OnClientUploadComplete="UploadComplete" CompleteBackColor="Lime"
UploaderStyle="Modern" ErrorBackColor="Red" ClientIDMode="AutoID" ThrobberID="Throbber"
UploadingBackColor="#66CCFF" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />

<asp:Label class="lastoppimg" ID="Throbber" runat="server" CssClass="style1">
<img src="../Movies/LoadingImg.gif" style="left:auto; right:auto; height:32px; width:32px;" alt="loading" />
</asp:Label>
<br />
<asp:Button class="lastoppk" ID="Button1" runat="server" Text="Start Upload" OnClick="Button3_Click" />

<asp:Label ID="lblStatus" runat="server" Style="font-family: Arial; font-size: small;"></asp:Label>
</div>
</div>

代码隐藏

    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (AsyncFileUpload1.HasFile)
{
string strPath = MapPath("~/Test/") + Path.GetFileName(e.filename);
AsyncFileUpload1.SaveAs(strPath);
}
}

最佳答案

Miro 实际上使用 FFMpeg 进行转码。
您可以自己使用 FFMpeg 或更简单,您可以通过使用 MediaHandlerPro 从 .NET 使用它成分。 (他们也有免费版)

关于c# - 在上传 HTML5 vid 服务器端实现转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6330272/

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