Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI #14

Merged
merged 2 commits into from
Aug 19, 2024
Merged

Add CLI #14

merged 2 commits into from
Aug 19, 2024

Conversation

mat-hek
Copy link
Member

@mat-hek mat-hek commented Jul 31, 2024

closes #9

This PR allows building boombox as a standalone binary and adds a CLI API to call that binary. The API translates to the Elixir API in the following way:

  • -value is translated to atom :value
  • anything else is translated to a string.

For example,

./boombox -i file.mp4 -o -webrtc ws://localhost:8830

is equivalent to:

Boombox.run(input: "file.mp4", output: {:webrtc, "ws://localhost:8830"})

I chose burrito for the building part, because it's the only tool I found that outputs a single binary and requires neither Erlang nor Elixir. When the binary is run for the first time, it extracts the release from itself, stores it under a common location in the system, and calls it. Subsequent runs only call the unpacked release. In our case, the problem is that the uncompressed release weighs over 1,5 GB, because of FFmpeg artifacts which are duplicated for each package that uses FFmpeg and take over 1,4 GB. Thus, building the release and the first run (unpacking) takes a longer while.

@mat-hek mat-hek requested a review from varsill August 2, 2024 08:02
@darthez darthez requested review from FelonEkonom and Noarkhh and removed request for varsill and FelonEkonom August 7, 2024 14:10
@mat-hek mat-hek changed the base branch from poc to master August 8, 2024 10:17
.gitignore Show resolved Hide resolved
README.md Show resolved Hide resolved
Comment on lines +40 to +52
|> Enum.drop_while(&(&1 != type))
|> Enum.drop(1)
|> Enum.take_while(&(&1 not in [:i, :o]))
|> case do
[value] -> value
[_h | _t] = values -> List.to_tuple(values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine for now, but I think we finally gonna need to use something like: https://hexdocs.pm/elixir/1.12.3/OptionParser.html or https://www.erlang.org/doc/apps/stdlib/argparse.html

Copy link
Member Author

@mat-hek mat-hek Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Currently, the API is not parsable by the OptionParser AFAIK - for example, we'd have to have boombox --i input.mp4 instead of boombox -i input.mp4. Maybe we should adjust to that, but that would require more thinking ;)

build_binary.sh Show resolved Hide resolved
@mat-hek mat-hek requested a review from varsill August 19, 2024 10:00
Copy link
Contributor

@varsill varsill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@mat-hek mat-hek merged commit ab533fe into master Aug 19, 2024
3 checks passed
@mat-hek mat-hek deleted the burrito branch August 19, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a precompiled binary and a simple command line interface to it
2 participants