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


Go to End


28 Posts   4639 Views

Avatar
dacar

Community Member, 173 Posts

20 October 2010 at 3:20am

Edited: 20/10/2010 3:22am

Hi Uncle Cheese,

here is the code. btw images, mp3 and flv are uploaded correctly. mpeg is saved as FILE to db.

PageRessource.php:

<?php
class PageResource extends DataObject
{
	static $db = array (
		'Name' => 'Text',
		'Beschreibung' => 'Text'
	);
 
	static $has_one = array (
		'Attachment' => 'File',       //@UncleCheese: could this be the problem?
		'Page' => 'Page'
	);
 
	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			new TextField('Name'),
			new TextareaField('Beschreibung'),
			new FileIFrameField('Attachment')
		);
	}
}
?>

Page.php

<?php
class Page extends SiteTree {

	public static $db = array(
		'RedirectToChild' 		=> 'Int',
		'Headline' 				=> 'Text',
		'Copytext' 				=> 'HTMLText',
		'BannerLinkExtern' 		=> 'Text',
		'BannerLinkInternID' 	=> 'Text',
		'BannerEinblenden' 		=> 'Boolean',
		'BannerText' 			=> 'Text',
		'KopfbildAufStartseite' => 'Boolean',
		'SliderCopytext' 		=> 'Text'
	);

	public static $has_one = array(
		'MoodImage' => 'Page_MoodImage',
		'BannerImage' => 'Page_BannerImage',
		'BannerLinkIntern' => 'SiteTree'
	);
	
	static $has_many = array (
		'PageResources' => 'PageResource'
	);
	
	function getCMSFields() {
	$array = array(
		'1' => 'Hauptnavigationspunkt anzeigen',
		'2' => 'Direkt 1. Navigationspunkt der 2. Ebene anzeigen',
		'3' => 'Direkt 1. Navigationspunkt der 3. Ebene anzeigen'
	);
	
	
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Content.Main', new DropdownField(
			'RedirectToChild',
			'Content zeigen aus',
			$array));
		// Kopfbild
		$fields->addFieldToTab('Root.Content.Kopfbild', new CheckboxField('KopfbildAufStartseite', 'Bild im Slider auf der Startseite anzeigen?'));
		$fields->addFieldToTab('Root.Content.Kopfbild', new TextareaField('SliderCopytext', 'Text f&uuml;r Slider:'));
		$fields->addFieldToTab("Root.Content.Kopfbild", new ImageField(
			"MoodImage", 
			"Bitte w&auml;hlen Sie ein Kopfbild (491*267)", 
			null, 
			null, 
			null, 
			"Kopfbilder/"
			)
		);
		// Banner
		$fields->addFieldToTab('Root.Content.Bannerbild', new ImageField(
			'BannerImage',
			'Bitte w&auml;hlen Sie ein Bild (260*120)',
			null,
			null,
			null,
			'Bannerbilder/'
			)
		);
		$fields->addFieldToTab('Root.Content.Banner', new TextField('Headline'));
		$fields->addFieldToTab('Root.Content.Banner', new TextareaField('Copytext'));
		// TreeDropdownField: $name, $title, $sourceObject, $keyField, $labelField, $showSearch
		
		$verlinkung = new TreeDropdownField('BannerLinkInternID', 'Bitte eine interne Verlinkung w&auml;hlen', 'SiteTree', 'ID', 'Title', true);
		// $verlinkung->objectForKey('ID');
		// $verlinkung->objectForKey($BannerLinkInternID);
		$fields->addFieldToTab('Root.Content.Banner', $verlinkung);
		
		$fields->addFieldToTab('Root.Content.Banner', new TextField('BannerLinkExtern'));
		$fields->addFieldToTab('Root.Content.Banner', new CheckboxField('BannerEinblenden'));

		$manager = new FileDataObjectManager(
			$this, // Controller
			'PageResources', // Source name
			'PageResource', // Source class
			'Attachment', // File name on DataObject
			array(
				'Name' => 'Name', 
				'Beschreibung' => 'Beschreibung', 
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause
			// Sort clause
			// Join clause
		);
        $fields->addFieldToTab("Root.Content.Dateien",$manager);
		
		return $fields;
	}

}

Thanks for your time, Carsten.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 October 2010 at 8:28am

