Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

FFMPEG and FLVTool2 Tip.


Go to End


7 Posts   3901 Views

Avatar
vstrazz

Community Member, 63 Posts

16 October 2009 at 4:03am

I don't know how many people are actually using DOM for High Quality video conversion. Well I had some trouble getting my videos to a very high quality and getting the progress bar to work.

After installing FFMPEG I found that uploading any files other than FLV's the progress bar didn't work. FLVTOOL2 fixes this by inserting Metadata into your newly created flv.

on Cent OS yum install flvtool2, will take care of that.

Here is the code I now use.

in FLV.PHP search for createFLV()

    private function createFLV()
    {
        $args = sprintf("-i %s -ar %d -ab %d -s 640x480 -r 30fps -b 3000kbps -g 100 -f flv - | flvtool2 -U stdin %s",
            $this->absoluteRawVideoLink(),
            self::$audio_sampling_rate,
            self::$audio_bit_rate,
            $this->absoluteFLVPath()
        );
        
        $output = self::ffmpeg($args);    

This is the bulk of the FFMPEG command

$args = sprintf("-i %s -ar %d -ab %d -s 640x480 -r 30fps -b 3000kbps -g 100 -f flv - | flvtool2 -U stdin %s",

This also generates the progressive download, like youtube. I hope this saves someone some time.

Note this generates very high quality FLV's. The final size of the FLV will be just as large, if not larger than the original uploaded.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 October 2009 at 6:18am

Yeah, I've been meaning to play around with FLVTool. Not everyone has it, so it would involve another checkpoint to build the ffmpeg command based on whether or not flvtool is installed, but that's good to know it's producing higher quality video for you. I'm not sure what you mean about the progress bar, though. I've always gotten that with no problem.

I anxiously await the day when I'll be able to overhaul all these media features -- mostly to decouple them from the DOM so I can make a more robust management interface.

Avatar
vstrazz

Community Member, 63 Posts

16 October 2009 at 7:52am

Edited: 16/10/2009 7:55am

I'm not sure what was up with the progress bar, it may have had something to do with the FFMPEG command I was running.

I know for fact that FLVTOOL2 fixed it. The higher quality also comes from the different arguments I supplied to the ffmpeg command.

That is one powerful piece of code right there. I can't wait for you to make a more powerful management interface as well :p. If it's better than DOM I will be super stoked that's for sure.

EDIT://

This is something else I added to the Player(). Since the player would show a black background instead of a thumbnail. I changed that :)


    public function playerThumb($width, $height){
        $img = $this->getThumbnail()->CroppedImage($width, $height)->Link();
        return Director::absoluteURL($img);
    } 
    
    public function Player($width = null, $height = null)
    {    
        if($width === null) $width = self::$video_width;
        if($height === null) $height = self::$video_height;
        
        self::$player_count++;
        Requirements::javascript('dataobject_manager/code/flv/swfobject.js');
        Requirements::customScript(sprintf(
                "swfobject.embedSWF('%s','player-%s','%d','%d','9.0.0','expressInstall.swf',{file : '%s', image : '%s'},{allowscriptaccess : 'true', allowfullscreen : '%s'})",
                $this->SWFLink(),
                self::$player_count,
                $width,
                $height,
                $this->FLVLink(),
                $this->playerThumb($width, $height),
                $this->AllowFullScreen()
                
            )
        );
        return "<div id='player-".self::$player_count."'>Loading...</div>";
    }

I couldn't use VideoPopup() because I happen to have mootools on another item on that page, and mootool + jquery = Fail.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 October 2009 at 8:18am

Yeah, the whole video endeavor has been way more successful and popular than I anticipated. I really believed that the FFMPEG requirement would be enough to turn people away. Not many users know how to do that level of sysadmin to install FFMPEG. Then, I figured, even if everyone has it, what are the chances the same shell exec code is going to work on everyone's machine? Surprisingly, it's been more compatible than SWFUpload in that regard.

Yeah, there's a lot more we can do. Thumbnail selection, player selection, more control over conversion parameters (as you point out). It's tough to store those as static vars. Everyone wants something different. I also need to get away from JWPlayer. They started charging for commercial use.

MooTools and jQuery should get along fine. I believe I have all the $() references in a closure. But I guess I've never tried it.

Avatar
vstrazz

Community Member, 63 Posts

16 October 2009 at 9:27am

I've always had issues with MooTools & JQuery on the same page. Probably something I'm doing. FFMPEG is almost a must on any server these days.

That sucks about JWPlayer, but Flowplayer is nice. They are probably charging for Commercial use as well though.

Surprisingly, it's been more compatible than SWFUpload in that regard. 

LOL @ that comment.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 October 2009 at 9:46am

I just launched a site that uses ToobPlayer instead of JW. Works well, looks good, and it's free!

Ultimately, I'd like the video features to be more like ImageGallery, where users can create and supply their own UI plugins.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

6 November 2009 at 3:50am

This is awesome stuff. I'll definitely be implementing this. Thanks, vstrazz.