rodizio1 / EZ-WifiBroadcast

Affordable Digital HD Video Transmission made easy!
GNU General Public License v2.0
821 stars 199 forks source link

We use GoPro4 to connect to the raspberry pie 3B via the B101. The transmitter sets the resolution at 1080p 30fps. the video delay at the receiver is about 2 ~ 3 seconds. Why? #198

Open SnailSnake opened 5 years ago

SnailSnake commented 5 years ago
  1. The raspberry pie sender is set to 1080P 30fps.The live video bitrate is maintained at about 13.7Mbit/s (greater than the maximum bitstream 13.2Mbit/s shown in parentheses) with a delay of about 3 seconds.
  2. If the raspberry pie sender is set to 720 30fps, the live video bitrate has been maintained around 9Mbit/s (less than the maximum code stream 13.2Mbit/s shown in parentheses), the delay will return to normal, around 200ms.
  3. If the raspberry pie transmitter is set to 1080p 30fps and the raspberry pie camera is used, the live video bitrate will be at 6~7Mbit/s, with a delay of about 200ms.

Question: 1 Is the large delay caused by the fact that the real time bit stream is larger than the maximum transmission bit stream? If not, what are the reasons? 2 Using GoPro4 to connect raspberry pie via B101, at the same resolution and frame rate, why is the bitstream about twice as large as that of the raspberry pie camera?

rodizio1 commented 5 years ago

Yes, when the datastream has higher bitrate than the available max. bitrate, it is buffered and thus delayed.

I don't know why that is and unfortunately cannot reproduce it because I don't own a B101. Reason is probably a bug in raspivid or the raspberry firmware, as the scripts inside EZ-Wifibroadcast set the raspivid bitrate parameter to the measured bitrate multiplied with the bitrate_percent config setting, i.e. much lower.

Only workaround I can think of would be reducing the bitrate_percent setting in wifibroadcast-1.txt to get a lower bitrate. Another option would be setting it to some fixed value in the /root/.profile script in the raspivid commandline.

SnailSnake commented 5 years ago

Thanks!

Davidsastresas commented 5 years ago

I am having a similar problem using a picapture hd1, my source only outputs 1080p so I can not go down to 720p, which works perfectly for me with other sources and picapture hd1. @rodizio1 Where is that bottleneck of 13 Mbit/s? I don't mind to dig into the code but if you could just give me some hints I would really appreciate it. Using only raspivid on a regular raspbian works perfectly also, I guess this is somewhere inside wifibroadcast code. Do you know if raspivid support something like change the resolution of a incoming stream, or even cropping the image? playing with -md I can just get 720p out of that 1080p, the thing is it crops to the upper left square of the frames. If that could be done cropping to the center of the frame would be fantastic. Please let me know if you have any idea about this.

Thank you very much for your time.

Regards.

rodizio1 commented 5 years ago

@Davidsastresas

The "bottleneck" of 13mbit is the maximum videobitrate that can be transmitted with the configured Wifibitrate and FEC settings.

Using only raspivid on regular Raspbian probably doesn't give any delays because you're not transmitting anything via Wifi and thus nothing can get delayed.

It would be interesting to see what you get on a regular Raspbian when running the raspivid commandline with the tool pipe viever, i.e. something like:

raspivid -w 1280 -h 720 -fps 48 -b 5000000 -t 0 | pv -i 0.5 -R > /dev/null

That should give about 5Mbit/s (or around 625kbyte/s).

Davidsastresas commented 5 years ago

Hello, sorry to come back this late but I left the project for a few weeks until now.

I've come to a solution, and I have not dig enough in to the scripts for making a lot of sense of it, but I somehow have a theory. The thing is 1080p with pi camera is no problem, 1080p with picapturehd1 gets delay accumulated until it crashes.

I saw the bitrate parameter which is set to "auto" is used diferently but both by the raspivid string and some aditional argument for another script right? I suspected somehow the picapture hd1 on 1080p is outputing more bitrate that picamera at same resolution, so on the scripts on profile I eliminated the relationship between the bitrate parameter and the raspivid string. on the raspivid extra params, I set manually the bitrate, to something smaller than the available bitrate for sure. This way it works nicely, with a stunning image quality, but I mean really really stunning, it is definitely comparable to uncompressed wired connection, that on something like 4 Mb. And also a reasonable lag, I think I measured it at less than 200 ms glass to glass. I am really really happy with the performance!

I don't know if that makes sense to you Rodizio, but it is finally working. Let me know if you want me to test anything in case you want to debug or something, I have the setup ready for anything you need.

Thank you very much.

Best regards.

Hanifudin95 commented 11 months ago

@Davidsastresas what parameter did you change mate? are they

nice -n -9 raspivid -w $WIDTH -h $HEIGHT -fps $FPS -b $BITRATE -g $KEYFRAMERATE -t 0 $EXTRAPARAMS -o - | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS

what number did you put on -b $BITRATE parameter and $VIDEO_WIFI_BITRATE parameter ?

Davidsastresas commented 11 months ago

@Hanifudin95 Sorry, that was looooong ago, I didn't even remember this thread. Nowadays you are probably better using OpenHD, I think it is more active than this project.

Good luck!