Posting video from mobile phones to drupal website is reasonable easy and there are few methods of doing it. Below we cover the "independent" path, to avoid any proprietary mms gateways: just simple email with attachment.

Introduction

Posting video from mobile phone to your drupal website via email requests from user to configure a mobile phone with smtp settings and reasonable Internet connection (3g). Costs depends from your mobile phone provider: at some networks you pay only for transfer volume, at others you might pay for "event" of establishing connection. Video from mobile phones is usually around 0.5 MB is size, so limit is in size of allowed attachments: on decent phones you cane attach up to 1 MB.

On server side you will probably need to setup smtp server and provide access to it to users of your website. Transcoding of posted video employs ffmpeg, its standard software on proper hosting server.

Process Overview

  1. Email with video attachment from mobile phone is sent to a defined mailbox
  2. Drupal website downloads Mail on cron (mailhandler module)
  3. Emails are turned into nodes with videos as attachments
  4. Media Mover runs on cron, trans-coding mobile video formats and creating thumbnails
  5. Transcoded flash video files are added to cck file field
  6. Thumbnail added to file field
  7. Nodes are themed using swftools to display video using "JWplayer"

Modules used

  • Mailhandler
  • Mailssave
  • Mediamover
  • SWFTools
  • FFMPEG_wrapper
  • cck
  • filefield
  • imagefield

Implementation

Node Setup

  1. Define a node type that will be used to "host" your video data. Call it for example "video" type
  2. Add a cck field for storing your flash video
  3. Set display settings to use video player
  4. Add a cck file field for thumbnail
  5. 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.
  6. Assign permissions to allow anonymous users to create and view this node type (but not edit it)
  7. 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.
  8. Allow attachments for this node type

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).

Mailhandler

Download and install mailhandler and mailsave modules. (There is mail module for media mover but it makes media mover process too complex). However, you can use Media Mover's implementation of Mail Handler to keep everything inside of Media Mover.

Set up mail box

Set up a new mailbox in admin/content/mailhandler page

E-mail address: mobile@example.org
Folder:INBOX
POP3 or IMAP: POP3
Mailbox domain: mail.example.org
Mailbox password: xxxx
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.

Working settings are below, tune it for your website:

type: video
promote: 1
comments: 1
published: 1

For more info on these settings see this page

Another couples of options to note below:

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 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, adjust settings for this and set who can email files to your site (see the next couple of entries).

Permission settings

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

mailsave module
* access content
* save attachments

node module
* create video content

upload module
* upload files
* view uploaded files

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 [http://mediamover.24b6.net/content/ffmpeg-binary 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, try "flush all caches" from [http://drupal.org/project/admin_menu admin menu]. Its strange behavior , but it helped us.

To transcode in drupal you need to install [http://drupal.org/project/ffmpeg_wrapper 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).

MediaMover

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
  • 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 image field
  • Complete your processing by publishing your node and promoting to front page if you want

SWFTOOLS setup

  1. configure flash video playing with swftools
  2. download the swfobject code
  3. download player code (JWplayer)
  4. Set up your swf file handling to use the player
  5. add a custom skin for the player if you want to - download from JWplayer site

Final notes

Security

Providing post-in gateway to your website might lead to security or spam issue. When you provide public smtp server to your users its god idea to limit allowed destination email addresses to only one, witch your drupal website checks.

Credits

The document have been put together as part of Transmission Network`s Drupal Video documentation effort at the Drupal Transmission Sprint 2009 uk

In creation of this tutorial have been involved the greenman, benced, szczym, Mick Fuzz and others.

Comments

leenyx’s picture

I am completely lost at:

Define a node type that will be used to "host" your video data. Call it for example "video" type // Ok...
Add a cck field for storing your flash video // which type of field, I can't find a flash video field???????
Set display settings to use video player // Where are these settings? how do I can only see lightbox settings and my imagecache presets.

Please can you be more precise in such an important part of the tutorial as the start.

gabash’s picture

Great tutorial, I am actually building a site with such schema.

What i didn't understand is how do you pass the thumbnail field to JWplayer as an "image:" flashvar.
What i do is store the thumbs with the encoded flv on the same cck field and use JWplayer to play them as a mixed media list.

bryanb229’s picture

Thanks so much for writing this out!

Anonymous’s picture

thanks for writing this intro...sounds great

but how is it possible to assign a nodetitel for the uploaded video by the user who's sending his videofile via mobilephones?

and how is it possible to assign the created node to his user?

konsul

j9’s picture

With 6.16 I see three incompatible modules:

Mailsave to audio - beta
Mailsave to CCK Imagefield
Mailsave to image attach

On module page, it says:

This version is incompatible with the 6.16 version of Drupal core.

Does anyone know if there is a way to make it work in 6.x or if 5.x works fully? thanks!

bonobo’s picture

We recently wrote some code that simplifies this, and makes it possible to set this up without Media Mover and Mailsave (although the MM functionality is very nice, and is necessary in some use cases).

The code is here on d.o: http://drupal.org/project/mimerouter

We also have a screencast on it at http://funnymonkey.com/mailhandler-and-mimerouter

If there's interest, we can either update this page, or add in a new page in this same section.

glitz’s picture

hello. im looking for a way to do this. Do you have an updated tutorial for posting videos and pictures via email using your methods?

thanks
chris