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

src: stream: pipeline: Fix wrong frame duration #353

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/stream/pipeline/v4l_pipeline.rs
Expand Up @@ -56,7 +56,7 @@ impl V4lPipeline {
VideoEncodeType::H264 => {
format!(
concat!(
"v4l2src device={device} do-timestamp=false",
"v4l2src device={device} do-timestamp=true",
" ! h264parse", // Here we need the parse to help the stream-format and alignment part, which is being fixed here because avc/au seems to reduce the CPU usage in the RTP payloading part.
" ! capsfilter name={filter_name} caps=video/x-h264,stream-format=avc,alignment=au,width={width},height={height},framerate={interval_denominator}/{interval_numerator}",
" ! tee name={video_tee_name} allow-not-linked=true",
Expand All @@ -76,7 +76,7 @@ impl V4lPipeline {
VideoEncodeType::Yuyv => {
format!(
concat!(
"v4l2src device={device} do-timestamp=false",
"v4l2src device={device} do-timestamp=true",
" ! videoconvert",
" ! capsfilter name={filter_name} caps=video/x-raw,format=I420,width={width},height={height},framerate={interval_denominator}/{interval_numerator}",
" ! tee name={video_tee_name} allow-not-linked=true",
Expand All @@ -96,7 +96,7 @@ impl V4lPipeline {
VideoEncodeType::Mjpg => {
format!(
concat!(
"v4l2src device={device} do-timestamp=false",
"v4l2src device={device} do-timestamp=true",
// We don't need a jpegparse, as it leads to incompatible caps, spoiling the negotiation.
" ! capsfilter name={filter_name} caps=image/jpeg,width={width},height={height},framerate={interval_denominator}/{interval_numerator}",
" ! tee name={video_tee_name} allow-not-linked=true",
Expand Down
14 changes: 14 additions & 0 deletions src/stream/sink/webrtc_sink.rs
Expand Up @@ -342,6 +342,20 @@ impl WebRTCSink {
rx.recv()??
};

// Configure RTP
let webrtcbin = webrtcbin.downcast::<gst::Bin>().unwrap();
webrtcbin
.iterate_elements()
.filter(|e| e.name().starts_with("rtpbin"))
.into_iter()
.for_each(|res| {
let Ok(rtp_bin) = res else { return };

// Use the pipeline clock time. This will ensure that the timestamps from the source are correct.
rtp_bin.set_property_from_str("ntp-time-source", "clock-time");
});
let webrtcbin = webrtcbin.upcast::<gst::Element>();

let webrtcbin_sink_pad = webrtcbin
.request_pad_simple("sink_%u")
.context("Failed requesting sink pad for webrtcsink")?;
Expand Down