Search code examples
c#textboxbitratenreco

How to change bitrate with nreco functions using textbox?


I'm trying to write a converter in C # using Nreco.VideoConverter. I've never had any experience with these before. I started researching this area because I was asked at work. My problem is; I can change the bitrate value in video converter. If you have a combobox or a specific value. But, if there is any value to enter from the textbox, I cannot adapt the code accordingly. Below is the code I use. Please help.

Code is;

  if (comboBox2.Text == "_1000kbit")
    {
    if (comboBox1.Text == "mp4" || comboBox1.Text == "mp4 1280 x 720 16 : 9" || comboBox1.Text == 
    "mp4 640 x 350 16 : 9" || comboBox1.Text == "mp4 720 x 540")
    {
     var ffmpeg = new NReco.VideoConverter.FFMpegConverter();
     ffmpeg.ConvertMedia(VideoPath, null, MusicPath, null, new ConvertSettings()
       {
       CustomOutputArgs = "-b:v 1000k -bufsize 1000k"
       });
       }

         }

but ı want do this;

 if (comboBox2.Text == "_1000kbit")
          {
           if (comboBox1.Text == "mp4" || comboBox1.Text == "mp4 1280 x 720 16 : 9" || 
            comboBox1.Text == "mp4 640 x 350 16 : 9" || comboBox1.Text == "mp4 720 x 540")
           {
              var ffmpeg = new NReco.VideoConverter.FFMpegConverter();
             ffmpeg.ConvertMedia(VideoPath, null, MusicPath, null, new ConvertSettings()
            {
          CustomOutputArgs = "-b:v"+textBox1.Text+"k -bufsize"+textBox1.Text+"k"
          });
          }

             }

So is it possible? how can i do it if possible? Because when I type it it says ffmpeg can't find the argument. By the way, I set the textbox value to int. Please help for this. Thank You.

What I have tried:

ı want do this; but is it possible or true I have no idea


Solution

  • Try this

     CustomOutputArgs = String.Format("-b:v {0}k -bufsize {0}k", textBox1.Text);
    

    Edit: Explaining problem in code Your CustomOutputArgs were turning out to be: -b:v1000k -bufsize1000k instead of -b:v 1000k -bufsize 1000k (Notice the spaces)