Code refactoring for FFmpeg producer

This commit is contained in:
Alex X
2024-05-23 12:40:29 +03:00
parent 6d9c7012b0
commit 02af2e2849
2 changed files with 6 additions and 5 deletions

View File

@@ -92,8 +92,6 @@ var defaults = map[string]string{
"pcml/8000": "-c:a pcm_s16le -ar:a 8000 -ac:a 1", "pcml/8000": "-c:a pcm_s16le -ar:a 8000 -ac:a 1",
"pcml/44100": "-c:a pcm_s16le -ar:a 44100 -ac:a 1", "pcml/44100": "-c:a pcm_s16le -ar:a 44100 -ac:a 1",
"opus/48000/2": "-c:a libopus -application:a lowdelay -min_comp 0 -ar:a 48000 -ac:a 2",
// hardware Intel and AMD on Linux // hardware Intel and AMD on Linux
// better not to set `-async_depth:v 1` like for QSV, because framedrops // better not to set `-async_depth:v 1` like for QSV, because framedrops
// `-bf 0` - disable B-frames is very important // `-bf 0` - disable B-frames is very important

View File

@@ -34,16 +34,19 @@ func NewProducer(url string) (core.Producer, error) {
p.Type = "FFmpeg producer" p.Type = "FFmpeg producer"
p.Medias = []*core.Media{ p.Medias = []*core.Media{
{ {
// we can support only audio, because don't know FmtpLine for H264 and PayloadType for MJPEG
Kind: core.KindAudio, Kind: core.KindAudio,
Direction: core.DirectionRecvonly, Direction: core.DirectionRecvonly,
// codecs in order from best to worst
Codecs: []*core.Codec{ Codecs: []*core.Codec{
// OPUS will always marked as OPUS/48000/2
{Name: core.CodecOpus, ClockRate: 48000, Channels: 2}, {Name: core.CodecOpus, ClockRate: 48000, Channels: 2},
{Name: core.CodecAAC, ClockRate: 16000, FmtpLine: aac.FMTP + "1408"}, {Name: core.CodecAAC, ClockRate: 16000, FmtpLine: aac.FMTP + "1408"},
{Name: core.CodecPCM, ClockRate: 16000}, {Name: core.CodecPCM, ClockRate: 16000},
{Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 16000}, {Name: core.CodecPCMA, ClockRate: 16000},
{Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 16000}, {Name: core.CodecPCMU, ClockRate: 16000},
{Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 8000}, {Name: core.CodecPCMU, ClockRate: 8000},
}, },
}, },
@@ -96,7 +99,7 @@ func (p *Producer) newURL() string {
case core.CodecAAC: case core.CodecAAC:
s += "#audio=aac/16000" s += "#audio=aac/16000"
case core.CodecOpus: case core.CodecOpus:
s += "#audio=opus/48000/2" s += "#audio=opus"
} }
} }
// add other params // add other params