Search code examples
.netnreco

Nreco ConvertMedia with settings VB.Net


Hello i am trying to make the below code work... but i am getting the error at conv.convertmedia line Value of type 'String' cannot be converted to 'FFMpegInput()'

    Dim conv = New NReco.VideoConverter.FFMpegConverter()
    AddHandler conv.ConvertProgress, AddressOf converter_progress
    Dim settings As New OutputSettings
    settings.SetVideoFrameSize(320, 320)
    settings.VideoCodec = "h264"
    Dim inputpath = TextBox1.Text
    conv.ConvertMedia(inputpath, "c:\temp\1.mkv", NReco.VideoConverter.Format.matroska, settings)

i tried to declare inputpath As FFMpegInput() but i couldnt manage to use it properly with convertmedia.

edit: found the solution

 Dim inputpaths As FFMpegInput() = {New FFMpegInput("video.mp4")}

    conv.ConvertMedia(inputpaths, "c:\temp\1.mkv", NReco.VideoConverter.Format.matroska, settings)

Solution

  • It seems you've specified incorrect number of ConvertMedia arguments; and you don't need to use overload that expects array of FFMpegInput if you have only one input file. In your original code you forgot to specify 2-nd parameter which determines input format (it can be null and in this case ffmpeg will autodetect input format):

    conv.ConvertMedia(inputpath, null, "c:\temp\1.mkv", NReco.VideoConverter.Format.matroska, settings)