Closed ajayalag1974 closed 2 years ago
UPDATE: So i tried debugging after getting some understanding of rust language & your code, in layman terms it turns out that in your code segment bytes were being sent by sender and receiver was not able to properly handle it (write bytes via writer) and was stucked and contantly gettting timed out.
Relevant Sender code:
tx.send(SegmentBytes::More(vec_rc.clone())) .await .map_err(|_| YoutubelinkError::SegmentDataSendError)?;
Relevant Receiver code line:
let out_segment_bytes = rx.recv().await;
match out_segment_bytes { None => { // Sender channel dropped break; } Some(SegmentBytes::EOF) => { stderr!(">>> received EOF \n")?; break; } Some(SegmentBytes::More(bytes)) => { stderr!(">>> received bytes \n")?; for out in txbufs.iter_mut() { //stderr!("x ")?; // looks like with youtube we can't skip bytes... // :( if out.reliable { out.tx .send(bytes.clone()) .await .maperr(|| YoutubelinkError::SegmentJoinSendError)?; } else { // non-blocking let _r = out.tx.try_send(bytes.clone()); } } } }
> Writer code which get stucks while writing bytes sent by above Receiver (out.writer.write_all):
async fn copy_channel_to_out(
mut rxbuf: Receiver<Rc<Vec
// We'll receive from channel
// in the future
let f = rxbuf.recv();
let once_msg: Option<Option<Rc<Vec<u8>>>> = f.now_or_never();
let msg: Option<Rc<Vec<u8>>>;
match once_msg {
// Received instantly
Some(m) => {
msg = m;
}
None => {
out.writer.flush().await?;
//stderr!("flushed")?;
msg = rxbuf.recv().await;
}
}
match msg {
Some(bytes_vec) => {
//stderr!("+ ")?;
out.writer.write_all(&bytes_vec).await?;
}
// None from .recv()
// because channel is closed
None => {
break;
}
}
}
Ok(())
}
Hi, video gets stuck probably because of ffplay
, you need to transcode container to mpegts instead of FLV.
It was a little hard to do this automatically, but the command is generally:
setup ffmpeg
TCP proxy
ffmpeg -listen 1 -i "tcp://127.0.0.1:5000" -c:v copy -c:a copy -f mpegts tcp://127.0.0.1:5001
ffmpeg -listen 1 -i "tcp://127.0.0.1:6000" -c:v copy -c:a copy -f mpegts tcp://127.0.0.1:6001
run ffplay
audio:
ffplay -fflags nobuffer -flags low_delay -af volume=0.9 -x 1280 -y 720 -listen 1 -i tcp://127.0.0.1:6001
video:
ffplay -x 1280 -y 720 -probesize 32 -sync ext -af volume=0.3 -vf setpts=0.5*PTS -listen 1 -i "tcp://127.0.0.1:5001"
run Rust program
cargo run --release -- --url https://www.youtube.com/watch?v=RTpWYWIfP7Y -f -v "tcp://127.0.0.1:5000" -a "tcp://127.0.0.1:6000"
Something like this... you need at least 3 terminals to watch video with lowest latency.
Some live videos are in mpegts
by default so it doesn't get stuck tho.
Well the Rust program should change the container to mpegts
Fixed in v0.2
Hi,
Thanks for the great program but i need your help as it is not working for many of the live videos. In those cases audio is working as usual but video is working only for first 1-2 seconds than it got stuck at some frame and that too those working seconds have frames much older (starting frames of the live video not the live ones). Sometimes in those case of live videos where it doesn't work as expected suddenly starts working and than after some time suddenly stops workings so its kind of random or may be some pattern, i am not able to figure out how to fix this thing tried some of the things which i could but i am now wanted to take your help if its possible.
What i observed, i monitored network requests with Fiddler to check whether any http requests are failing due to invalid requests, but that was not the case each and every request, audio as well as video requests were successfully completing and data was fetched. See screenshot:![image](https://user-images.githubusercontent.com/76968826/129451914-700cc49f-57b2-4632-9fd3-90c59709fa1a.png)
In command line logs, i see both audio & video download_format_segment status coming 200 but segment joining of audio is completing but segment joining of video is outputing this - ordered_download: segment timed out. Video gets stuck at some initial frame audio is working fine. Video segment joininig process (frame) gets well behind to audio segment joining because of constant time outs for each frame though i see 200 http status in command line logs + fiddler all requests are completing maybe some bug when joining those fetched segments/frame. My knowledge is limited in this context so forgive me if i sound confusing hope you are able to understand the issue and could help me out. Here are the command line logs: