|
| 1 | +#!/usr/bin/env just --justfile |
| 2 | + |
| 3 | +# Using Just: https://github.com/casey/just?tab=readme-ov-file#installation |
| 4 | + |
| 5 | +export RUST_BACKTRACE := "1" |
| 6 | +export RUST_LOG := "info" |
| 7 | +export URL := "http://localhost:4443" |
| 8 | +#export GST_DEBUG:="*:4" |
| 9 | + |
| 10 | +# List all of the available commands. |
| 11 | +default: |
| 12 | + just --list |
| 13 | + |
| 14 | +# Install any required dependencies. |
| 15 | +setup: |
| 16 | + # Upgrade Rust |
| 17 | + rustup update |
| 18 | + |
| 19 | + # Make sure the right components are installed. |
| 20 | + rustup component add rustfmt clippy |
| 21 | + |
| 22 | + # Install cargo binstall if needed. |
| 23 | + cargo install cargo-binstall |
| 24 | + |
| 25 | + # Install cargo shear if needed. |
| 26 | + cargo binstall --no-confirm cargo-shear |
| 27 | + |
| 28 | +# Download the video and convert it to a fragmented MP4 that we can stream |
| 29 | +download name url: |
| 30 | + if [ ! -f dev/{{name}}.mp4 ]; then \ |
| 31 | + wget {{url}} -O dev/{{name}}.mp4; \ |
| 32 | + fi |
| 33 | + |
| 34 | + if [ ! -f dev/{{name}}.fmp4 ]; then \ |
| 35 | + ffmpeg -i dev/{{name}}.mp4 \ |
| 36 | + -c copy \ |
| 37 | + -f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \ |
| 38 | + dev/{{name}}.fmp4; \ |
| 39 | + fi |
| 40 | + |
| 41 | +# Publish a video using ffmpeg to the localhost relay server |
| 42 | +pub: (download "bbb" "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4") |
| 43 | + # Build the plugins |
| 44 | + cargo build |
| 45 | + |
| 46 | + # Run gstreamer and pipe the output to our plugin |
| 47 | + GST_PLUGIN_PATH="${PWD}/target/debug${GST_PLUGIN_PATH:+:$GST_PLUGIN_PATH}" \ |
| 48 | + gst-launch-1.0 -v -e multifilesrc location="dev/bbb.fmp4" loop=true ! qtdemux name=demux \ |
| 49 | + demux.video_0 ! h264parse ! queue ! identity sync=true ! isofmp4mux name=mux chunk-duration=1 fragment-duration=1 ! moqsink url="$URL/demo/bbb" tls-disable-verify=true \ |
| 50 | + demux.audio_0 ! aacparse ! queue ! mux. |
| 51 | + |
| 52 | +# Subscribe to a video using gstreamer |
| 53 | +sub: |
| 54 | + # Build the plugins |
| 55 | + cargo build |
| 56 | + |
| 57 | + # Run gstreamer and pipe the output to our plugin |
| 58 | + # This will render the video to the screen |
| 59 | + GST_PLUGIN_PATH="${PWD}/target/debug${GST_PLUGIN_PATH:+:$GST_PLUGIN_PATH}" \ |
| 60 | + gst-launch-1.0 -v -e moqsrc url="$URL/demo/bbb" tls-disable-verify=true ! decodebin ! videoconvert ! autovideosink |
| 61 | + |
| 62 | +# Run the CI checks |
| 63 | +check $RUSTFLAGS="-D warnings": |
| 64 | + cargo check --all-targets |
| 65 | + cargo clippy --all-targets -- -D warnings |
| 66 | + cargo fmt -- --check |
| 67 | + cargo shear # requires: cargo binstall cargo-shear |
| 68 | + |
| 69 | +# Run any CI tests |
| 70 | +test $RUSTFLAGS="-D warnings": |
| 71 | + cargo test |
| 72 | + |
| 73 | +# Automatically fix some issues. |
| 74 | +fix: |
| 75 | + cargo fix --allow-staged --all-targets --all-features |
| 76 | + cargo clippy --fix --allow-staged --all-targets --all-features |
| 77 | + cargo fmt --all |
| 78 | + cargo shear --fix |
| 79 | + |
| 80 | +# Upgrade any tooling |
| 81 | +upgrade: |
| 82 | + rustup upgrade |
| 83 | + |
| 84 | + # Install cargo-upgrades if needed. |
| 85 | + cargo install cargo-upgrades cargo-edit |
| 86 | + cargo upgrade |
| 87 | + |
| 88 | +# Build the plugins |
| 89 | +build: |
| 90 | + cargo build |
0 commit comments