craigmox / cetonproxy

An app that allows a Ceton InfiniTV PCI/network tuner to appear as a SiliconDust HDHomeRun to DVR apps like NextPVR, Plex, and Emby.
GNU General Public License v3.0
23 stars 7 forks source link

CetonProxy Transcoder #5

Open cornesto opened 4 years ago

cornesto commented 4 years ago

Just to start, great work so far on this app. I am also using it with Comcast as my provider and serving the channels through Plex.

Im having issues with the Plex Transcoder when serving the live stream to my devices... no matter what settings Ive used, the image eventually glitches in hues of green and purple. I did the VLC test to tune directly to a channel fron my cp server and get a stable clear image. Is there any tweaking that can be done within cp to do the transcoding before sending it to Plex? This would be similar to what the HD Homerun EXTEND does.

My setup: cetonproxy (VM)

plex media server

craigmox commented 4 years ago

It's a good idea, and I am using ffmpeg in the project already, but I don't have much experience in its transcoding options. I know there's 10 million of them, so I'm worried how much of a black hole a project like that would be. What settings would you like to see configurable if I ever attempted it?

I would guess Plex is transcoding using ffmpeg too, though. Seems like it's everywhere. What if you tried downloading a test video from cetonproxy and tried transcoding it manually with the ffmpeg command-line app, and see if the same glitches occur? It might point to a different problem in the video stream, or maybe a bug in cetonproxy.

cornesto commented 4 years ago

Completely get it... the ever ending "could do it" vs "should doi it" question. From what I've read, Plex has developed its on transcoder based of ffmpeg, but its closed source. I am by no means knowledgeable in programming, but I can definitely tinker with ffmpeg to transcode a stream from ceton, test it, and post some parameters. The benefit Im thinking is compressing the stream before it leaves the windows box therefore condensing bandwidth and then have Plex be able to direct play/direct stream it to any agent (including remote users). If it proves useful, maybe something that could be implemented as "experimental"? Enable/disable with a checkbox?

Will post back with test results.

cornesto commented 4 years ago

BTW, i havent been able to cipher very well through the source code, but how is cp using ffmpeg currently? Is it just re-streaming the channel direct from the ceton card? Are you able to point how its doing the re-stream? (No need to type anything extended, I can read through your code if its easier, just not sure where to start).

craigmox commented 4 years ago

So forgive me if you already know this, but an MPEG2 video stream can have multiple channels of video called programs, like when Channel 4 has a bunch of sub channels 4.1, 4.2, etc, it could potentially send all of those video streams in a single MPEG2 stream. When you ask Ceton to tune to a channel, you tell it the program to filter on, so that the video stream it sends back only has a single channel's video stream. However, the Ceton still includes other programs in the stream, but they're completely empty. The DVR software I've seen don't play nice with that and won't play those kind of streams correctly, so cetonproxy uses ffmpeg to strip out those empty programs to only leave the one program that has actual video. This is what the HDHomeRun devices do too.

As far as video streaming flow: Request comes into ProxyWebModuleUnit.pas to start video stream which calls TProxyWebModule.SendTuneResponse. That creates a TCetonVideoStream (inside Ceton.pas) to do the work. That creates a TVideoConverter (inside VideoUtils.pas) to receive video from Ceton and strip out the correct streams for the intended program using ffmpeg. Then it makes the stream data available for the TCetonVideoStream to read, so that it can finally ship it back to the web client.

cornesto commented 4 years ago

No! Thats great info. Time to dig into the ffmpeg-libav writeups and see what I find.