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

Increase quailty of Video encode


Go to End


6 Posts   1893 Views

Avatar
Howard

Community Member, 215 Posts

27 July 2009 at 9:35am

Edited: 27/07/2009 9:39am

Hi UncleCheese,

I've got video working perfectly along with ffmpeg but the quality of the video on the flv encode is a bit low for our use. Is there a way to up the bitrate of the transcode into flv, I saw variables for audio but not the video.

Thanks,
Howard

Avatar
Howard

Community Member, 215 Posts

27 July 2009 at 1:36pm

I've had a go at implementing it, to FLV.php I added

public static $video_bit_rate = 4000; // high for testing purposes

then changed the createFLV function to

	private function createFLV()
	{
		$args = sprintf("-i %s -ar %d -ab %d -b %d -f flv %s",
			$this->absoluteRawVideoLink(),
			self::$audio_sampling_rate,
			self::$audio_bit_rate,
			self::$video_bit_rate,
			$this->absoluteFLVPath()
		);
		
		$output = self::ffmpeg($args);	
	}

But this doesn't increase the quality or the generated filesize...

Any ideas?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 July 2009 at 2:05pm

Thanks for looking into this. The FLV features of DOM are in a very nascent state and I right now my focus is just to get it working reliably on several different installs and hopefully make its way into some production sites. It seems to be doing well so far.

I will definitely be adding a lot more features to it as I learn more about FFMPEG. There are hundreds of flags you can throw at the video conversion, including one for quality, that takes a value of 0 to 30. You might want to read the docs on that on the ffmpeg website. Hack the core code and see if it makes a difference for you and get back to me on what you find. If it looks good, I'll have you revert your changes and check it in to the svn channel.

Avatar
Howard

Community Member, 215 Posts

27 July 2009 at 5:46pm

Hi again,

Yea I couldn't see the single 0-30 quality setting in the ffmpeg documentation but I have achieved what I wanted by using -sameq which sets it to the same quality as the upload, I will tinker with it a bit more down the line. The changes I have made are the addition of the following to FLV.php I figured I would set it up so that I could pass any arguments I liked into the encode so that it would be easy to use the heaps of different encoding options.

	public static $extra_flv_commands;

	private function createFLV()
	{
		$args = sprintf("-i %s -ar %d -ab %d %s -f flv %s",
			$this->absoluteRawVideoLink(),
			self::$audio_sampling_rate,
			self::$audio_bit_rate,
			self::$extra_flv_commands,
			$this->absoluteFLVPath()
		);
		
		$output = self::ffmpeg($args);	
	}

	static function set_var($var, $value)
	{
		if(property_exists('FLV', $var))
			self::$$var = $value;
	}

And then obviously in _config.php I included:
FLV::set_var('extra_flv_commands','-sameq');

What do you think about setting it up like this?

(Also I've got a little bug but ill post it in the other thread)

Avatar
house98

Community Member, 31 Posts

10 January 2010 at 5:34am

Hey Howard.

Thanks for this tip. Works great! :)

Avatar
Rishi

Community Member, 97 Posts

26 January 2010 at 8:26am

hello howardgrigg
i am trying to make a video gallery,my ffmpeg is working fine and even its creating thumbnail and convertiing video into flv but nothing is showing up on the page..
can you help me with your code where you have made video working fine,it willb e a great help.
thank you in advance