1 /*! ========================================================================
4 ** $Id: mptr_mplayer.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
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.
18 ** === N O T E S ===========================================================
20 ** ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include <synfig/synfig.h>
32 #include <ETL/stringf>
33 #include "mptr_mplayer.h"
38 #include <ETL/stringf>
41 /* === M A C R O S ========================================================= */
43 using namespace synfig;
47 /* === G L O B A L S ======================================================= */
49 const char mplayer_mptr::Name[]="avi";
50 const char mplayer_mptr::Ext[]="avi";
52 /* === M E T H O D S ======================================================= */
55 mplayer_mptr::New(const char *file)
57 return new mplayer_mptr(file);
60 mplayer_mptr::mplayer_mptr(const char *file)
65 mplayer_mptr::~mplayer_mptr()
70 mplayer_mptr::GetFrame(Time time, synfig::Surface &surface, synfig::ProgressCallback *)
74 strprintf("/usr/local/bin/mencoder \"%s\" -ovc rawrgb -ss %f -endpos 0 -nosound -o /tmp/tmp.synfig.rgbdata | grep \"VIDEO\" > /tmp/tmp.synfig.size",
82 cerr<<"mencoder execution failed."<<endl;
86 FILE *sizefile=fopen("/tmp/tmp.synfig.size","rt");
87 FILE *rgbfile=fopen("/tmp/tmp.synfig.rgbdata","rb");
90 cerr<<"unable to open /tmp/tmp.synfig.rgbdata"<<endl;
95 cerr<<"unable to open /tmp/tmp.synfig.size"<<endl;
102 fscanf(sizefile,"%s %s %dx%d",bleh,bleh,&w,&h);
104 cerr<<strprintf("w:%d, h:%d, time:%f",w,h,time)<<endl;
105 fseek(rgbfile,2047+3*8,SEEK_CUR);
111 b=(unsigned char)fgetc(rgbfile),
112 g=(unsigned char)fgetc(rgbfile),
113 r=(unsigned char)fgetc(rgbfile);
115 surface[h-y-1][x]=Color(