Skip to content

Commit

Permalink
Fix audio in the BBB demo. (kixelated#164)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Curley <[email protected]>
  • Loading branch information
kixelated and kixcord authored May 8, 2024
1 parent 129c373 commit 4ad3c77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
12 changes: 10 additions & 2 deletions deploy/publish
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ URL=${URL:-"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/Big
REGION=${REGION:-"server"}

# Download the funny bunny
wget -nv "${URL}" -O "${NAME}.mp4"
wget -nv "${URL}" -O "tmp.mp4"

# Properly fragment the file
ffmpeg -i tmp.mp4 \
-c copy \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
"${NAME}.mp4"

rm tmp.mp4

# ffmpeg
# -hide_banner: Hide the banner
Expand Down Expand Up @@ -38,5 +46,5 @@ ffmpeg \
-preset ultrafast \
-tune zerolatency \
-f mp4 \
-movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset \
-movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
- | moq-pub "${ADDR}" --name "${NAME}"
16 changes: 10 additions & 6 deletions dev/pub
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ cd "$(dirname "$0")/.."
# Download the Big Buck Bunny video if it doesn't exist
if [ ! -f dev/bbb.mp4 ]; then
echo "Downloading ya boye Big Buck Bunny..."
wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O dev/bbb.mp4
wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O dev/tmp.mp4

echo "Converting to a (properly) fragmented MP4..."
ffmpeg -i dev/tmp.mp4 \
-c copy \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
dev/bbb.mp4

rm dev/tmp.mp4
fi

# Use debug logging by default
Expand All @@ -32,13 +40,9 @@ INPUT="${INPUT:-dev/bbb.mp4}"
echo "Watch URL: https://quic.video/watch/$NAME?server=$ADDR"

# Run ffmpeg and pipe the output to moq-pub
# TODO fix the stuttering issue with audio (try removing -an)
# In the meantime, consider using gstreamer instead
ffmpeg -hide_banner -v quiet \
-stream_loop -1 -re \
-i "$INPUT" \
-an \
-c copy \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer \
-frag_duration 1 \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
- | cargo run --bin moq-pub -- --name "$NAME" "$URL" "$@"
6 changes: 0 additions & 6 deletions moq-pub/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ impl Media {
// Get the track for this moof.
let track = self.tracks.get_mut(&fragment.track).context("failed to find track")?;

log::info!(
"frame: {}, time: {:?}",
track.handler,
fragment.timestamp(track.timescale)
);

// Save the track ID for the next iteration, which must be a mdat.
anyhow::ensure!(self.current.is_none(), "multiple moof atoms");
self.current.replace(fragment.track);
Expand Down

0 comments on commit 4ad3c77

Please sign in to comment.