Skip to content

container/flv: add audio support - #45

Merged
elliot-ausocean merged 14 commits into
mainfrom
add-audio-flv
Dec 15, 2025
Merged

elliot-ausocean merged 14 commits into
mainfrom
add-audio-flv

Conversation

@elliot-ausocean

Copy link
Copy Markdown
Collaborator

We currently just add dummy audio, which does not allow us to have anything other than silence. This requires renaming frame to videoFrame. I have also made Write return the total number of bytes written, rather than just the size of the video frame.

We currently just add dummy audio, which does not allow us to have
anything other than silence.

@ao-david ao-david left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a promising step!
I would like to see the tests passing and this still working with YouTube before merging

Comment thread container/flv/encoder.go
Comment thread container/flv/encoder.go
Comment thread container/flv/encoder.go Outdated
Comment thread container/flv/encoder.go Outdated
Comment thread container/flv/encoder.go Outdated
Comment thread container/flv/flv.go
Comment thread container/flv/flv.go
Comment thread container/flv/flv_test.go
Comment thread container/flv/flv_test.go
This is so that audio and video can be written separately. Some adapters
are also provided to interface with io.Writer. A dummy audio decorator
is provided for when you don't want any audio.
@saxon-milton
saxon-milton self-requested a review December 10, 2025 01:42
Added audio functionality to the stream from file test for RTSP so that
we know it actually works. Also added a ADTS lexer, which may come in
handy.
@elliot-ausocean

Copy link
Copy Markdown
Collaborator Author

I have added a test (which worked successfully, albeit with some freezing). I think all of the comment should be fixed up now.

Comment thread container/flv/encoder.go
Comment thread container/flv/encoder.go
Comment thread codec/aac/lex.go Outdated
Comment thread container/flv/encoder.go Outdated
Comment thread container/flv/encoder.go Outdated
Comment thread container/flv/encoder.go Outdated
@saxon-milton

Copy link
Copy Markdown
Member

This PR is quite big. Any chance we could do separate PRs ? Maybe one for reformatting, another for adding the lexer and then the other for the test ? And any other changes you think would be worth splitting up ?

@saxon-milton saxon-milton left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider splitting this up into separate pull requests. I'm also not sure we need the adapter code at this stage. ISTM we could have written a proof of concept test without making modifications to the primary interface we're currently using in the pipeline.

Comment thread protocol/rtmp/rtmp_test.go Outdated
Comment thread protocol/rtmp/rtmp_test.go Outdated
Comment thread protocol/rtmp/rtmp_test.go Outdated

@trekhopton trekhopton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revisit once the discussed changes to the encoder have been made.

This is so that the previous interface is retained. Dummy audio is now
written by default again and can be enabled or disabled using
SetDummyAudio.
Comment thread container/flv/encoder.go
Comment thread container/flv/encoder.go

// SetDummyAudio disables or enables the sending of dummy audio frames at the same time as video frames.
// After this function is called, a new audio config must be sent in the first WriteAudio operation.
func (e *Encoder) SetDummyAudio(enabled bool) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done this as a setter as the audio specific config should be reset at the same time. This is because the new audio stream may have a different config.

Comment thread container/flv/encoder.go Outdated
@elliot-ausocean

Copy link
Copy Markdown
Collaborator Author

Tested streaming to youtube on latest commit and it works great. I believe this is all good to go now.

@elliot-ausocean
elliot-ausocean merged commit 1e59e44 into main Dec 15, 2025
1 check passed
@elliot-ausocean
elliot-ausocean deleted the add-audio-flv branch December 15, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants