1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-24 00:52:19 +00:00

Stream with the H264 codec to have no CPU usage

This commit is contained in:
Yohann D'ANELLO 2020-10-27 19:32:23 +01:00
parent cdb56c8bf5
commit 9e7e1ec0b8
3 changed files with 8 additions and 8 deletions

View File

@ -18,12 +18,12 @@ func ingest(name string, q *messaging.Quality) {
q.Register(videoInput) q.Register(videoInput)
// Open a UDP Listener for RTP Packets on port 5004 // Open a UDP Listener for RTP Packets on port 5004
videoListener, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5004}) audioListener, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5004})
if err != nil { if err != nil {
log.Printf("Faited to open UDP listener %s", err) log.Printf("Faited to open UDP listener %s", err)
return return
} }
audioListener, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5005}) videoListener, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5005})
if err != nil { if err != nil {
log.Printf("Faited to open UDP listener %s", err) log.Printf("Faited to open UDP listener %s", err)
return return
@ -117,11 +117,11 @@ func ingest(name string, q *messaging.Quality) {
func startFFmpeg(in <-chan []byte) (ffmpeg *exec.Cmd, err error) { func startFFmpeg(in <-chan []byte) (ffmpeg *exec.Cmd, err error) {
ffmpegArgs := []string{"-hide_banner", "-loglevel", "error", "-i", "pipe:0", ffmpegArgs := []string{"-hide_banner", "-loglevel", "error", "-i", "pipe:0",
"-an", "-vcodec", "libvpx", "-crf", "10", "-cpu-used", "5", "-b:v", "6000k", "-maxrate", "8000k", "-bufsize", "12000k", // TODO Change bitrate when changing quality // Audio
"-qmin", "10", "-qmax", "42", "-threads", "4", "-deadline", "1", "-error-resilient", "1", "-vn", "-c:a", "libopus", "-b:a", "160k",
"-auto-alt-ref", "1",
"-f", "rtp", "rtp://127.0.0.1:5004", "-f", "rtp", "rtp://127.0.0.1:5004",
"-vn", "-acodec", "libopus", "-cpu-used", "5", "-deadline", "1", "-qmin", "10", "-qmax", "42", "-error-resilient", "1", "-auto-alt-ref", "1", // Source
"-an", "-c:v", "copy", "-b:v", "3000k", "-maxrate", "5000k", "-bufsize", "5000k",
"-f", "rtp", "rtp://127.0.0.1:5005"} "-f", "rtp", "rtp://127.0.0.1:5005"}
ffmpeg = exec.Command("ffmpeg", ffmpegArgs...) ffmpeg = exec.Command("ffmpeg", ffmpegArgs...)

View File

@ -75,7 +75,7 @@ func newPeerHandler(name string, localSdpChan chan webrtc.SessionDescription, re
} }
// Create video track // Create video track
codec, payloadType := getPayloadType(mediaEngine, webrtc.RTPCodecTypeVideo, "VP8") codec, payloadType := getPayloadType(mediaEngine, webrtc.RTPCodecTypeVideo, "H264")
videoTrack, err := webrtc.NewTrack(payloadType, rand.Uint32(), "video", "pion", codec) videoTrack, err := webrtc.NewTrack(payloadType, rand.Uint32(), "video", "pion", codec)
if err != nil { if err != nil {
log.Println("Failed to create new video track", err) log.Println("Failed to create new video track", err)

View File

@ -26,7 +26,7 @@ func TestServe(t *testing.T) {
peerConnection, _ := api.NewPeerConnection(webrtc.Configuration{}) peerConnection, _ := api.NewPeerConnection(webrtc.Configuration{})
// Create video track // Create video track
codec, payloadType := getPayloadType(mediaEngine, webrtc.RTPCodecTypeVideo, "VP8") codec, payloadType := getPayloadType(mediaEngine, webrtc.RTPCodecTypeVideo, "H264")
videoTrack, err := webrtc.NewTrack(payloadType, rand.Uint32(), "video", "pion", codec) videoTrack, err := webrtc.NewTrack(payloadType, rand.Uint32(), "video", "pion", codec)
if err != nil { if err != nil {
t.Error("Failed to create new video track", err) t.Error("Failed to create new video track", err)