1 /* === S Y N F I G ========================================================= */
2 /*! \file mptr_mplayer.cpp
3 ** \brief ppm Target Module
6 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
19 ** === N O T E S ===========================================================
21 ** ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include <synfig/synfig.h>
33 #include <ETL/stringf>
34 #include "mptr_mplayer.h"
39 #include <ETL/stringf>
42 /* === M A C R O S ========================================================= */
44 using namespace synfig;
48 /* === G L O B A L S ======================================================= */
50 const char mplayer_mptr::Name[]="avi";
51 const char mplayer_mptr::Ext[]="avi";
53 /* === M E T H O D S ======================================================= */
56 mplayer_mptr::New(const char *file)
58 return new mplayer_mptr(file);
61 mplayer_mptr::mplayer_mptr(const char *file)
66 mplayer_mptr::~mplayer_mptr()
71 mplayer_mptr::GetFrame(Time time, synfig::Surface &surface, synfig::ProgressCallback *)
75 strprintf("/usr/local/bin/mencoder \"%s\" -ovc rawrgb -ss %f -endpos 0 -nosound -o /tmp/tmp.synfig.rgbdata | grep \"VIDEO\" > /tmp/tmp.synfig.size",
83 cerr<<"mencoder execution failed."<<endl;
87 FILE *sizefile=fopen("/tmp/tmp.synfig.size","rt");
88 FILE *rgbfile=fopen("/tmp/tmp.synfig.rgbdata","rb");
91 cerr<<"unable to open /tmp/tmp.synfig.rgbdata"<<endl;
96 cerr<<"unable to open /tmp/tmp.synfig.size"<<endl;
103 fscanf(sizefile,"%s %s %dx%d",bleh,bleh,&w,&h);
105 cerr<<strprintf("w:%d, h:%d, time:%f",w,h,time)<<endl;
106 fseek(rgbfile,2047+3*8,SEEK_CUR);
112 b=(unsigned char)fgetc(rgbfile),
113 g=(unsigned char)fgetc(rgbfile),
114 r=(unsigned char)fgetc(rgbfile);
116 surface[h-y-1][x]=Color(