diff --git a/hack/segment-durations.sh b/hack/segment-durations.sh new file mode 100755 index 00000000..491e0b9a --- /dev/null +++ b/hack/segment-durations.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Splits a video stream apart into video and audio files and checks the discrepancy between them + +set -euo pipefail + +dir="$(mktemp -d)" +ffmpeg -i "$1" -vn -c:a copy "$dir/audio.mkv" 2>/dev/null >/dev/null +ffmpeg -i "$1" -an -c:v copy "$dir/video.mkv" 2>/dev/null >/dev/null +videoDuration=$(gst-discoverer-1.0 "$dir/video.mkv" | grep "Duration" | sed 's/ Duration: 0:00:0//') +audioDuration=$(gst-discoverer-1.0 "$dir/audio.mkv" | grep "Duration" | sed 's/ Duration: 0:00:0//') + +echo "Video duration: $videoDuration" +echo "Audio duration: $audioDuration" +echo "Difference (negative means audio is longer): $(node -p "$videoDuration - $audioDuration")" +rm -rf "$dir" diff --git a/pkg/media/webrtc_ingest.go b/pkg/media/webrtc_ingest.go index 200bfbc1..4b5e2b62 100644 --- a/pkg/media/webrtc_ingest.go +++ b/pkg/media/webrtc_ingest.go @@ -34,7 +34,7 @@ func (mm *MediaManager) WebRTCIngest(ctx context.Context, offer *webrtc.SessionD pipelineSlice := []string{ "multiqueue name=queue", "appsrc format=time is-live=true do-timestamp=true name=videosrc ! capsfilter caps=application/x-rtp ! rtph264depay ! capsfilter caps=video/x-h264,stream-format=byte-stream,alignment=nal ! h264parse disable-passthrough=true config-interval=-1 ! h264timestamper ! identity ! queue.sink_0", - "appsrc format=time do-timestamp=true name=audiosrc ! capsfilter caps=application/x-rtp,media=audio,encoding-name=OPUS,payload=111 ! rtpopusdepay ! queue.sink_1", + "appsrc format=time do-timestamp=true name=audiosrc ! capsfilter caps=application/x-rtp,media=audio,encoding-name=OPUS,payload=111 ! rtpopusdepay ! opusparse ! queue.sink_1", } pipeline, err := gst.NewPipelineFromString(strings.Join(pipelineSlice, "\n"))