chore: 发布 v1.0.1 并支持端口参数
This commit is contained in:
@@ -40,6 +40,7 @@ type RTMPServer struct {
|
||||
transcoders map[string][]*variantTranscoder
|
||||
thumbnailJobs map[string]context.CancelFunc
|
||||
internalPublishKey string
|
||||
rtmpPort string
|
||||
thumbnailDir string
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
@@ -100,13 +101,14 @@ func (w *bufferedWriteFlusher) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewRTMPServer creates and initializes a new media server
|
||||
func NewRTMPServer() *RTMPServer {
|
||||
// NewRTMPServer creates and initializes a new media server.
|
||||
func NewRTMPServer(rtmpPort string) *RTMPServer {
|
||||
s := &RTMPServer{
|
||||
channels: make(map[string]*pubsub.Queue),
|
||||
transcoders: make(map[string][]*variantTranscoder),
|
||||
thumbnailJobs: make(map[string]context.CancelFunc),
|
||||
internalPublishKey: generateInternalPublishKey(),
|
||||
rtmpPort: rtmpPort,
|
||||
thumbnailDir: filepath.Join(os.TempDir(), "hightube-thumbnails"),
|
||||
server: &rtmp.Server{},
|
||||
}
|
||||
@@ -348,8 +350,8 @@ func (s *RTMPServer) startVariantTranscoders(roomID string) {
|
||||
launch := make([]*variantTranscoder, 0, len(supportedQualities))
|
||||
for quality, profile := range supportedQualities {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
inputURL := fmt.Sprintf("rtmp://127.0.0.1:1935/live/%s", roomID)
|
||||
outputURL := fmt.Sprintf("rtmp://127.0.0.1:1935/variant/%s/%s/%s", roomID, quality, s.internalPublishKey)
|
||||
inputURL := fmt.Sprintf("rtmp://127.0.0.1:%s/live/%s", s.rtmpPort, roomID)
|
||||
outputURL := fmt.Sprintf("rtmp://127.0.0.1:%s/variant/%s/%s/%s", s.rtmpPort, roomID, quality, s.internalPublishKey)
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"ffmpeg",
|
||||
@@ -475,7 +477,7 @@ func (s *RTMPServer) captureThumbnail(roomID string) {
|
||||
"-y",
|
||||
"-loglevel", "error",
|
||||
"-rtmp_live", "live",
|
||||
"-i", fmt.Sprintf("rtmp://127.0.0.1:1935/live/%s", roomID),
|
||||
"-i", fmt.Sprintf("rtmp://127.0.0.1:%s/live/%s", s.rtmpPort, roomID),
|
||||
"-frames:v", "1",
|
||||
"-q:v", "4",
|
||||
tempPath,
|
||||
|
||||
Reference in New Issue
Block a user