diff --git a/plugin/transcode/api.go b/plugin/transcode/api.go index 74c75fa..3030a53 100755 --- a/plugin/transcode/api.go +++ b/plugin/transcode/api.go @@ -269,7 +269,10 @@ func (t *TranscodePlugin) Launch(ctx context.Context, transReq *pb.TransRequest) if transReq.Scale != "" { transReq.Scale = fmt.Sprintf(" -s %s ", transReq.Scale) } - conf = strings.Join(inputs, " -i ") + fmt.Sprintf(" %s ", transReq.LogLevel) + fmt.Sprintf(" %s ", filterStr) + transReq.Scale + transReq.Decodec + if transReq.GlobalOptions != "" { + transReq.GlobalOptions = fmt.Sprintf(" %s ", transReq.GlobalOptions) + } + conf = strings.Join(inputs, " -i ") + fmt.Sprintf(" %s ", filterStr) + transReq.Scale + transReq.Encodec cfg.Output = []config.TransfromOutput{ { @@ -278,6 +281,10 @@ func (t *TranscodePlugin) Launch(ctx context.Context, transReq *pb.TransRequest) Conf: conf, }, } + cfg.Input = map[string]any{ + "args": transReq.GlobalOptions, + "codec": transReq.Decodec, + } t.Transform(transReq.SrcStream, cfg) return diff --git a/plugin/transcode/pb/transcode.pb.go b/plugin/transcode/pb/transcode.pb.go index 05e639b..bfb24ff 100644 --- a/plugin/transcode/pb/transcode.pb.go +++ b/plugin/transcode/pb/transcode.pb.go @@ -39,7 +39,7 @@ type OverlayConfig struct { FontSize string `protobuf:"bytes,9,opt,name=font_size,json=fontSize,proto3" json:"font_size,omitempty"` // 字体大小 FontColor string `protobuf:"bytes,10,opt,name=font_color,json=fontColor,proto3" json:"font_color,omitempty"` // r,g,b 颜色 TextPosition string `protobuf:"bytes,11,opt,name=text_position,json=textPosition,proto3" json:"text_position,omitempty"` // x,y 文字在图片上的位置 - LineSpacing string `protobuf:"bytes,12,opt,name=line_spacing,json=lineSpacing,proto3" json:"line_spacing,omitempty"` //文字间距 + LineSpacing string `protobuf:"bytes,12,opt,name=line_spacing,json=lineSpacing,proto3" json:"line_spacing,omitempty"` //文字行间距 } func (x *OverlayConfig) Reset() { @@ -161,13 +161,13 @@ type TransRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SrcStream string `protobuf:"bytes,1,opt,name=src_stream,json=srcStream,proto3" json:"src_stream,omitempty"` // 原始流 - DstStream string `protobuf:"bytes,2,opt,name=dst_stream,json=dstStream,proto3" json:"dst_stream,omitempty"` // 输出流 - Encodec string `protobuf:"bytes,3,opt,name=encodec,proto3" json:"encodec,omitempty"` - Decodec string `protobuf:"bytes,4,opt,name=decodec,proto3" json:"decodec,omitempty"` - Scale string `protobuf:"bytes,5,opt,name=scale,proto3" json:"scale,omitempty"` - LogLevel string `protobuf:"bytes,6,opt,name=log_level,json=logLevel,proto3" json:"log_level,omitempty"` - OverlayConfigs []*OverlayConfig `protobuf:"bytes,7,rep,name=overlay_configs,json=overlayConfigs,proto3" json:"overlay_configs,omitempty"` + GlobalOptions string `protobuf:"bytes,1,opt,name=global_options,json=globalOptions,proto3" json:"global_options,omitempty"` // 全局参数 + SrcStream string `protobuf:"bytes,2,opt,name=src_stream,json=srcStream,proto3" json:"src_stream,omitempty"` // 原始流 + DstStream string `protobuf:"bytes,3,opt,name=dst_stream,json=dstStream,proto3" json:"dst_stream,omitempty"` // 输出流 + Encodec string `protobuf:"bytes,4,opt,name=encodec,proto3" json:"encodec,omitempty"` + Decodec string `protobuf:"bytes,5,opt,name=decodec,proto3" json:"decodec,omitempty"` + Scale string `protobuf:"bytes,6,opt,name=scale,proto3" json:"scale,omitempty"` + OverlayConfigs []*OverlayConfig `protobuf:"bytes,8,rep,name=overlay_configs,json=overlayConfigs,proto3" json:"overlay_configs,omitempty"` } func (x *TransRequest) Reset() { @@ -200,6 +200,13 @@ func (*TransRequest) Descriptor() ([]byte, []int) { return file_transcode_proto_rawDescGZIP(), []int{1} } +func (x *TransRequest) GetGlobalOptions() string { + if x != nil { + return x.GlobalOptions + } + return "" +} + func (x *TransRequest) GetSrcStream() string { if x != nil { return x.SrcStream @@ -235,13 +242,6 @@ func (x *TransRequest) GetScale() string { return "" } -func (x *TransRequest) GetLogLevel() string { - if x != nil { - return x.LogLevel - } - return "" -} - func (x *TransRequest) GetOverlayConfigs() []*OverlayConfig { if x != nil { return x.OverlayConfigs @@ -337,43 +337,43 @@ var file_transcode_proto_rawDesc = []byte{ 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x78, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x70, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x22, 0xf6, 0x01, 0x0a, - 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x72, 0x63, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x72, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, - 0x64, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x64, 0x73, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, - 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x63, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, - 0x14, 0x0a, 0x05, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x73, 0x63, 0x61, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x67, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x12, 0x41, 0x0a, 0x0f, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x5f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x22, 0x4c, 0x0a, 0x0c, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x72, 0x63, 0x5f, 0x73, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x72, 0x63, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x73, 0x74, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x32, 0xbf, 0x01, 0x0a, 0x03, 0x61, 0x70, 0x69, 0x12, 0x5c, 0x0a, 0x06, 0x6c, - 0x61, 0x75, 0x6e, 0x63, 0x68, 0x12, 0x17, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, - 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, - 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2e, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, - 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x12, 0x5a, 0x0a, 0x05, 0x63, 0x6c, 0x6f, - 0x73, 0x65, 0x12, 0x17, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x43, - 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6c, - 0x6f, 0x62, 0x61, 0x6c, 0x2e, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x3a, 0x01, 0x2a, 0x22, - 0x14, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x42, 0x25, 0x5a, 0x23, 0x6d, 0x37, 0x73, 0x2e, 0x6c, 0x69, 0x76, - 0x65, 0x2f, 0x6d, 0x37, 0x73, 0x2f, 0x76, 0x35, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x70, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x22, 0x80, 0x02, 0x0a, + 0x0c, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, + 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x72, 0x63, 0x5f, 0x73, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x72, 0x63, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x73, 0x74, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, 0x18, 0x0a, 0x07, + 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, + 0x65, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x12, 0x41, 0x0a, 0x0f, + 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, + 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, + 0x65, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x0e, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x22, + 0x4c, 0x0a, 0x0c, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x72, 0x63, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x72, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1d, + 0x0a, 0x0a, 0x64, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x64, 0x73, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x32, 0xbf, 0x01, + 0x0a, 0x03, 0x61, 0x70, 0x69, 0x12, 0x5c, 0x0a, 0x06, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x12, + 0x17, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x2e, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6c, 0x61, 0x75, + 0x6e, 0x63, 0x68, 0x12, 0x5a, 0x0a, 0x05, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x2e, 0x53, + 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x3a, 0x01, 0x2a, 0x22, 0x14, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x63, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x42, + 0x25, 0x5a, 0x23, 0x6d, 0x37, 0x73, 0x2e, 0x6c, 0x69, 0x76, 0x65, 0x2f, 0x6d, 0x37, 0x73, 0x2f, + 0x76, 0x35, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x63, + 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/plugin/transcode/pb/transcode.proto b/plugin/transcode/pb/transcode.proto index d33d383..86efef3 100644 --- a/plugin/transcode/pb/transcode.proto +++ b/plugin/transcode/pb/transcode.proto @@ -33,17 +33,17 @@ message OverlayConfig { string font_size = 9; // 字体大小 string font_color = 10; // r,g,b 颜色 string text_position = 11; // x,y 文字在图片上的位置 - string line_spacing = 12; //文字间距 + string line_spacing = 12; //文字行间距 } message TransRequest { - string src_stream = 1; // 原始流 - string dst_stream = 2; // 输出流 - string encodec = 3; - string decodec = 4; - string scale = 5; - string log_level = 6; - repeated OverlayConfig overlay_configs = 7; + string global_options = 1; // 全局参数 + string src_stream = 2; // 原始流 + string dst_stream = 3; // 输出流 + string encodec = 4; + string decodec = 5; + string scale = 6; + repeated OverlayConfig overlay_configs = 8; } message CloseRequest {