Barracuda09 / SATPI

SATIP server for linux, suitable to run on an Raspberry Pi, Vu+, GigaBlue or any other linux box. currently supporting DVB-S/S2/T/C and transform DVB-S requests to DVB-C
http://barracuda09.github.io/SATPI
GNU General Public License v2.0
153 stars 32 forks source link

Virtual Tuners: Problem with high-bitrate DVB-Stream #199

Open neo7530 opened 1 year ago

neo7530 commented 1 year ago

Hi.

I've tried to tune into a high-bitrate DVB stream, supplied via udp-multicast ( 3 TV-Channels and 3 Radio channels). Ts-Reader, streamer and childpipe - all have the same behavior. The Channels will be found in SAT>IP Client, but the video is unwatchable. Have uploaded a test-ts of this stream to: https://ddns.dynbox.net/owncloud/index.php/s/6FaYTk68zBHWsJm

my mapping looks like this:

#EXTM3U

# To use Translation you need to set in the web interface
# - 'Advertise as' to exp. 'DVB-S2'
# - 'Transformation enable' should be checked
# - and a valid m3u file like this

#EXTINF:-1 satip-freq="12344", Translation to: ChildPIPE exec="wget -qO- HTTP-Stream from TSDUCK streaming"
rtp://@#1/?msys=childpipe&exec="wget%20-qO-%20http:%2F%2F10.24.10.51:7777%2Fudp%2F224.10.10.10:1234"&pcrtimer=0

#EXTINF:-1 satip-freq="12345", Translation to: ChildPIPE exec="wget -qO- HTTP-Stream from TSDUCK streaming"
rtp://@#1/?msys=file&uri="multiprog.ts"&pcrtimer1

#EXTINF:-1 satip-freq="12363", Translation to: Stream 1 Multicast UDP input
rtsp://@#1/?msys=streamer&uri="udp@224.10.10.10:1234"

Playing the UDP-Multicast via VLC works, playing the translated (via udpxy) stream direct works with VLC also. Playing via SATPI (running on the same machine) via VLC doesn't work (getting programs but sluttery video/audio)

Could you download my testfile for testing, please and tell me, what is wrong with the Stream?

Greetings, Marco.

Barracuda09 commented 1 year ago

Hi Marco,

Thanks for your interesting use case.

I have downloaded the file, I will test this probably later this weekend. But first I have some questions you could answer in the meantime.

Kind regards,

Marc

neo7530 commented 1 year ago

Hi Marc. I tested all variations with pcrtimer without any success... it is a pc (i7 32GB ram) sat-ip client is connected via ethernet. Filtering etc was tested too without success...

neo7530 commented 1 year ago

Hi Marc.

The issue seems to be the stuffing pid (0x1fff). After remuxing the file without pid 1FFF the file is playing back fine. Can you build in a filter, that filters out the stuffing pid? It is always 0x1FFF.

Kind regards Marco.

Barracuda09 commented 1 year ago

Hi Marco,

Could you upload this remuxed file. You can send the link to my e-mail if you like.

i have done some testing with the stuffed file. I added the drop of 0x1FFF (null packets) but then it still reads the file to slow. So this does not seem to have the desired outcome.

Why is the file stuffed with 0x1FFF packets, to make it constant bit-rate? or was this a mistake?

Kind regards, marc

neo7530 commented 1 year ago

This is to match the muxrate for my dektec modulator. I need a cbr for transmitting.

Barracuda09 commented 1 year ago

Can you build SatPI yourself? and edit some files?

neo7530 commented 1 year ago

Yep i can do.

Barracuda09 commented 1 year ago

Which virtual-tuner are you planing to use? childpipe or streamer (Do not use File as it does not work and should be removed)

neo7530 commented 1 year ago

I use childpipe, because i read from udp port with socat.

Barracuda09 commented 1 year ago

Ok then you could try to decrease the 150 ms to 20 ms. And turn off Filter PCR for timing in webUI and no pcrtimer=xx in the request :

