OptiVorbis / OptiVorbis

🗜️ Library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.
https://optivorbis.github.io/OptiVorbis
GNU Affero General Public License v3.0
99 stars 6 forks source link

A setting to overwrite files/bulk optimization? #8

Open abbuw opened 2 years ago

abbuw commented 2 years ago

Hello! I've stumbled upon this program, and the first thing I thought is that it would be extremely handy if I could just point this application at a folder and have it optimize everything within it without having to manually input each file. I'm a barely tech literate sort of person so I don't really know how to write a fancy script that would do that for me automagically like what I've seen others do. If there was a setting to optimize and overwrite the original files without having to do it all manually, that would rock my socks off. It would be doubly awesome if I could just drag and drop files/folders on the executable and have it do all the magic without ever touching a command prompt, kind of like how PNGOUT does it!

AlexTMjugador commented 2 years ago

Hi! :wave:

In-place optimization is a bit tricky for OptiVorbis. Its two-pass optimization techniques require the input file to be available while the output file is generated, so a temporary output file must be used and atomically moved to the original path after optimizations. Getting this done right across platforms requires attention to detail, so it was not in scope for the first public release.

On the dragging and dropping part, while I understand that it can be a significant UX improvement, at a technical level that gesture is just another way of passing command line parameters, and I'm unsure whether I want to change the CLI interface to accommodate that use case. For example, if two files are dragged and dropped, two paths are passed to the CLI, so what should OptiVorbis do: optimize the file referenced by the first path to the second path (the current behavior), or optimize both files in place? OptiVorbis does not know if the user dragged and dropped files or used a command-line prompt, so it's impossible to guess what the user wants from the paths alone.

Anyway, your suggestions are intriguing, and even if they do not make it to the application, I welcome user-contributed ways to make these operations easier! Thank you for your feedback :smile:

murlakatamenka commented 1 year ago

@abbuw you can leverage other utilities to make your CPU cores busy with optimizing a folder, such as fd:

fd . --type file --extension ogg "/path/to/folder" -x optivorbis {} {.}_optimized.ogg

After that, you can verify that optimized files are valid and remove the original ones, then strip _optimized from filenames. Quick and dirty, take it or leave it :smile:

AlexTMjugador commented 1 year ago

Thanks for the tip, @murlakatamenka! I've used tools like parallel several times myself to execute commands in parallel across file sets, but I didn't think of it when I wrote that reply :smile:

murlakatamenka commented 1 year ago

Yes, GNU parallel is another alternative.

@abbuw didn't specify the platform he uses, so I've written about cross-platform fd only. parallel is via MSYS2 or WSL on Windows as I understand.

Dnyarri commented 3 months ago

Sorry for being late, some time ago I wrote small Python-based GUI script for batch processing folders with optivorbis. It's among other batch files here: https://github.com/Dnyarri/batchfiles GUI is based on tkinter which is included in all normal Python distributions for a long time, and is quite simple: it asks you which folder to process, then shows some sort of progress (file being processed) so you don't think it's crashed. Practically all you should do to configure it is changing optivorbis.exe path in source (I have a dir for frequenty used command line stuff, included in PATH, and optivorbis.exe is there so I don't have to type address every time). So, if you happen to have Python installed already, you may give it a try.

AlexTMjugador commented 3 months ago

No worries @Dnyarri, it's never late to share useful scripts. Thank you!

Dnyarri commented 3 months ago

Well, since I first took a look at Python at the end of 2023, I'm supposed to be late for 2022. But optivorbis was the first candidate for batch automation - I used to have a "movable" version of my music collection (that is, something that would fit even old netbook HD), I use ogg for this, and saving some more space with optivorbis is great. So it was unavoidable that I write some batch for it. And since I'm too lazy to write something I don't use myself, it's supposed to be useful.

Dnyarri commented 3 months ago

Oh, BTW, drag-and-drop support was mentioned. I'm unlikely to make real drag-and-drop, but I guess I have a workaround. I just uploaded upgraded version of the script, which understands command line arguments. If an argument is a directory name, it open "Open..." dialog in this directory; in case of a file name it opens dialog in directory where the file is; else it's supposed to start in CWD.

As a result, under Windows you may create a shortcuts with pythonw.exe "dir ffmpeg flac2ogg 48.py" "%1" command, and drag and drop file onto shortcut to open batch dialog in it's dir. Or put this shortcut to "Send to". Also, if you are more or less comfortable with editing registry, you may add this command to right-click menu (I did it for shift+rclick already, works fine, but I'm not sure if I keep it - probably I'll leave it to shortcuts only).

Hopefully this would make batch processing with optivorbis easy enough.