Commit a0f5a5be authored by Philippe Gorley's avatar Philippe Gorley Committed by Sébastien Blin

encoder: fix audio only initialization

MediaRecorder only calls the MediaEncoder with an AVFrame*, not with our
VideoFrame/AudioFrame wrappers, so the audio stream was never
initialized.

Gitlab: #95
Change-Id: Ie9c85eb9334444f2b58a4355e8f6db9d2a14610f
Reviewed-by: Sébastien Blin's avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
parent 5c60caa6
......@@ -469,9 +469,13 @@ MediaEncoder::encode(AVFrame* frame, int streamIdx)
if (!initialized_ && frame) {
// Initialize on first video frame, or first audio frame if no video stream
bool isVideo = (frame->width > 0 && frame->height > 0);
if (isVideo or not videoOpts_.isValid()) {
if (isVideo and videoOpts_.isValid()) {
// Has video stream, so init with video frame
streamIdx = initStream(videoCodec_, frame->hw_frames_ctx);
startIO();
} else if (!isVideo and !videoOpts_.isValid()) {
// Only audio, for MediaRecorder, which doesn't use encodeAudio
startIO();
} else {
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment