diff options
author | Marton Balint <cus@passwd.hu> | 2020-04-06 00:21:47 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2020-04-16 23:52:12 +0200 |
commit | 2a118a71cfe5fe59655585484b09dbe4b3799531 (patch) | |
tree | 605b7712ec7fcdd7453674afb5834a19704fe175 | |
parent | e4ce40d25b6368cd4492f5c579e155dfe9639311 (diff) | |
download | ffmpeg-2a118a71cfe5fe59655585484b09dbe4b3799531.tar.gz |
avdevice/opengl: add support of wrapped avframe codec
Also change the default to that.
Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r-- | libavdevice/opengl_enc.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index ae03caa8c5..2bdb8da732 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -1055,13 +1055,14 @@ static av_cold int opengl_init_context(OpenGLContext *opengl) static av_cold int opengl_write_header(AVFormatContext *h) { OpenGLContext *opengl = h->priv_data; + AVCodecParameters *par = h->streams[0]->codecpar; AVStream *st; int ret; if (h->nb_streams != 1 || - h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || - h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { - av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n"); + par->codec_type != AVMEDIA_TYPE_VIDEO || + (par->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME && par->codec_id != AV_CODEC_ID_RAWVIDEO)) { + av_log(opengl, AV_LOG_ERROR, "Only a single raw or wrapped avframe video stream is supported.\n"); return AVERROR(EINVAL); } st = h->streams[0]; @@ -1256,7 +1257,13 @@ static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt) static int opengl_write_packet(AVFormatContext *h, AVPacket *pkt) { - return opengl_draw(h, pkt, 0, 1); + AVCodecParameters *par = h->streams[0]->codecpar; + if (par->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) { + AVFrame *frame = (AVFrame *)pkt->data; + return opengl_draw(h, frame, 0, 0); + } else { + return opengl_draw(h, pkt, 0, 1); + } } static int opengl_write_frame(AVFormatContext *h, int stream_index, @@ -1290,7 +1297,7 @@ AVOutputFormat ff_opengl_muxer = { .long_name = NULL_IF_CONFIG_SMALL("OpenGL output"), .priv_data_size = sizeof(OpenGLContext), .audio_codec = AV_CODEC_ID_NONE, - .video_codec = AV_CODEC_ID_RAWVIDEO, + .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_header = opengl_write_header, .write_packet = opengl_write_packet, .write_uncoded_frame = opengl_write_frame, |