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

发布于 2024-11-15 04:53:35 字数 3048 浏览 2 评论 0原文

我想在上传时将 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>

Codebehind

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

I want to convert from wmv to mp4, webm and ogv on upload.
is there a way to implement miro video converter or something like at codebehind?

what i use is ACT's AsyncUpload

aspx page

<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>

Codebehind

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2024-11-22 04:53:35

Miro 实际上使用 FFMpeg 进行转码。
您可以自己使用 FFMpeg,也可以更轻松地使用 FFMpeg,您可以通过使用 MediaHandlerPro 组件从 .NET 使用它。 (他们也有免费版本)

Miro is actually using FFMpeg for its transcoding.
You can use FFMpeg yourself or easier, You can use it from .NET by using the MediaHandlerPro component. (They also have a free version)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文