ASP.net FFMPEG video conversion receiving error: "Error number -2 occurred"

Posted by Pete on Stack Overflow See other posts from Stack Overflow or by Pete
Published on 2010-05-03T19:20:42Z Indexed on 2010/05/03 19:28 UTC
Read the original article Hit count: 770

Filed under:
|
|
|
|

Hello,

I am attempting to integrate FFMPEG into my asp.net website. The process I am trying to complete is to upload a video, check if it is .avi, .mov, or .wmv and then convert this video into an mp4 using x264 so my flash player can play it.

I am using an http handler (ashx) file to handle my upload. This is where I am also putting my conversion code. I am not sure if this is the best place to put it, but I wanted to see if i could at least get it working.

Additionally, I was able to complete the conversion manually through cmd line. The error -2 comes up when i output the standard error from the process I executed.

This is the error i receive:

FFmpeg version SVN-r23001, Copyright (c) 2000-2010 the FFmpeg developers

built on May 1 2010 06:06:15 with gcc 4.4.2

configuration: --enable-memalign-hack --cross-prefix=i686-mingw32- --cc=ccache-i686-mingw32-gcc --arch=i686 --target-os=mingw32 --enable-runtime-cpudetect --enable-avisynth --enable-gpl --enable-version3 --enable-bzlib --enable-libgsm --enable-libfaad --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg --enable-libxvid --enable-libschroedinger --enable-libx264 --enable-libopencore_amrwb --enable-libopencore_amrnb

libavutil 50.15. 0 / 50.15. 0 libavcodec 52.66. 0 / 52.66. 0 libavformat 52.61. 0 / 52.61. 0 libavdevice 52. 2. 0 / 52. 2. 0 libswscale 0.10. 0 / 0.10. 0

532010_Robotica_720.wmv: Error number -2 occurred

here is the code below:

<%@ WebHandler Language="VB" Class="upload" %>

Imports System Imports System.Web Imports System.IO Imports System.Diagnostics Imports System.Threading

Public Class upload : Implements IHttpHandler

Public currentTime As System.DateTime

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    currentTime = System.DateTime.Now

    If (Not context.Request.Files("Filedata") Is Nothing) Then
        Dim file As HttpPostedFile : file = context.Request.Files("Filedata")

        Dim targetDirectory As String : targetDirectory = HttpContext.Current.Server.MapPath(context.Request("folder"))
        Dim targetFilePath As String : targetFilePath = Path.Combine(targetDirectory, currentTime.Month & currentTime.Day & currentTime.Year & "_" & file.FileName)

        Dim fileNameArray As String()
        fileNameArray = Split(file.FileName, ".")

        If (System.IO.File.Exists(targetFilePath)) Then
            System.IO.File.Delete(targetFilePath)
        End If

        file.SaveAs(targetFilePath)

        Select Case fileNameArray(UBound(fileNameArray))
                Case "avi", "mov", "wmv" 
                    Dim fileargs As String = 
                    fileargs = "-y -i " & currentTime.Month & currentTime.Day & 
                    currentTime.Year & "_" & file.FileName & " -ab 96k -vcodec libx264 
                    -vpre normal -level 41 "
                    fileargs += "-crf 25 -bufsize 20000k -maxrate 25000k -g 250 -r 20 
                    -s 900x506 -coder 1 -flags +loop "
                    fileargs += "-cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 
                    -subq 7 -me_range 16 -keyint_min 25 "
                    fileargs += "-sc_threshold 40 -i_qfactor 0.71 
                    -rc_eq 'blurCplx^(1-qComp)' -bf 16 -b_strategy 1 -bidir_refine 1 "
                    fileargs += "-refs 6 -deblockalpha 0 -deblockbeta 0 -f mp4 " &   
                    currentTime.Month & currentTime.Day & currentTime.Year & "_" & 
                    file.FileName & ".mp4"

                    Dim proc As New Diagnostics.Process()
                    proc.StartInfo.FileName "ffmpeg.exe"
                    proc.StartInfo.Arguments = fileargs
                    proc.StartInfo.UseShellExecute = False
                    proc.StartInfo.CreateNoWindow = True
                    proc.StartInfo.RedirectStandardOutput = True
                    proc.StartInfo.RedirectStandardError = True

                    AddHandler proc.OutputDataReceived, AddressOf SaveTextToFile

                    proc.Start()
                    SaveTextToFile2(proc.StandardError.ReadToEnd())
                    proc.WaitForExit()
                    proc.Close()
            End Select
        Catch ex As System.IO.IOException
            Thread.Sleep(2000)
            GoTo Conversion
        Finally
            context.Response.Write("1")
        End Try

    End If

