add audio support, trying to manage MSD device
This commit is contained in:
@@ -2,20 +2,29 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var RootFS string
|
||||
|
||||
func init() {
|
||||
RootFS = os.Getenv("ROOT_FS")
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
LogLevel string `yaml:"log_level"`
|
||||
Auth bool `yaml:"auth"`
|
||||
AuthSecret string `yaml:"auth_secret"`
|
||||
Port int `yaml:"port"`
|
||||
UStreamer UStreamer `yaml:"ustreamer"`
|
||||
FFmpeg FFmpeg `yaml:"ffmpeg"`
|
||||
Video FFmpeg `yaml:"video"`
|
||||
Audio []string `yaml:"audio"`
|
||||
WebRtc WebRtc `yaml:"webrtc"`
|
||||
Stream Stream `yaml:"stream"`
|
||||
|
||||
NanoKVMUISupport bool `yaml:"nano_kvm_ui_support"`
|
||||
ISOPath string `yaml:"iso_path"`
|
||||
NanoKVMUISupport bool `yaml:"nano_kvm_ui_support"`
|
||||
}
|
||||
|
||||
type WebRtc struct {
|
||||
@@ -35,16 +44,20 @@ type Stream struct {
|
||||
const (
|
||||
StreamSourceMjpeg = "mjpeg"
|
||||
StreamSourceH264 = "h264"
|
||||
StreamSourceHevc = "hevc"
|
||||
)
|
||||
|
||||
type FFmpeg struct {
|
||||
ExtProcess
|
||||
FPS int `yaml:"fps"`
|
||||
Bitrate int `yaml:"bitrate"`
|
||||
FPS int `yaml:"fps"`
|
||||
Bitrate int `yaml:"bitrate"`
|
||||
Height int `yaml:"height"`
|
||||
GOP int `yaml:"gop"`
|
||||
Codec string `yaml:"codec"`
|
||||
}
|
||||
|
||||
func (f FFmpeg) FormatArgs() []string {
|
||||
return strings.Split(fmt.Sprintf(f.Args, f.Bitrate*1000, f.FPS), " ")
|
||||
return strings.Split(fmt.Sprintf(f.Args, f.Height, f.Codec, f.Bitrate*1000, f.FPS, f.GOP), " ")
|
||||
}
|
||||
|
||||
type UStreamer struct {
|
||||
@@ -59,6 +72,8 @@ func Get() Config {
|
||||
return c
|
||||
}
|
||||
|
||||
// arecord -D hw:0,0 -f cd -r 44100 -c 2 | /app/ffmpeg -re -init_hw_device rkmpp=hw -filter_hw_device hw -f wav -i pipe:0 -f v4l2 -c:a aac -b:a 128k -ar 44100 -ac 2 -f rtp rtp://127.0.0.1:5006?pkt_size=1200 -i /dev/video0 -vf hwupload,scale_rkrga=h=720:force_original_aspect_ratio=1 -c:v h264_rkmpp -flags +low_delay -b:v 6000000 -framerate 60 -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200
|
||||
|
||||
func Init() {
|
||||
c = Config{
|
||||
LogLevel: "debug",
|
||||
@@ -72,21 +87,30 @@ func Init() {
|
||||
Args: "--host 0.0.0.0 --port 8888 -m BGR24 -f 60",
|
||||
},
|
||||
},
|
||||
FFmpeg: FFmpeg{
|
||||
Video: FFmpeg{
|
||||
ExtProcess: ExtProcess{
|
||||
Path: "/app/ffmpeg",
|
||||
Args: "-re -i /dev/video0 -c:v h264_rkmpp -b:v %d -framerate %d -bsf:v h264_mp4toannexb -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200",
|
||||
Args: "-hide_banner -loglevel error -re -init_hw_device rkmpp=hw -filter_hw_device hw -i /dev/video0 -vf hwupload,scale_rkrga=h=%d:force_original_aspect_ratio=1 -c:v %s_rkmpp -flags +low_delay -b:v %d -framerate %d -g %d -f rtp rtp://127.0.0.1:5004?pkt_size=1200",
|
||||
//Args: "-re -i /dev/video0 -c:v h264_rkmpp -b:v %d -framerate %d -bsf:v h264_mp4toannexb -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200",
|
||||
},
|
||||
FPS: 60,
|
||||
Bitrate: 6000,
|
||||
Height: 720,
|
||||
GOP: 5,
|
||||
Codec: "h264",
|
||||
},
|
||||
Audio: []string{
|
||||
"/usr/bin/arecord -D hw:0,0 -f dat -r 48000 -c 2 --buffer-size=60",
|
||||
"/app/ffmpeg -hide_banner -loglevel error -re -f wav -i pipe:0 -c:a libopus -b:a 48000 -sample_fmt s16 -ssrc 1 -payload_type 111 -f rtp -max_delay 0 -application lowdelay -f rtp rtp://127.0.0.1:5006?pkt_size=1200",
|
||||
},
|
||||
WebRtc: WebRtc{
|
||||
Host: "127.0.0.1",
|
||||
Port: 5004,
|
||||
},
|
||||
Stream: Stream{
|
||||
Source: StreamSourceMjpeg,
|
||||
Source: StreamSourceH264,
|
||||
},
|
||||
ISOPath: "/data",
|
||||
NanoKVMUISupport: true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user