https://github.com/Barracuda09/SATPI/blob/91dabfba867784bb34f374d2f016891be94ee9b1/src/input/childpipe/TSReader.cpp#L103-L114

neo7530 commented 1 year ago

Ok. Will test tomorrow. 👍

lars18th commented 1 year ago

Hi @Barracuda09 ,

After a lot of time without writing here, I need to comment this because is related with the problem that suffers @neo7530 :

In resume, after this commit https://github.com/Barracuda09/SATPI/commit/98708753109d3e6744edc8dc7b9aeb8f6b60f416 the input troubles appear. I recommend to @neo7530 to compile one version before this commit and check the results.

In my case, I'm freezed with these ancient versions (with my original patches) because I'm using SATPI only for UDP+FILE+HDHomeRun inputs with the REMAPPING functionality.

I hope this helps. Regards.

Barracuda09 commented 1 year ago

Hi @lars18th

Nice to hear from you again, hope your doing well.

I have good results (no freezes) with lowering this timer in function bool TSReader::isDataAvailable() in combination with the provided test file here https://github.com/Barracuda09/SATPI/issues/199#issue-1888650893.

We have never lowed this value, it is now more or less the same result as your approuce with the do while loop (I would think)

Kind regards, Marc

lars18th commented 1 year ago

Hi @Barracuda09 ,

I'm going not really well. However, I'm glad to participate here.

Regarding the last changes, I'll check them in the next weeks. However, I want to note two key points (from my point of view):

  1. It will be useful to leave the option of configuring the waiting timer. The reason is that you don't know the performance of the device where the SATPI runs. Therefore, using a low power device with a hardware pid filtering, it will be preferable to use a higher value. But with a performance server with software pid filtering, the idea is to reduce it to the minimun. My suggestion is to use a number from a CONSTANT (that you can modify at compile time), and add a command line option to change the default value. You agree?
  2. The second question is if you want to trust or not the source. If you trust that it doesn't produce over a maximun threshold, then it will be preferable to read in the loop until "all the incoming buffer is full or no more data is pending". This has sense when you're using the software pid filtering. Because all packets to discard will be removed in the same loop. Without waiting for the next read. Take note that if the source is "trusted", then it sends TS packets of the same PES packet in one chunk. The problem with the current implementation is that you can insert some wating delay inside a full PES packet. And that's the reason of the glitches. However, with the approach to read "at full speed" (in the sense of fulfill the buffer if data is pending to read) then the problem goes out even the waiting timer is higher. Remember my initial implementation. On it, I'm reading and discarding packets (pid filtering) until the buffer is full or no more packets are pending. That's the difference with the current implementation.

I hope this helps you to improve the implementation. Regards.

lars18th commented 1 year ago

Hi @Barracuda09 ,

Please, revert back this commit: https://github.com/Barracuda09/SATPI/commit/ad810dd82b8fae2cdd3b81ddf3c1d54aa10a43da

When you want to receive the FULL TRANSPORT STREAM, then you want all pids, including the NULL stuff. Because you want to maintain the CBR of the full stream. This code breaks this. So I suggest to change it to:

// Check is this the beginning of the TS and no Transport error indicator and not a NULL packet when filtering
if (ptr[0] != 0x47 || (ptr[1] & 0x80) == 0x80 || (ptr[1] == 0x1F && ptr[2] == 0xFF && !_pidTable.isAllPID())) {

Regards.

Barracuda09 commented 1 year ago

Hi @lars18th

Said to here that. And I appreciated your input and suggestions.

I have good results with these changes and the test file provided and running this setup on a Pi3. So please give these changes a try. Please note, I do run a regulair build of SatPI so no debug.

Kind regards, Marc

lars18th commented 1 year ago

Hi @Barracuda09 ,

Thank you for commenting this. Now, I think you're right. However, perhaps a simple #define WAIT_TIMER 15 in the code will be a good option. Do you think so?

Futhermore, let me to check it in the next weeks. Perhaps you're right (and I hope it) and the problems are gone.

Regards.

Barracuda09 commented 1 year ago

Hi @neo7530

Ok. Will test tomorrow. 👍

Did you manage to test this?