Search code examples
c#visual-studioffmpegmpeg-4mpeg-2

C # FFMPEG I GET ERRORS IN MPEG2 AND MPEG4 FORMAT?


I am making a converter using the ffmepg library via c # form. I can convert all my videos to whatever format I want. But I get the following error in mpeg2, mpeg, mpeg4 formats. My code is;

if (comboBox1.Text == "mpeg2")
            {
                var convert = new NReco.VideoConverter.FFMpegConverter();
                convert.ConvertMedia(VideoPath, MusicPath, "mpeg2");
                MessageBox.Show("convert is okey");
            }

**is my fault; **NReco.VideoConverter.FFMpegException: 'C:\Users\zbaran\Videos\New folder\ converted Alan Walker, Sabrina Carpenter & Farruko - On My Way.webm.mpeg2: Invalid argument (exit code: 1)'

what should I do? Please Help! But the other format is working. I havent any error.


Solution

  • I had a look at the documentation: https://www.nrecosite.com/doc/NReco.VideoConverter/ and it seems like they have a Format class. The string they use for mpeg is just "mpeg". So, this should work:

    convert.ConvertMedia(VideoPath, MusicPath, "mpeg");
    

    or this

    convert.ConvertMedia(VideoPath, MusicPath, Format.mpeg);
    

    mpeg4 would be

    convert.ConvertMedia(VideoPath, MusicPath, "mp4");