I've tried this a number of different ways, but I can't seem to replicate the problem you're having. Here's the code I'm using:

FileDOMTestPage.php

<?php

class FileDOMTestPage extends Page {

	static $has_many = array (
		'Resources' => 'Resource'
	);
	
	public function getCMSFields() {
		$f = parent::getCMSFields();
		$f->addFieldToTab("Root.Content.Resources", new FileDataObjectManager(
			$this
		));
		return $f;
	}
}

class FileDOMTestPage_Controller extends Page_Controller {}

Resource.php

<?php

class Resource extends DataObject {

	static $db = array (
		'Title' => 'Varchar',
		'Description' => 'Text'
	);
	
	static $has_one = array (
		'Attachment' => 'FLV',
		'FileDOMTestPage' => 'FileDOMTestPage'
	);
	
	public function getCMSFields() {
		return new FieldSet (
			new TextField('Title'),
			new TextareaField('Description'),
			new FileUploadField('Attachment')
		);
	}

}

The file gets uploaded, thumbnailed, encoded, and saved with the "FLV" class. You can test it on the demo site..

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
GRiiDWeb

Community Member, 60 Posts

25 November 2010 at 10:59pm

Hi Uncle Cheese,
I've emailed you previously and you have always managed to help.
I have a similar situation that videos are not converted to FLV, I don't think it's ever worked.
ffMpeg is installed and working on the server. I have the DOM, swfupload and image gallery installed unchanged from your originals and I've added -
; Maximum size of POST data that PHP will accept.
post_max_size = 99M

; Maximum allowed size for uploaded files.
upload_max_filesize = 99M

for the file sizes. Generally I have small 5 meg videos, usually avi and they never convert to FLV.
Are there some additional settings which can be changed to get the conversion or can I add other files types to the DOM (however, would they play in JW Player?)

Many thanks
P.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

26 November 2010 at 4:33am

Check the log in /dataobject_manager/code/flv/ffmpeg_log.txt. It should be logging all of the FFMPEG commands. Run a few at the command line and you can see if there are any errors.

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
GRiiDWeb

Community Member, 60 Posts

26 November 2010 at 6:43am

Hi,
This is what the log says -

[2010-11-25 09:47:41] ffmpeg -i /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.AVI -ar 22050 -ab 32 -f flv /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.flv
[2010-11-25 09:47:41] sh: ffmpeg: command not found

[2010-11-25 09:47:41] ffmpeg -y -i /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.flv -an -s 640x480 -ss 10 -an -r 1 -vframes 1 -y -vcodec mjpeg -f mjpeg /home/griided/public_html/assets/video_thumbnails/erin-at-the-fridge2.jpg
[2010-11-25 09:47:41] sh: ffmpeg: command not found

[2010-11-25 09:47:41] ffmpeg -i /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.AVI -ar 22050 -ab 32 -f flv /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.flv
[2010-11-25 09:47:41] sh: ffmpeg: command not found

[2010-11-25 09:47:41] ffmpeg -y -i /home/griided/public_html/assets/Uploads/Erin-at-the-fridge2.flv -an -s 640x480 -ss 10 -an -r 1 -vframes 1 -y -vcodec mjpeg -f mjpeg /home/griided/public_html/assets/video_thumbnails/erin-at-the-fridge2.jpg
[2010-11-25 09:47:41] sh: ffmpeg: command not found

[2010-11-25 09:52:31] ffmpeg
[2010-11-25 09:52:31] sh: ffmpeg: command not found

Is there something the server provider needs to do?

Thanks again
P

Avatar
GRiiDWeb

Community Member, 60 Posts

26 November 2010 at 7:28am

Hang on!
I've just run the test again and it says ffMpeg is not installed, but it was there yesterday.

Sorry to be messing you around, I have emailed my service provider to see what the heck is going on.

P.

Avatar
GRiiDWeb

Community Member, 60 Posts

26 November 2010 at 8:35am

Hi,
Ok, they have sorted the php.ini folder and confirmed ffMpeg installed ok, however, it still doesn't work. I'm still getting the 'command not found' in the log.
Any ideas will be gratefully received.

Many thanks

P.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

26 November 2010 at 8:46am

If you're getting command not found, then it isn't installed. You shouldn't have to do anything in your php.ini. FFMPEG is a package you install on a Linux server.

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com