rust-av/Av1an

Refactor Av1an as a Library

Aperta

#995 aperta il 19 mag 2025

 (0 commenti) (0 reazioni) (0 assegnatari)Rust (188 fork)auto 404
dependenciesdocumentationenhancementhelp wantedrust

Metriche repository

Star
 (1958 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Av1an's functionality outside of a command-line interface is very valuable and should be refactored such that it can be leveraged as a dependency in other projects. This does not mean Av1an should not be a command-line utility, rather it should be split into a library and a command-line interface and can both be developed in the same repository. The distinction between av1an and av1an-core is already an indication that this was a considered possibility in the future but the current structure makes it difficult to do something like call a single function to encode a specific chunk and get realtime progress programmatically.

Without specifying every single possibility, I'll instead offer this workflow scenario to exemplify how this refactor would work:

  1. Detect scenes of video.mkv. Subscribe to a channel that reports progress. Returns a list of scenes.
  2. Iterate through every scene: Perform Target Quality in advance. Each probe also has a channel that reports progress or the parent function can report aggregate progress of the entire chunk. Returns the probing results.
  3. Iterate through every scene: Encode and report progress in a channel. Returns the encoded chunk path.
  4. Iterate through every scene: Measure quality and report progress in a channel. Returns the quality results.
  5. Generate a report and quality plot from the results.
  6. Demux the audio, subtitles, chapters, attachments, etc. from video.mkv. Allow addressing specific tracks with custom arguments.
  7. Mux the encoded chunks and processed audio, subtitles, chapters, attachments, etc. into a single video.

Another scenario:

  1. Connect to server.
  2. Submit encoding task for every scene.
  3. Perform encoding tasks along with N other clients. Retrieve task, encode and report progress in websocket, upload encoded chunk to server, repeat.
  4. Wait for completion from all N clients.
  5. Download the encoded chunks from the server.
  6. Multiplex the encoded chunks.

Most of these tasks can be performed with the commandline interface but with limitations and issues like being unable to programmatically read progress (#366) or perform Target Quality separately from encoding can all be resolved by refactoring these atomic tasks into their respective functions. Distributed encoding is one of the next major goals for Av1an and this refactor is a necessary step to making that possible. The same can be said for implementing a graphical user interface - something I have personally implemented but with many limitations and unsightly hacks.

Additionally, the readme refers to cargo.io (should be updated to crates.io) and will need to be updated on Av1an's next release. Av1an can remain a command-line interface and be published the same way, but the av1an-core could also be published to do all of the aforementioned.

Thank you, - Boats M.

Guida contributor