Drupal Video Conversion (in detail)
Its possible to post video from mobile phone to drupal website. Below is short tutorial, with will let you get started. The document have been put together as part of Drupal Video documentation efford at the Drupal transmission sprint.
New version of this document is published also at [drupal.org tutorials section]
- Email sent to mailbox
- Mail downloaded on cron (mailhandler module)
- emails are turned into nodes with videos as attachments
- MediaMover runs on cron, transcoding mobile video formats and creating thumbnails
- Transcoded flash video files are added to cck file field
- Thumbnail added to file field
- Nodes are themed using swftools to display video using "JWplayer"
- configure flash video playing with swftools
- download the swfobject code
- download player code (JWplayer)
- Set up your swf file handling to use the player
- add a custom skin for the player if you want to - download from JWplayer site
- Define a node type that will be used to "host" your video data. Call it for example "video" type
- Add a cck field for storing your flash video
- Set display settings to use video player
- Add a cck file field for thumbnail
- At time of writing Imagefield is not properly released for D6, so Media Mover is unable to add filed to image fields properly. This will mean that image thumbnails will need to be manually themed for now.
- Assign permissions to allow anonymous users to create and view this node type (but not edit it)
- if users are already members, and they email in from their registration address, video will be owned by them, so then they will be able to add metadata.
- Allow attachments for this node type
Transcoding with ffmpeg
To convert video from attachments into flv format you will need 2 pices: ffmpeg binary installed on server where your drupal is installed and ffmpeg wrapper module (covered below).Ffmpeg is a standard open source package for multimedia handling available on many distributions so ask your host if you dont have it. Note it might be very tricky to make it running:
- Standard debian package is striped from proprietary formats so you will not be able to transcode from/to avi, mp4, rm flv or mp3 but developer of Media mover is providing static binary. You still need vhooks libs installed (part of ffmpeg) on system.
- Usually shared hosts don`t let your php to run shell commands, if you run into passthru limit or php error 127, it means you are in shell jail. Explain to your host what you are going to do, if it not helps, change your host.
- If test transcode is not running, tray "flush all caches" from admin menu. Its strange behavior , but it helped us.
To transcode in drupal you need to install ffmpeg wraper module and test it via settings in admin menu. Best way to test is to trans code small video file with common extension like 3gp or avi and media encoded with popular codec. Extension of the test file have to match one from list available formats of ffmpeg, other wise your test will fail (it might happend for example with .mpg files).
Media mover does the video conversion in a set of stages. Each stage processes new nodes with video attachments. (These nodes will have been created by Mailhandler from email set to the video inbox.)
Media mover rules should be weighted so that they run in order. This will allow nodes to be made public only when all content has been processed.
Pass 1: convert video to standard format
Set up a media mover rule to do the following:
- harvest nodes with attachments
- attachments should have allowed video extensions
- exactly which extensions are possible will depend on your ffmpeg setup
- attachments should have allowed video extensions
- Process your incoming attachments to transcode video to flv
- store transcoded video in a cck file field on the original node
Pass 2: Create a thumbnail
- harvest nodes with video attachments - exactly as above
- process your video to create thumbnails
- store the thumbnail in a file field
- we had trouble adding to an image field !!! (current problem)
- Complete your processing by publishing your node and promoting to front page if you want
Download and install mailhandler and mailsave modules
Set up mail box
Set up a new mailbox in admin/content/mailhandler page
More info [here http://drupal.org/node/39172]
Run through of first lines we set
E-mail address: email@example.com Folder:INBOX POP3 or IMAP: POP3 Mailbox domain: mail.anarchotv.org Mailbox password: p455w0rd Security: Disabled Send error replies: Disabled
There is an area in the mailbox entitled "Default Commands" which is IMPORTANT towards assigning where you want your mail to go and adjust other default settings that aren't sent in emails but are standard on drupal nodes
Our settings are below
type: video promote: 1 comments: 1 published: 1
For more info on these settings see this page
Another couples of options to note below for the test site we set as
Delete messages after they are processed? Deselected Cron processing: Disabled
However in a production site you will want to set these as
Delete messages after they are processed? Selected Cron processing: Enabled
Now this is set up the mailhandler should be able to recieve emails from your admin user and create nodes from them
In order to make sure your email attachments are stored on the site and attached to a node (and adjust settings for this) and set who can email files to your site see the next couple of entries
File Upload settings
Set upload settings, so that every user posting via mail (usually anonymous) will be able to publish video type:
- upload file size
- upload file extensions (jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp avi mov wmv mpeg mp4 mpeg2 dv 3gp 3g2 mpeg4 flv mpg)
Note: media mover is using the upload module to insert transcoded files into cck filed: remember to allow proper size and extension (flv).
The mailhandler module uses the email address that the message is sent from to determine which user the message is coming from. If this email address does not match the email address of a user on your website then the message will be assigned as being from an anonymous user
Thus we can use the Drupal Core permission roles to determine who can send emails, attachments etc. to the website.
For our site we wanted anonymous users to be able to send in emails with attachments so in admin/user/permissions we selected the following options for anonymous users
- access content
- save attachments
- create video content
- upload files
- view uploaded files
Media Mover Documentation
Media Mover API documentation http://drupal.org/node/276134
Requests for Media Mover documentation http://groups.drupal.org/node/19188