[PATCH] fix failure to initialize screenshot filter

"Thomas Kirsten" <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <op.yjtdyeqzk5yp9f@caesar>
Hello,

ffmpeg recently extended the verification logic in avcodec_open2, see
https://github.com/FFmpeg/FFmpeg/commit/e62ff72fc1052273deb708ba715f73e5187281d4

The function now fails when timebase (in AVCodecContext) is not set
properly. This essentially disables the screenshot filter as it does not
set those members and therefor its PNG output context fails to initialize.

When run as "mplayer -vf screenshot file", it prints those errors during
the start:

[png @ 0x81101000]The encoder timebase is not set.
Could not open libavcodec PNG encoder
FATAL: Cannot initialize video driver.

The first one is from the new ffmpeg code, the others are from
libmpcodecs/vf_screenshot.c. Pressing the screenshot button makes the
program crash in "write_png" in the libmpcodecs/vf_screenshot.c.

The patch sets the timebase field in libmpcodecs/vf_screenshot.c to 1/1
(documentation states it should be 1/framerate, but a single screenshot
doesn't have a framerate). It satisfies the new check in ffmpeg, the
filter is initialized and making the screenshot works fine.

I'm not sure whether the value 1/1 for the timebase is correct, someone
knowing about avcodec_open2 should approve this.

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
mplayer-vf-screenshot-avcodec_open2-fix.patch (application/octet-stream, 680 B)
Index: libmpcodecs/vf_screenshot.c
===================================================================
--- libmpcodecs/vf_screenshot.c	(revision 37872)
+++ libmpcodecs/vf_screenshot.c	(working copy)
@@ -81,6 +81,8 @@
         vf->priv->avctx->pix_fmt = AV_PIX_FMT_RGB24;
         vf->priv->avctx->width = d_width;
         vf->priv->avctx->height = d_height;
+        vf->priv->avctx->time_base.num = 1;
+        vf->priv->avctx->time_base.den = 1;
         vf->priv->avctx->compression_level = 0;
         if (avcodec_open2(vf->priv->avctx, avcodec_find_encoder(AV_CODEC_ID_PNG), NULL)) {
             mp_msg(MSGT_VFILTER, MSGL_FATAL, "Could not open libavcodec PNG encoder\n");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.