initial commit
This commit is contained in:
53
http/hw/stream/ffmpeg.go
Normal file
53
http/hw/stream/ffmpeg.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package stream
|
||||
|
||||
import (
|
||||
"rkkvm/config"
|
||||
)
|
||||
|
||||
//h264
|
||||
//ffmpeg -re -i /dev/video0 -c:v h264_rkmpp -b:v 2000000 -bsf:v h264_mp4toannexb -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200
|
||||
|
||||
//h265
|
||||
//ffmpeg -re -i /dev/video0 -c:v hevc_rkmpp -b:v 2000000 -g 10 -f rtp rtp://127.0.0.1:5004?pkt_size=1200
|
||||
|
||||
// vp8
|
||||
//ffmpeg -re -i /dev/video0 -c:v libvpx -crf 10 -b:v 3M -deadline 1 -g 10 -error-resilient 1 -auto-alt-ref 1 -an -f rtp rtp://127.0.0.1:5004?pkt_size=1200
|
||||
|
||||
// https://jsfiddle.net/z7ms3u5r/
|
||||
|
||||
var ffmpeg *FFmpeg
|
||||
|
||||
type FFmpeg struct {
|
||||
*ExtProcess
|
||||
config.FFmpeg
|
||||
}
|
||||
|
||||
func (f *FFmpeg) SetBitrate(b int) {
|
||||
f.Bitrate = b
|
||||
if f.Bitrate < 0 {
|
||||
f.Bitrate = 6000
|
||||
}
|
||||
|
||||
f.ChangeArgs(f.FormatArgs())
|
||||
}
|
||||
|
||||
func (f *FFmpeg) SetFPS(fps int) {
|
||||
f.FPS = fps
|
||||
if f.FPS < 0 {
|
||||
f.FPS = 30
|
||||
}
|
||||
|
||||
f.ChangeArgs(f.FormatArgs())
|
||||
}
|
||||
|
||||
func InitFFmpeg(path string, args []string) *FFmpeg {
|
||||
ffmpeg = &FFmpeg{
|
||||
ExtProcess: Init(path, args),
|
||||
FFmpeg: config.Get().FFmpeg,
|
||||
}
|
||||
return ffmpeg
|
||||
}
|
||||
|
||||
func GetFFmpeg() *FFmpeg {
|
||||
return ffmpeg
|
||||
}
|
||||
Reference in New Issue
Block a user