mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
codecs from string not bools.
This commit is contained in:
parent
ccbfe93765
commit
057ab2d886
@ -10,6 +10,7 @@
|
||||
### Misc
|
||||
- Server: Split `remote` to `desktop` and `capture`.
|
||||
- Server: Refactored `xorg` - added `xevent` and clipboard is handled as event (no looped polling anymore).
|
||||
- Introduced `NEKO_AUDIO_CODEC=` and `NEKO_VIDEO_CODEC=` as a new way of setting codecs.
|
||||
|
||||
## [n.eko v2.6](https://github.com/m1k1o/neko/releases/tag/v2.6)
|
||||
|
||||
|
@ -64,15 +64,10 @@ nat1to1: <ip>
|
||||
|
||||
### Video
|
||||
|
||||
#### `NEKO_VP8`:
|
||||
- If vp8 should be used as video encoder for the stream *(default encoder)*.
|
||||
- e.g. `true`
|
||||
#### `NEKO_VP9`:
|
||||
- If vp9 should be used as video encoder for the stream *(parameter not optimized yet)*.
|
||||
- e.g. `false`
|
||||
#### `NEKO_H264`:
|
||||
- If h264 should be used as video encoder for the stream *(second best option)*.
|
||||
- e.g. `false`
|
||||
#### `NEKO_VIDEO_CODEC`:
|
||||
- vp8 *(default encoder)*
|
||||
- vp9 *(parameter not optimized yet)*
|
||||
- h264 *(second best option)*
|
||||
#### `NEKO_VIDEO_BITRATE`:
|
||||
- Bitrate of the video stream in kb/s.
|
||||
- e.g. 3500
|
||||
@ -93,18 +88,11 @@ nat1to1: <ip>
|
||||
|
||||
### Audio
|
||||
|
||||
#### `NEKO_OPUS`:
|
||||
- If opus should be used as audio encoder for the stream *(default encoder)*.
|
||||
- e.g. `true`
|
||||
#### `NEKO_G722`:
|
||||
- If g722 should be used as audio encoder for the stream.
|
||||
- e.g. `false`
|
||||
#### `NEKO_PCMU`:
|
||||
- If pcmu should be used as audio encoder for the stream.
|
||||
- e.g. `false`
|
||||
#### `NEKO_PCMA`:
|
||||
- If pcma should be used as audio encoder for the stream.
|
||||
- e.g. `false`
|
||||
#### `NEKO_AUDIO_CODEC`:
|
||||
- opus *(default encoder)*
|
||||
- g722
|
||||
- pcmu
|
||||
- pcma
|
||||
#### `NEKO_AUDIO_BITRATE`:
|
||||
- Bitrate of the audio stream in kb/s.
|
||||
- e.g. `196`
|
||||
@ -158,6 +146,7 @@ Usage:
|
||||
Flags:
|
||||
--audio string audio codec parameters to use for streaming
|
||||
--audio_bitrate int audio bitrate in kbit/s (default 128)
|
||||
--audio_codec string audio codec to be used (default "opus")
|
||||
--bind string address/port/socket to serve neko (default "127.0.0.1:8080")
|
||||
--broadcast_pipeline string custom gst pipeline used for broadcasting, strings {url} {device} {display} will be replaced
|
||||
--broadcast_url string URL for broadcasting, setting this value will automatically enable broadcasting
|
||||
@ -166,8 +155,8 @@ Flags:
|
||||
--device string audio device to capture (default "auto_null.monitor")
|
||||
--display string XDisplay to capture (default ":99.0")
|
||||
--epr string limits the pool of ephemeral ports that ICE UDP connections can allocate from (default "59000-59100")
|
||||
--g722 use G722 audio codec
|
||||
--h264 use H264 video codec
|
||||
--g722 DEPRECATED: use audio_codec
|
||||
--h264 DEPRECATED: use video_codec
|
||||
-h, --help help for serve
|
||||
--hwenc string use hardware accelerated encoding
|
||||
--icelite configures whether or not the ice agent should be a lite agent
|
||||
@ -179,11 +168,12 @@ Flags:
|
||||
--locks strings resources, that will be locked when starting (control, login)
|
||||
--max_fps int maximum fps delivered via WebRTC, 0 is for no maximum (default 25)
|
||||
--nat1to1 strings sets a list of external IP addresses of 1:1 (D)NAT and a candidate type for which the external IP address is used
|
||||
--opus use Opus audio codec
|
||||
--opus DEPRECATED: use audio_codec
|
||||
--password string password for connecting to stream (default "neko")
|
||||
--password_admin string admin password for connecting to stream (default "admin")
|
||||
--pcma use PCMA audio codec
|
||||
--pcmu use PCMU audio codec
|
||||
--path_prefix string path prefix for HTTP requests (default "/")
|
||||
--pcma DEPRECATED: use audio_codec
|
||||
--pcmu DEPRECATED: use audio_codec
|
||||
--proxy enable reverse proxy mode
|
||||
--screen string default screen resolution and framerate (default "1280x720@30")
|
||||
--static string path to neko client files to serve (default "./www")
|
||||
@ -191,8 +181,9 @@ Flags:
|
||||
--udpmux int single UDP mux port for all peers
|
||||
--video string video codec parameters to use for streaming
|
||||
--video_bitrate int video bitrate in kbit/s (default 3072)
|
||||
--vp8 use VP8 video codec
|
||||
--vp9 use VP9 video codec
|
||||
--video_codec string video codec to be used (default "vp8")
|
||||
--vp8 DEPRECATED: use video_codec
|
||||
--vp9 DEPRECATED: use video_codec
|
||||
|
||||
Global Flags:
|
||||
--config string configuration file path
|
||||
|
@ -98,7 +98,7 @@ services:
|
||||
! v4l2h264enc extra-controls="controls,h264_profile=0,video_bitrate=1250000;"
|
||||
! h264parse config-interval=3
|
||||
! video/x-h264,profile=baseline,stream-format=byte-stream
|
||||
NEKO_H264: 1
|
||||
NEKO_VIDEO_CODEC: h264
|
||||
```
|
||||
|
||||
## Not using docker?
|
||||
|
@ -3,6 +3,8 @@ package config
|
||||
import (
|
||||
"m1k1o/neko/internal/types/codec"
|
||||
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@ -38,23 +40,28 @@ func (Capture) Init(cmd *cobra.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// video codecs
|
||||
// TODO: video.codec
|
||||
cmd.PersistentFlags().Bool("vp8", false, "use VP8 video codec")
|
||||
cmd.PersistentFlags().String("video_codec", "vp8", "video codec to be used")
|
||||
if err := viper.BindPFlag("video_codec", cmd.PersistentFlags().Lookup("video_codec")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// DEPRECATED: video codec
|
||||
cmd.PersistentFlags().Bool("vp8", false, "DEPRECATED: use video_codec")
|
||||
if err := viper.BindPFlag("vp8", cmd.PersistentFlags().Lookup("vp8")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("vp9", false, "use VP9 video codec")
|
||||
// DEPRECATED: video codec
|
||||
cmd.PersistentFlags().Bool("vp9", false, "DEPRECATED: use video_codec")
|
||||
if err := viper.BindPFlag("vp9", cmd.PersistentFlags().Lookup("vp9")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("h264", false, "use H264 video codec")
|
||||
// DEPRECATED: video codec
|
||||
cmd.PersistentFlags().Bool("h264", false, "DEPRECATED: use video_codec")
|
||||
if err := viper.BindPFlag("h264", cmd.PersistentFlags().Lookup("h264")); err != nil {
|
||||
return err
|
||||
}
|
||||
// video codecs
|
||||
|
||||
cmd.PersistentFlags().String("hwenc", "", "use hardware accelerated encoding")
|
||||
if err := viper.BindPFlag("hwenc", cmd.PersistentFlags().Lookup("hwenc")); err != nil {
|
||||
@ -85,24 +92,31 @@ func (Capture) Init(cmd *cobra.Command) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// audio codecs
|
||||
// TODO: audio.codec
|
||||
cmd.PersistentFlags().Bool("opus", false, "use Opus audio codec")
|
||||
cmd.PersistentFlags().String("audio_codec", "opus", "audio codec to be used")
|
||||
if err := viper.BindPFlag("audio_codec", cmd.PersistentFlags().Lookup("audio_codec")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// DEPRECATED: audio codec
|
||||
cmd.PersistentFlags().Bool("opus", false, "DEPRECATED: use audio_codec")
|
||||
if err := viper.BindPFlag("opus", cmd.PersistentFlags().Lookup("opus")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("g722", false, "use G722 audio codec")
|
||||
// DEPRECATED: audio codec
|
||||
cmd.PersistentFlags().Bool("g722", false, "DEPRECATED: use audio_codec")
|
||||
if err := viper.BindPFlag("g722", cmd.PersistentFlags().Lookup("g722")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("pcmu", false, "use PCMU audio codec")
|
||||
// DEPRECATED: audio codec
|
||||
cmd.PersistentFlags().Bool("pcmu", false, "DEPRECATED: use audio_codec")
|
||||
if err := viper.BindPFlag("pcmu", cmd.PersistentFlags().Lookup("pcmu")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().Bool("pcma", false, "use PCMA audio codec")
|
||||
// DEPRECATED: audio codec
|
||||
cmd.PersistentFlags().Bool("pcma", false, "DEPRECATED: use audio_codec")
|
||||
if err := viper.BindPFlag("pcma", cmd.PersistentFlags().Lookup("pcma")); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -136,21 +150,31 @@ func (Capture) Init(cmd *cobra.Command) error {
|
||||
}
|
||||
|
||||
func (s *Capture) Set() {
|
||||
var ok bool
|
||||
|
||||
//
|
||||
// video
|
||||
//
|
||||
|
||||
s.Display = viper.GetString("display")
|
||||
|
||||
videoCodec := codec.VP8()
|
||||
if viper.GetBool("vp8") {
|
||||
videoCodec = codec.VP8()
|
||||
} else if viper.GetBool("vp9") {
|
||||
videoCodec = codec.VP9()
|
||||
} else if viper.GetBool("h264") {
|
||||
videoCodec = codec.H264()
|
||||
videoCodec := viper.GetString("video_codec")
|
||||
s.VideoCodec, ok = codec.ParseStr(videoCodec)
|
||||
if !ok || s.VideoCodec.Type != webrtc.RTPCodecTypeVideo {
|
||||
log.Warn().Str("codec", videoCodec).Msgf("unknown video codec, using Vp8")
|
||||
s.VideoCodec = codec.VP8()
|
||||
}
|
||||
|
||||
if viper.GetBool("vp8") {
|
||||
s.VideoCodec = codec.VP8()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_VP8=true', use 'NEKO_VIDEO_CODEC=vp8' instead")
|
||||
} else if viper.GetBool("vp9") {
|
||||
s.VideoCodec = codec.VP9()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_VP9=true', use 'NEKO_VIDEO_CODEC=vp9' instead")
|
||||
} else if viper.GetBool("h264") {
|
||||
s.VideoCodec = codec.H264()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_H264=true', use 'NEKO_VIDEO_CODEC=h264' instead")
|
||||
}
|
||||
s.VideoCodec = videoCodec
|
||||
|
||||
videoHWEnc := ""
|
||||
if viper.GetString("hwenc") == "VAAPI" {
|
||||
@ -168,17 +192,26 @@ func (s *Capture) Set() {
|
||||
|
||||
s.AudioDevice = viper.GetString("device")
|
||||
|
||||
audioCodec := codec.Opus()
|
||||
if viper.GetBool("opus") {
|
||||
audioCodec = codec.Opus()
|
||||
} else if viper.GetBool("g722") {
|
||||
audioCodec = codec.G722()
|
||||
} else if viper.GetBool("pcmu") {
|
||||
audioCodec = codec.PCMU()
|
||||
} else if viper.GetBool("pcma") {
|
||||
audioCodec = codec.PCMA()
|
||||
audioCodec := viper.GetString("audio_codec")
|
||||
s.AudioCodec, ok = codec.ParseStr(audioCodec)
|
||||
if !ok || s.AudioCodec.Type != webrtc.RTPCodecTypeAudio {
|
||||
log.Warn().Str("codec", audioCodec).Msgf("unknown audio codec, using Opus")
|
||||
s.AudioCodec = codec.Opus()
|
||||
}
|
||||
|
||||
if viper.GetBool("opus") {
|
||||
s.AudioCodec = codec.Opus()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_OPUS=true', use 'NEKO_VIDEO_CODEC=opus' instead")
|
||||
} else if viper.GetBool("g722") {
|
||||
s.AudioCodec = codec.G722()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_G722=true', use 'NEKO_VIDEO_CODEC=g722' instead")
|
||||
} else if viper.GetBool("pcmu") {
|
||||
s.AudioCodec = codec.PCMU()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_PCMU=true', use 'NEKO_VIDEO_CODEC=pcmu' instead")
|
||||
} else if viper.GetBool("pcma") {
|
||||
s.AudioCodec = codec.PCMA()
|
||||
log.Warn().Msg("you are using deprecated config setting 'NEKO_PCMA=true', use 'NEKO_VIDEO_CODEC=pcma' instead")
|
||||
}
|
||||
s.AudioCodec = audioCodec
|
||||
|
||||
s.AudioBitrate = viper.GetUint("audio_bitrate")
|
||||
s.AudioPipeline = viper.GetString("audio")
|
||||
|
Loading…
Reference in New Issue
Block a user