Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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"
});
}

}
Posted
Comments
Richard MacCutchan 1-Oct-19 4:53am    
It is never a good idea to concatenate items directly from a textbox; in SQL it is positively dangerous. You should take the text items from the textboxes and validate them first. You can then use a StringBuilder or similar class to create your parameter string.

Also, using the debugger, or adding a simple display statement to your code, will allow you to examine the actual text in your CustomOutputArgs variable.
Mels Alex Barno 1-Oct-19 7:37am    
In fact, I thought of something like this at first; There would be variables in the combobox but my goal was to get those values by pulling them through enum. I did this with a little research. But then I couldn't understand how to proceed and change the code when asked to be adjustable to any value entered from the textbox. Because I'm working with this library for the first time.
Richard MacCutchan 1-Oct-19 7:48am    
You have still not really explained what the problem is.
Mels Alex Barno 1-Oct-19 8:01am    
I was asked to do video converter. In this converter, the resolution and bitrate values from mp3 to mp4 or other formats will be changed and converted. I do the desired converter. followed by another request. It was requested to enter the bitrate value via textbox without restricting the user. I normally load bitrate values into the combobox under the enum structure. Now how can I pull these values from the textbox and adapt them to the code?
Richard MacCutchan 1-Oct-19 8:17am    
The way I suggested in my original comment. Take the text field from each text box, and validate it to ensure that the bitrate is acceptable to the library. Then build your parameter string using a StringBuilder which allows you to add each field independently.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900