Skip to content

Commit

Permalink
Code refactoring for FFmpeg producer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 23, 2024
1 parent 6d9c701 commit 02af2e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions internal/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ var defaults = map[string]string{
"pcml/8000": "-c:a pcm_s16le -ar:a 8000 -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
// better not to set `-async_depth:v 1` like for QSV, because framedrops
// `-bf 0` - disable B-frames is very important
Expand Down
9 changes: 6 additions & 3 deletions internal/ffmpeg/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ func NewProducer(url string) (core.Producer, error) {
p.Type = "FFmpeg producer"
p.Medias = []*core.Media{
{
// we can support only audio, because don't know FmtpLine for H264 and PayloadType for MJPEG
Kind: core.KindAudio,
Direction: core.DirectionRecvonly,
// codecs in order from best to worst
Codecs: []*core.Codec{
// OPUS will always marked as OPUS/48000/2
{Name: core.CodecOpus, ClockRate: 48000, Channels: 2},
{Name: core.CodecAAC, ClockRate: 16000, FmtpLine: aac.FMTP + "1408"},
{Name: core.CodecPCM, ClockRate: 16000},
{Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 16000},
{Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 16000},
{Name: core.CodecPCM, ClockRate: 8000},
{Name: core.CodecPCMA, ClockRate: 8000},
{Name: core.CodecPCMU, ClockRate: 8000},
},
},
Expand Down Expand Up @@ -96,7 +99,7 @@ func (p *Producer) newURL() string {
case core.CodecAAC:
s += "#audio=aac/16000"
case core.CodecOpus:
s += "#audio=opus/48000/2"
s += "#audio=opus"
}
}
// add other params
Expand Down

0 comments on commit 02af2e2

Please sign in to comment.