1 /* === S Y N F I G ========================================================= */
2 /*! \file mptr_mplayer.cpp
3 ** \brief ppm Target Module
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 ** === N O T E S ===========================================================
23 ** ========================================================================= */
25 /* === H E A D E R S ======================================================= */
34 #include <synfig/synfig.h>
35 #include <ETL/stringf>
36 #include "mptr_mplayer.h"
41 #include <ETL/stringf>
44 /* === M A C R O S ========================================================= */
46 using namespace synfig;
50 /* === G L O B A L S ======================================================= */
52 const char mplayer_mptr::Name[]="avi";
53 const char mplayer_mptr::Ext[]="avi";
55 /* === M E T H O D S ======================================================= */
58 mplayer_mptr::New(const char *file)
60 return new mplayer_mptr(file);
63 mplayer_mptr::mplayer_mptr(const char *file)
68 mplayer_mptr::~mplayer_mptr()
73 mplayer_mptr::GetFrame(Time time, synfig::Surface &surface, synfig::ProgressCallback *)
76 #error This code has vulnerabilites: arbitrary shell command execution and tmpfile issues
80 strprintf("/usr/local/bin/mencoder \"%s\" -ovc rawrgb -ss %f -endpos 0 -nosound -o /tmp/tmp.synfig.rgbdata | grep \"VIDEO\" > /tmp/tmp.synfig.size",
88 cerr<<"mencoder execution failed."<<endl;
92 FILE *sizefile=fopen("/tmp/tmp.synfig.size","rt");
93 FILE *rgbfile=fopen("/tmp/tmp.synfig.rgbdata","rb");
96 cerr<<"unable to open /tmp/tmp.synfig.rgbdata"<<endl;
101 cerr<<"unable to open /tmp/tmp.synfig.size"<<endl;
108 fscanf(sizefile,"%s %s %dx%d",bleh,bleh,&w,&h);
110 cerr<<strprintf("w:%d, h:%d, time:%f",w,h,time)<<endl;
111 fseek(rgbfile,2047+3*8,SEEK_CUR);
117 b=(unsigned char)fgetc(rgbfile),
118 g=(unsigned char)fgetc(rgbfile),
119 r=(unsigned char)fgetc(rgbfile);
121 surface[h-y-1][x]=Color(