Today, I fixed a bug in my opusenc code regarding the output filename when it is not provided.
The issue was that if a file didn’t had an extension, then the output string would be empty, so in reality, the encoded file would not be stored. This has been fixed in my latest commits still awaiting approval to be merged into the official opusenc GitHub repository.
The new updated code is the following:
There are now two “if” conditions that will check if the extension dot (.) was found or if it’s already at a directory level. If we get to a / or \, it means an extension was not found. We break the loop and copy the original file name back. Then, we append the .opus extension. In the “else if”, if the dot (.) is found, then we make “foundExt” equal 1 and break the loop.
The “foundExt” is used to know if we need to copy the whole file path or not. Because the extension was found, we skip the “if (!foundExt)” loop and proceed to contatenate the “.opus” extension to the file path.
This build brings an option to enable or disable multithreading and also allows you to encode files to the same input folder by leaving the output textbox blank. This is in part, thanks to a few commits I’ve performed today and currently awaiting a Pull Request approval to merge these commits into the opus-tools repo.
Yesterday, I got my first Pull Request approved which added an argument called “–tracknumber”. This allows you to pass a track number to opusenc so that it is saved in the .opus file metadata.
This is the initial code I wrote:
I then proceeded to update the opusenc documentation to add this argument:
I was told by the code maintainers to fix my indentation, so I did it. ~I was also told to move the –tracknumber argument below the –album argument. The documentation was also updated. Here’s the result:
With these changes done, my Pull Request got accepted and now we have an extra argument included in opusenc, which is very useful for tools like Exact Audio Copy:
To add a track number to a file during encoding, use opusenc.exe like this:
This will add a “1” to the metadata track field. You can use any integer number for this argument.
The other Pull Request that I’ve made today is about having the output filename autogenerated if it’s skipped by using the input name as the base and changing its extension to .opus. This is awaiting acceptance.
I’m not an expert C programmer, but here you can see the progress I did with this:
Initially, the code was large. I was able to update it to the following:
But it still could be improved and here’s the final commit I’ve done up to this point:
As you can see, the code got smaller with every commit. Here’s hoping that this gets merged!
To use the new opusenc without specifying the output filename, you just have to use it like this:
These will generate the output file “file.opus”. The base name is maintained, and the extension is changed to “.opus”.
of course, you can also use it with arguments. See the help by running opusenc.exe.
I hope these changes are very useful to all of you!
This new release brings several improvements. v1.1 was also released but was immediately superseded by v1.2 due to an uncorrected bitrate bug.
First, the GUI will now display the opusenc.exe version being used. This is useful because sometimes, new opusenc versions are released which I personally compile and try to see if there’s new improvements to the audio files.
The other improvement is that the software will try to detect whether opusenc.exe exists in the current folder. If not, you’ll be presented with the following message:
You should not see this message because the software already comes bundled with opusenc.exe, but it’s there just in case.
Lastly, I changed the Bitrate TextBox to an element called “NumericUpDown”, which basically allows numbers to be placed and use the increment and decrement buttons to up or down the bitrate number.