diff --git a/dev/pub b/dev/pub index f98bb36..2a5cb21 100755 --- a/dev/pub +++ b/dev/pub @@ -23,14 +23,18 @@ NAME="${NAME:-dev}" URL="${URL:-"https://$ADDR/$NAME"}" # Default to a source video -MEDIA="${MEDIA:-dev/source.mp4}" +INPUT="${INPUT:-dev/source.mp4}" # Print out the watch URL echo "Watch URL: https://quic.video/watch/$NAME?server=$ADDR" # Run ffmpeg and pipe the output to moq-pub +# TODO enable audio again once fixed. ffmpeg -hide_banner -v quiet \ -stream_loop -1 -re \ - -i "$MEDIA" \ - -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - \ - | cargo run --bin moq-pub -- "$URL" "$@" + -i "$INPUT" \ + -c copy \ + -an \ + -f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer \ + -frag_duration 1 \ + - | cargo run --bin moq-pub -- "$URL" "$@" diff --git a/dev/pub-file b/dev/pub-file index dbd8f2c..cef42ca 100755 --- a/dev/pub-file +++ b/dev/pub-file @@ -5,7 +5,7 @@ set -euo pipefail cd "$(dirname "$0")/.." # Default to a source video -MEDIA="${MEDIA:-dev/source.mp4}" +INPUT="${INPUT:-dev/source.mp4}" # Output the fragmented MP4 to disk for testing. OUTPUT="${OUTPUT:-dev/output.mp4}" @@ -14,10 +14,77 @@ OUTPUT="${OUTPUT:-dev/output.mp4}" # - print any errors/warnings # - only loop twice # -# Note this is artificially slowed down to real-time using the -re flag. +# Note this is artificially slowed down to real-time using the -re flag; you can remove it. ffmpeg \ - -stream_loop 2 \ -re \ - -i "$MEDIA" \ - -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset \ + -y \ + -i "$INPUT" \ + -c copy \ + -fps_mode passthrough \ + -f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer \ + -frag_duration 1 \ "${OUTPUT}" + +# % ffmpeg -f mp4 --ffmpeg -h muxer=mov +# +# ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers +# Muxer mov [QuickTime / MOV]: +# Common extensions: mov. +# Default video codec: h264. +# Default audio codec: aac. +# mov/mp4/tgp/psp/tg2/ipod/ismv/f4v muxer AVOptions: +# -movflags E.......... MOV muxer flags (default 0) +# rtphint E.......... Add RTP hint tracks +# empty_moov E.......... Make the initial moov atom empty +# frag_keyframe E.......... Fragment at video keyframes +# frag_every_frame E.......... Fragment at every frame +# separate_moof E.......... Write separate moof/mdat atoms for each track +# frag_custom E.......... Flush fragments on caller requests +# isml E.......... Create a live smooth streaming feed (for pushing to a publishing point) +# faststart E.......... Run a second pass to put the index (moov atom) at the beginning of the file +# omit_tfhd_offset E.......... Omit the base data offset in tfhd atoms +# disable_chpl E.......... Disable Nero chapter atom +# default_base_moof E.......... Set the default-base-is-moof flag in tfhd atoms +# dash E.......... Write DASH compatible fragmented MP4 +# cmaf E.......... Write CMAF compatible fragmented MP4 +# frag_discont E.......... Signal that the next fragment is discontinuous from earlier ones +# delay_moov E.......... Delay writing the initial moov until the first fragment is cut, or until the first fragment flush +# global_sidx E.......... Write a global sidx index at the start of the file +# skip_sidx E.......... Skip writing of sidx atom +# write_colr E.......... Write colr atom even if the color info is unspecified (Experimental, may be renamed or changed, do not use from scripts) +# prefer_icc E.......... If writing colr atom prioritise usage of ICC profile if it exists in stream packet side data +# write_gama E.......... Write deprecated gama atom +# use_metadata_tags E.......... Use mdta atom for metadata. +# skip_trailer E.......... Skip writing the mfra/tfra/mfro trailer for fragmented files +# negative_cts_offsets E.......... Use negative CTS offsets (reducing the need for edit lists) +# -moov_size E.......... maximum moov size so it can be placed at the begin (from 0 to INT_MAX) (default 0) +# -rtpflags E.......... RTP muxer flags (default 0) +# latm E.......... Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC +# rfc2190 E.......... Use RFC 2190 packetization instead of RFC 4629 for H.263 +# skip_rtcp E.......... Don't send RTCP sender reports +# h264_mode0 E.......... Use mode 0 for H.264 in RTP +# send_bye E.......... Send RTCP BYE packets when finishing +# -skip_iods E.......... Skip writing iods atom. (default true) +# -iods_audio_profile E.......... iods audio profile atom. (from -1 to 255) (default -1) +# -iods_video_profile E.......... iods video profile atom. (from -1 to 255) (default -1) +# -frag_duration E.......... Maximum fragment duration (from 0 to INT_MAX) (default 0) +# -min_frag_duration E.......... Minimum fragment duration (from 0 to INT_MAX) (default 0) +# -frag_size E.......... Maximum fragment size (from 0 to INT_MAX) (default 0) +# -ism_lookahead E.......... Number of lookahead entries for ISM files (from 0 to 255) (default 0) +# -video_track_timescale E.......... set timescale of all video tracks (from 0 to INT_MAX) (default 0) +# -brand E.......... Override major brand +# -use_editlist E.......... use edit list (default auto) +# -fragment_index E.......... Fragment number of the next fragment (from 1 to INT_MAX) (default 1) +# -mov_gamma E.......... gamma value for gama atom (from 0 to 10) (default 0) +# -frag_interleave E.......... Interleave samples within fragments (max number of consecutive samples, lower is tighter interleaving, but with more overhead) (from 0 to INT_MAX) (default 0) +# -encryption_scheme E.......... Configures the encryption scheme, allowed values are none, cenc-aes-ctr +# -encryption_key E.......... The media encryption key (hex) +# -encryption_kid E.......... The media encryption key identifier (hex) +# -use_stream_ids_as_track_ids E.......... use stream ids as track ids (default false) +# -write_btrt E.......... force or disable writing btrt (default auto) +# -write_tmcd E.......... force or disable writing tmcd (default auto) +# -write_prft E.......... Write producer reference time box with specified time source (from 0 to 2) (default 0) +# wallclock 1 E.......... +# pts 2 E.......... +# -empty_hdlr_name E.......... write zero-length name string in hdlr atoms within mdia and minf atoms (default false) +# -movie_timescale E.......... set movie timescale (from 1 to INT_MAX) (default 1000) diff --git a/moq-pub/src/media.rs b/moq-pub/src/media.rs index 888ad84..cb2c5a7 100644 --- a/moq-pub/src/media.rs +++ b/moq-pub/src/media.rs @@ -177,7 +177,7 @@ impl Media { track["kind"] = json!("audio"); track["codec"] = json!(codec_str); track["channel_count"] = json!(mp4a.channelcount); - track["sample_rate"] = json!(mp4a.samplerate); + track["sample_rate"] = json!(mp4a.samplerate.value()); track["sample_size"] = json!(mp4a.samplesize); let bitrate = max(desc.max_bitrate, desc.avg_bitrate);