Archived
2
0

Compare commits

...
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.

1 Commits

Author SHA1 Message Date
Miroslav Šedivý
3e67e44c61 initial h265 implementation. 2021-12-08 20:01:47 +01:00
3 changed files with 20 additions and 0 deletions

View File

@ -133,6 +133,15 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
} }
pipelineStr = fmt.Sprintf(videoSrc+"video/x-raw,format=NV12 ! x264enc threads=4 bitrate=%d key-int-max=60 vbv-buf-capacity=%d byte-stream=true tune=zerolatency speed-preset=veryfast ! video/x-h264,stream-format=byte-stream"+pipelineStr, pipelineDevice, fps, bitrate, vbvbuf) pipelineStr = fmt.Sprintf(videoSrc+"video/x-raw,format=NV12 ! x264enc threads=4 bitrate=%d key-int-max=60 vbv-buf-capacity=%d byte-stream=true tune=zerolatency speed-preset=veryfast ! video/x-h264,stream-format=byte-stream"+pipelineStr, pipelineDevice, fps, bitrate, vbvbuf)
case "H265":
// https://gstreamer.freedesktop.org/documentation/vpx/vp9enc.html?gi-language=c
// gstreamer1.0-plugins-good
// vp9enc
if err := CheckPlugins([]string{"ximagesrc", "x265"}); err != nil {
return nil, err
}
pipelineStr = fmt.Sprintf(videoSrc+"x265enc bitrate=%d key-int-max=60 tune=zerolatency speed-preset=veryfast ! video/x-h265,stream-format=byte-stream"+pipelineStr, pipelineDevice, fps, bitrate)
case "Opus": case "Opus":
// https://gstreamer.freedesktop.org/documentation/opus/opusenc.html // https://gstreamer.freedesktop.org/documentation/opus/opusenc.html
// gstreamer1.0-plugins-base // gstreamer1.0-plugins-base

View File

@ -80,6 +80,11 @@ func (Remote) Init(cmd *cobra.Command) error {
return err return err
} }
cmd.PersistentFlags().Bool("h265", false, "use H265 video codec")
if err := viper.BindPFlag("h265", cmd.PersistentFlags().Lookup("h265")); err != nil {
return err
}
// audio codecs // audio codecs
cmd.PersistentFlags().Bool("opus", false, "use Opus audio codec") cmd.PersistentFlags().Bool("opus", false, "use Opus audio codec")
if err := viper.BindPFlag("opus", cmd.PersistentFlags().Lookup("opus")); err != nil { if err := viper.BindPFlag("opus", cmd.PersistentFlags().Lookup("opus")); err != nil {
@ -112,6 +117,8 @@ func (s *Remote) Set() {
videoCodec = "VP9" videoCodec = "VP9"
} else if viper.GetBool("h264") { } else if viper.GetBool("h264") {
videoCodec = "H264" videoCodec = "H264"
} else if viper.GetBool("h265") {
videoCodec = "H265"
} }
audioCodec := "Opus" audioCodec := "Opus"

View File

@ -317,6 +317,10 @@ func (manager *WebRTCManager) createTrack(codecName string) (*webrtc.TrackLocalS
case "H264": case "H264":
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, ClockRate: 90000, Channels: 0, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f", RTCPFeedback: fb}, PayloadType: 102} codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, ClockRate: 90000, Channels: 0, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f", RTCPFeedback: fb}, PayloadType: 102}
id = "video" id = "video"
case "H265":
// TODO: Fix this (correct payload type and SDPFmtpLine if needed).
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/H265", ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 0}
id = "video"
case "Opus": case "Opus":
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 111} codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 111}
id = "audio" id = "audio"