Created
June 3, 2011 06:56
-
-
Save fudanchii/1005980 to your computer and use it in GitHub Desktop.
lulz patch for mplayer screenshot filter v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/command.c b/command.c | |
index de7f1fb..c0e0087 100644 | |
--- a/command.c | |
+++ b/command.c | |
@@ -3289,12 +3289,13 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) | |
case MP_CMD_SCREENSHOT: | |
if (mpctx->video_out && mpctx->video_out->config_ok) { | |
+ char *fname = get_metadata(mpctx, META_NAME); | |
+ void* param[2] = {&cmd->args[0].v.i, fname}; | |
mp_msg(MSGT_CPLAYER, MSGL_INFO, "sending VFCTRL_SCREENSHOT!\n"); | |
- if (CONTROL_OK != | |
- ((vf_instance_t *) sh_video->vfilter)-> | |
- control(sh_video->vfilter, VFCTRL_SCREENSHOT, | |
- &cmd->args[0].v.i)) | |
+ if (CONTROL_OK != ((vf_instance_t *) sh_video->vfilter)-> | |
+ control(sh_video->vfilter, VFCTRL_SCREENSHOT, ¶m)) | |
mp_msg(MSGT_CPLAYER, MSGL_INFO, "failed (forgot -vf screenshot?)\n"); | |
+ talloc_free(fname); | |
} | |
break; | |
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c | |
index 1b5d575..cbfa223 100644 | |
--- a/libmpcodecs/vf_screenshot.c | |
+++ b/libmpcodecs/vf_screenshot.c | |
@@ -54,6 +54,7 @@ struct vf_priv_s { | |
AVCodecContext *avctx; | |
uint8_t *outbuffer; | |
int outbuffer_size; | |
+ char mpctx_fname[90]; | |
}; | |
//===========================================================================// | |
@@ -113,7 +114,10 @@ static int fexists(char *fname) | |
static void gen_fname(struct vf_priv_s* priv) | |
{ | |
do { | |
- snprintf (priv->fname, 100, "shot%04d.png", ++priv->frameno); | |
+ if (!priv->mpctx_fname[0]) | |
+ snprintf (priv->fname, 100, "shot%04d.png", ++priv->frameno); | |
+ else | |
+ snprintf (priv->fname, 100, "%s.%04d.png", priv->mpctx_fname, ++priv->frameno); | |
} while (fexists(priv->fname) && priv->frameno < 100000); | |
if (fexists(priv->fname)) { | |
priv->fname[0] = '\0'; | |
@@ -229,7 +233,7 @@ static int control (vf_instance_t *vf, int request, void *data) | |
* 1: take screenshots with each frame until the same command is given once again | |
**/ | |
if(request==VFCTRL_SCREENSHOT) { | |
- if (data && *(int*)data) { // repeated screenshot mode | |
+ if (data && *((int**)data)[0]) { // repeated screenshot mode | |
if (vf->priv->shot==2) | |
vf->priv->shot=0; | |
else | |
@@ -238,6 +242,9 @@ static int control (vf_instance_t *vf, int request, void *data) | |
if (!vf->priv->shot) | |
vf->priv->shot=1; | |
} | |
+ if (data && (((char**)data)[1])[0]) { | |
+ strncpy(vf->priv->mpctx_fname, ((char**)data)[1], 89); | |
+ } | |
return CONTROL_TRUE; | |
} | |
return vf_next_control (vf, request, data); | |
@@ -320,3 +327,4 @@ const vf_info_t vf_info_screenshot = { | |
}; | |
//===========================================================================// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment