FFmpeg: Support audio-only recording
Vicki Pfau vi@endrift.com
Tue, 14 May 2019 14:25:20 -0700
3 files changed,
20 insertions(+),
4 deletions(-)
M
CHANGES
→
CHANGES
@@ -57,6 +57,7 @@ - Debugger: Make tracing compatible with breakpoints/watchpoints
- Debugger: Print breakpoint/watchpoint number when inserting - Qt: Open a message box for Qt frontend errors - GBA Video: Clean up dead code in sprite rendering loop + - FFmpeg: Support audio-only recording 0.7.1: (2019-02-24) Bugfixes:
M
src/feature/ffmpeg/ffmpeg-encoder.c
→
src/feature/ffmpeg/ffmpeg-encoder.c
@@ -55,10 +55,12 @@ encoder->resampleContext = NULL;
encoder->absf = NULL; encoder->context = NULL; encoder->scaleContext = NULL; + encoder->audio = NULL; encoder->audioStream = NULL; encoder->audioFrame = NULL; encoder->audioBuffer = NULL; encoder->postaudioBuffer = NULL; + encoder->video = NULL; encoder->videoStream = NULL; encoder->videoFrame = NULL; }@@ -146,6 +148,12 @@ { AV_PIX_FMT_YUV422P, 4 },
{ AV_PIX_FMT_YUV444P, 5 }, { AV_PIX_FMT_YUV420P, 6 } }; + + if (!vcodec) { + encoder->videoCodec = 0; + return true; + } + AVCodec* codec = avcodec_find_encoder_by_name(vcodec); if (!codec) { return false;@@ -189,13 +197,13 @@ bool FFmpegEncoderVerifyContainer(struct FFmpegEncoder* encoder) {
AVOutputFormat* oformat = av_guess_format(encoder->containerFormat, 0, 0); AVCodec* acodec = avcodec_find_encoder_by_name(encoder->audioCodec); AVCodec* vcodec = avcodec_find_encoder_by_name(encoder->videoCodec); - if ((encoder->audioCodec && !acodec) || !vcodec || !oformat) { + if ((encoder->audioCodec && !acodec) || (encoder->videoCodec && !vcodec) || !oformat) { return false; } if (encoder->audioCodec && !avformat_query_codec(oformat, acodec->id, FF_COMPLIANCE_EXPERIMENTAL)) { return false; } - if (!avformat_query_codec(oformat, vcodec->id, FF_COMPLIANCE_EXPERIMENTAL)) { + if (encoder->videoCodec && !avformat_query_codec(oformat, vcodec->id, FF_COMPLIANCE_EXPERIMENTAL)) { return false; } return true;@@ -562,7 +570,7 @@ }
void _ffmpegPostVideoFrame(struct mAVStream* stream, const color_t* pixels, size_t stride) { struct FFmpegEncoder* encoder = (struct FFmpegEncoder*) stream; - if (!encoder->context) { + if (!encoder->context || !encoder->videoCodec) { return; } stride *= BYTES_PER_PIXEL;@@ -606,6 +614,9 @@ }
static void _ffmpegSetVideoDimensions(struct mAVStream* stream, unsigned width, unsigned height) { struct FFmpegEncoder* encoder = (struct FFmpegEncoder*) stream; + if (!encoder->context || !encoder->videoCodec) { + return; + } encoder->iwidth = width; encoder->iheight = height; if (encoder->scaleContext) {
M
src/platform/qt/VideoView.cpp
→
src/platform/qt/VideoView.cpp
@@ -275,7 +275,11 @@
void VideoView::setVideoCodec(const QString& codec, bool manual) { free(m_videoCodecCstr); m_videoCodec = sanitizeCodec(codec, s_vcodecMap); - m_videoCodecCstr = strdup(m_videoCodec.toUtf8().constData()); + if (m_videoCodec == "none") { + m_videoCodecCstr = nullptr; + } else { + m_videoCodecCstr = strdup(m_videoCodec.toUtf8().constData()); + } if (!FFmpegEncoderSetVideo(&m_encoder, m_videoCodecCstr, m_vbr)) { free(m_videoCodecCstr); m_videoCodecCstr = nullptr;