wakabayashik / mpegts-to-webrtc

demux mpegts to H264 and Opus then send to a WebRTC client.
MIT License
5 stars 0 forks source link

MPEGTS works perfect, but not H264 #5

Open Sean-Zeo opened 1 year ago

Sean-Zeo commented 1 year ago

Hi!

The following code works perfectly for mpegts; ffmpeg -rtbufsize 100M -f gdigrab -framerate 60 -i desktop -pix_fmt yuv420p -c:v libx264 -preset ultrafast -tune zerolatency -b:v 1M -max_delay 0 -bf 0 -f mpegts -pes_payload_size 0 pipe:1 | mpegts-to-webrtc -offerFile sdp.txt

However, I was hoping to have '-f h264' support for the highest frame rate.
Any ideas of how I can achieve this?

The result is "broken pipe"; image ffmpeg -rtbufsize 100M -f gdigrab -framerate 60 -i desktop -pix_fmt yuv420p -c:v libx264 -preset ultrafast -tune zerolatency -b:v 1M -max_delay 0 -bf 0 -f h264 -pes_payload_size 0 pipe:1 | mpegts-to-webrtc -offerFile sdp.txt

Thanks. :)

wakabayashik commented 1 year ago

How about ffmpeg-to-webrtc? It's not my work, but mpegts-to-webrtc was inspired by this project.

The motivation of mpegts-to-webrtc is to achieve video and audio at the same time, and for that purpose it takes as input mpegts, which can interleave video and audio into a single stream.

If only video is to be transmitted, ffmpeg-to-webrtc may work well.

Sean-Zeo commented 1 year ago

Hi friend, I've tried ffmpeg-to-webrtc in the past, there are huge latency delays comapred to mpegts-to-webrtc. It seems the code is broken somewhere causing inconsistent frame rates and huge slowdown.

If I removed the audio stream requirements from mpegts-to-webrtc would h264 function as intended? Thanks!

wakabayashik commented 1 year ago

code is broken somewhere

you mean this hardcoded frame duration?

const (
    h264FrameDuration = time.Millisecond * 33
)

I believe you can change this constant by forking ffmpeg-to-webrtc. On the other hand, mpegts-to-webrtc refers timestamps contained in mpegts to recognize the frame duration.