Skip to content

Commit 02af2e2

Browse files
committed
Code refactoring for FFmpeg producer
1 parent 6d9c701 commit 02af2e2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

internal/ffmpeg/ffmpeg.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ var defaults = map[string]string{
9292
"pcml/8000": "-c:a pcm_s16le -ar:a 8000 -ac:a 1",
9393
"pcml/44100": "-c:a pcm_s16le -ar:a 44100 -ac:a 1",
9494

95-
"opus/48000/2": "-c:a libopus -application:a lowdelay -min_comp 0 -ar:a 48000 -ac:a 2",
96-
9795
// hardware Intel and AMD on Linux
9896
// better not to set `-async_depth:v 1` like for QSV, because framedrops
9997
// `-bf 0` - disable B-frames is very important

internal/ffmpeg/producer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ func NewProducer(url string) (core.Producer, error) {
3434
p.Type = "FFmpeg producer"
3535
p.Medias = []*core.Media{
3636
{
37+
// we can support only audio, because don't know FmtpLine for H264 and PayloadType for MJPEG
3738
Kind: core.KindAudio,
3839
Direction: core.DirectionRecvonly,
40+
// codecs in order from best to worst
3941
Codecs: []*core.Codec{
42+
// OPUS will always marked as OPUS/48000/2
4043
{Name: core.CodecOpus, ClockRate: 48000, Channels: 2},
4144
{Name: core.CodecAAC, ClockRate: 16000, FmtpLine: aac.FMTP + "1408"},
4245
{Name: core.CodecPCM, ClockRate: 16000},
43-
{Name: core.CodecPCM, ClockRate: 8000},
4446
{Name: core.CodecPCMA, ClockRate: 16000},
45-
{Name: core.CodecPCMA, ClockRate: 8000},
4647
{Name: core.CodecPCMU, ClockRate: 16000},
48+
{Name: core.CodecPCM, ClockRate: 8000},
49+
{Name: core.CodecPCMA, ClockRate: 8000},
4750
{Name: core.CodecPCMU, ClockRate: 8000},
4851
},
4952
},
@@ -96,7 +99,7 @@ func (p *Producer) newURL() string {
9699
case core.CodecAAC:
97100
s += "#audio=aac/16000"
98101
case core.CodecOpus:
99-
s += "#audio=opus/48000/2"
102+
s += "#audio=opus"
100103
}
101104
}
102105
// add other params

0 commit comments

Comments
 (0)