inutero Posted May 5, 2008 Share Posted May 5, 2008 Ok, I'm rather new to php so sorry for that. I'm trying to use ffmpeg to convert videos to flv, I can get it to work but I want the input and output files to be variables. My current code looks like this: <?php $source="cat.mpeg"; $destination="cat.flv"; class convert { function convert($source,$destination) { // this will create a .flv from .wmv // you can chnage the other parameters if you are an expert exec("ffmpeg -i -f {$source} {$destination}"); } } $jf=new convert($source,$destination); ?> The problem is the variables don't seem to be read, I'm pretty sure it is the way I have written them. I know ffmpeg works because if I replace the $source & $destination the conversion works fine. Any tips on how to correct this? Link to comment https://forums.phpfreaks.com/topic/104177-need-help-with-simple-ffmpeg-class/ Share on other sites More sharing options...
dooper3 Posted May 5, 2008 Share Posted May 5, 2008 You are not declaring the variables inside the class, so I don't think it will work. Try this instead... <?php class convert { var $source; var $destination; function convert() { // this will create a .flv from .wmv // you can chnage the other parameters if you are an expert exec("ffmpeg -i -f {$this->source} {$this->destination}"); } } $jf=new convert(); $jf->source="cat.mpeg"; $jf->destination="cat.flv"; $jf->convert(); ?> That should work if it is loading the files correctly, but don't hold your breath, I haven't tested it. If not, there is an OOP forum, which may help a little more, as people in their are more familiar with classes and other OOP stuff. Link to comment https://forums.phpfreaks.com/topic/104177-need-help-with-simple-ffmpeg-class/#findComment-533323 Share on other sites More sharing options...
inutero Posted May 5, 2008 Author Share Posted May 5, 2008 It doesn't work but thanks anyway, I'll ask in the O.O.P board. Link to comment https://forums.phpfreaks.com/topic/104177-need-help-with-simple-ffmpeg-class/#findComment-533327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.