End Sub

Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
    Get
        Return False
    End Get
End Property

Private Shared Sub SaveTextToFile(ByVal sendingProcess As Object, ByVal strData As DataReceivedEventArgs)

    Dim FullPath As String = "text.txt"
    Dim Contents As String = ""

    Dim objReader As StreamWriter
    objReader = New StreamWriter(FullPath)

    If Not String.IsNullOrEmpty(strData.Data) Then
        objReader.Write(Environment.NewLine + strData.Data)
    End If

    objReader.Close()

End Sub

Private Sub SaveTextToFile2(ByVal strData As String)

    Dim FullPath As String = "texterror.txt"
    Dim Contents As String = ""

    Dim objReader As StreamWriter
    objReader = New StreamWriter(FullPath)

    objReader.Write(Environment.NewLine + strData)

    objReader.Close()

End Sub

End Class

© Stack Overflow or respective owner

Related posts about ffmpeg

  • how to install ffmpeg in cpanel

    as seen on Super User - Search for 'Super User'
    i'm using dedicated server(linux) so i need to install ffmpeg in cpanel so here ffmpeg i found in Main Software Install a Perl Module but i writing script in php so how can i install ffmpeg phpperl when i'am trying to install ffmpeg in perl module i get this response Checking C compiler… >>> More

  • FFMpeg-PHP Installation Error

    as seen on Server Fault - Search for 'Server Fault'
    While installing FFmpeg-PHP, I got this interesting error: /usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c: In function 'zim_ffmpeg_movie_getAudioStreamId': /usr/downloads/ffmpeg-php-0.6.0/ffmpeg_movie.c:1051: error: 'CODEC_TYPE_AUDIO' undeclared (first use in this function) /usr/downloads/ffmpeg-php-0… >>> More

  • git problems installing stuff [closed]

    as seen on Super User - Search for 'Super User'
    root@Frenzen:~# cd root@Frenzen:~# git clone --depth 1 git://source.ffmpeg.org/ffmpeg Initialized empty Git repository in /root/ffmpeg/.git/ root@Frenzen:~# cd root@Frenzen:~# git clone --depth 1 git://source.ffmpeg.org/ffmpeg Initialized empty Git repository in /root/ffmpeg/.git/ root@Frenzen:~#… >>> More

  • Unable to install ffmpeg-php

    as seen on Server Fault - Search for 'Server Fault'
    I followed the instructions on http://www.mysql-apache-php.com/ffmpeg-install.htm but ffmpeg-php does not show up in my phpinfo() The commands I ran (in order) #yum install ffmpeg ffmpeg-devel ... Public key for faac-1.26-1.el5.rf.x86_64.rpm is not installed #rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0… >>> More

  • Unable to install ffmpeg-php

    as seen on Server Fault - Search for 'Server Fault'
    Hi, I followed the instructions on http://www.mysql-apache-php.com/ffmpeg-install.htm but ffmpeg-php does not show up in my phpinfo() The commands I ran (in order) #yum install ffmpeg ffmpeg-devel ... Public key for faac-1.26-1.el5.rf.x86_64.rpm is not installed #rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0… >>> More

Related posts about ASP.NET