Sometimes people reinvent the wheel simply because they can make it better. Most video converters are either paid or bloated with features we do not need. In our case, we only need to convert a bunch of AVI videos to MP4. These videos are small clips typically under 10 minutes each representing a solution to a single question. Altogether, they occupy around 3 TB of space. I will explain the recording tool that created these videos in another post. For now, let us focus solely on the conversion process.
đź§° Why Not Use Ready-Made Tools?
Ready-made tools are often complex or costly. Plus, we have hundreds or even thousands of videos to convert. We need something simple that can scale. .NET does not offer built-in support for this type of media conversion, so we need an external tool. The most reliable and free solution available is FFMPEG. For this project, I used the FFMPEG library through the shell command interface.
🪄 Building the Interface
I created a clean interface with a form that lets the user choose between a single file or an entire folder. When the radio button on the right is selected, the “Select File” button changes to “Select Folder.” When the left button is selected again, it switches back. The click event of the selection button checks its label to determine whether to open a file picker or a folder browser.
There is also a “Save Location” button. When clicked, it opens a folder dialog for the output location. The output filename is automatically set to match the input file but the extension becomes .mp4
.
🔄 The Actual Conversion Process
One code sample I found online used a global process object to read FFMPEG’s output. However, I chose a simpler method. I used the Shell
command to run FFMPEG silently with specific parameters.
Here is the key line:
Shell("ffmpeg -i """ & txtFrom.Text & """ -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k """ & txtTo.Text & """", AppWinStyle.Hide, True)
Let us break it down:
-i
: The input video file-c:v libx264
: Use H.264 as the video codec-c:a libvo_aacenc
: Use AAC as the audio codec-preset slow
: Favor quality over speed during conversion-crf 20
: Choose a constant rate factor for consistent video quality-b:a 128k
: Set audio bitrateAppWinStyle.Hide
: Run FFMPEG without showing a console windowTrue
: Wait for the process to finish before continuing
This approach keeps things simple. While the conversion is running, the app becomes unresponsive, which is acceptable for our needs.
âś… Conclusion
By combining VB.Net with FFMPEG, you can batch convert AVI files to MP4 with minimal effort and no extra costs. This method is scalable, flexible and clean. If you plan to handle thousands of videos like I did, this solution will save you both time and money.