#UdpSocket, Gstreamer, H264, and a side dish of annoyance
10 messages · Page 1 of 1 (latest)
I ended up using the command line and running that through Rust, I could never get the library to work
https://github.com/WPKG4/screenshare-pow/tree/gstreamer
i've made this today, which is working shockingly well
got realtime fullhd 25fps 190mb per 5min
utilizing gstreamer libary
I imagine I'm nearing dragon territory with this, but may as well ask. I'm attempting to capture my screen and turn it into a H264 stream I can send over WebRTC to a remote web browser. I've run into quite a few pipewire not-negotiated bugs at this point, but I know that using TcpStream, the gstreamer pipeline works. With it, though, I was experiencing heavy artifacting and a significant lag (10-15 seconds, sometimes more). I thought to try UdpSocket, but it just doesn't return, not with Tokio's or std's. The following is the code. Any help would be very much appreciated
println!("Binding to socket");
let socket = UdpSocket::bind("127.0.0.1:3001").await.unwrap();
println!("Making data slice");
let mut nal_data = [0u8; 65535];
let mut h264 = H264Reader::new(Cursor::new(nal_data));
println!("Made h264 parser");
loop {
if recv.try_recv().is_ok() {
println!("BREAKING, RECEIVED EXIT SIGNAL");
break;
}
println!("Grabbing from socket");
match socket.recv(&mut nal_data).await {
Ok(_) => {}
Err(e) => {
eprintln!("Encountered error {e}");
continue;
}
}
println!("Parsing NAL");
let nal = match h264.next_nal() {
Ok(nal) => nal,
Err(err) => {
println!("Error streaming nal: {}", err);
continue;
}
};
println!(
"PictureOrderCount={}, ForbiddenZeroBit={}, RefIdc={}, UnitType={}, datalen={}",
nal.picture_order_count,
nal.forbidden_zero_bit,
nal.ref_idc,
nal.unit_type,
nal.data.len()
);
video_track
.write_sample(&Sample {
data: nal.data.freeze(),
duration: Duration::from_secs_f64(0.03333333333),
..Default::default()
})
.await
.unwrap();
}
Should clarify just in case, the issue is that the UdpSocket isn't returning any data, it's just sitting indefinitely
Okay well
Ignore this, apparently the issue is GStreamer is somehow stroking out :v