Alan Evans and I are happy to present the media.module for Drupal 4.6. Developed to address the need for better support of audio and video file handling, it has the following features:

  • uses getId3 [1] to read and store the metadata from any audio or video file that is uploaded to a Drupal site via the upload.module
  • presents the metadata from all audio and video files in a sortable table
  • supports downloading and streaming of media
  • introduces a new node type, the media-playlist

Media-playlist nodes are a list of media files that can all be streamed to the client in order. Users can create playlists from existing media files either by creating a media-playlist node and adding media files to it, or by creating a session playlist which only persists as long as the user is logged in. Session playlists can be converted to real nodes at any time.

The code for this module, while functional, is still in an early stage of development and is only tested to work with the current CVS version of Drupal (upcoming 4.6 release). It is therefore only to be found in my sandbox (sandbox/robertdouglass/media), and is not yet released as a module. Feel free to download the code and test it. Documentation will be provided in time.

There is a test site which you may want to visit and try all the features out. Use your Drupal id to log in and you can upload media files and create playlists. There is also a discussion forum where you are encouraged to report problems and make suggestions.

http://testit.webs4.com

[1] http://www.getid3.org/

Comments

gerbrand’s picture

hi robert and alan,

this is great news.
testit.web4s.com doesn't work. this should be http://tryit.webs4.com/.
i will be monitoring the development of this module closely. i'll even consider upgrading drupal from 4.5.2 to cvs to try and test it.

i would be very interested in the following features explicitly:

  • generating and RSS/RDF output with the latest mediafiles, for syndication to other sites and podcasting
  • integration of a 'live' media type, with starting and ending time, and an announcement of upcoming live events
  • having various formats of media (eg an ogg and mp3, or a fullsize theora and low-quality realmedia video) version of the same song/event smartly integrated
  • feature to upload/generate/display an (animated gif) image of the video
  • bittorrent integration to facilitate downloading of large files

thanks!
gerbrand (coming to FOSDEM next week)

robertDouglass’s picture

Try it, test it - you get the idea :-)

The RSS feed is on the list, as are blocks of media files and playlists. The other points you mentioned are certainly interesting and worth programming, but fall outside of the scope of a metadata-manager like the media module.

Are you going to be in Antwerp too? Alan and I will be there taking part in the cell discussions.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

gerbrand’s picture

Hi Alan and Robert,

yes I will certainly try to make it to Antwerp, at least for the media handling gathering.

Great that RSS is already on the list!

What it takes for Drupal to serve streaming media, apart from MP3/OGG?
Well, there is a lot to say about that. Basically, for both Realserver/HelixServer and Darwin (Quicktime) Streaming Server integration with Drupal, it would take dynamically generated URLs and/or metafiles based on templates. Just as m3u is a metafile for mp3, there are metafiles required for quicktime, mpeg4 and real streams. An important choise is always whether the video should be opened in the standard player, or in a popup-window (more control for website owner, with potentially extra information, links, etc.)

of course, we should pay great attention to ogg-theora, the open source video codec that seems to have the same momentum as drupal currently.

It would be very important to be able to display and cleverly use metadata. For video a thumbnail image would be great. It would also be great to be able to send synchronised metadata events (such as subtitling, related URLs, etc.). As you say, this might be outside the scope for the current project.

Anyway, I hope to see you all in Brussels and/or Antwerp.

Gerbrand

bertboerland’s picture

Nice, I just bought a squeezebox (cheesy: wifi to your hifi) and hope that your module will integrate with that as well.--
groets
bertb

--
groets
bert boerland

kbahey’s picture

Kudos to Alan and Robert for this creative use of Drupal.

I have one question: I understand the download part. That is straightforward. My question is about the streaming part: what do you mean by streaming here? Does Drupal have a background process that serves the content to the client gradually? I don't think this is the case, because it can tie up resources very quickly on the server.

Some clarification appreciated.

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

robertDouglass’s picture

We generate an m3u file and serve that. Then the media player on the client does several things; it starts downloading the first item in the m3u list and makes a note of both the bitrate of the file and the speed of the connection. It uses that info to decide how long to buffer before it can safely start playing. In the end, this is no way to secure media files so that they can never be saved on the client, but it would factually mean so for 80% to 90% of users. In any case, it is much nicer to click on an mp3 link and have it start playing within seconds to a minute, instead of 3-4 minutes later when the whole file is downloaded.

I'm hoping people will make suggestions for other types of presentation so that perhaps Drupal could be used for sites where protecting the media is important. Can a Flash movie stream media in a way that can't be downloaded? Realplayer? What does Drupal need to be a media server? What's missing?

Those are the questions that will guide implementation of features for the media module.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

freyquency’s picture

i could kiss you. smootch.

[]+][+][+[]
erik mallinson
http://coacalina.org

robertDouglass’s picture

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

kbahey’s picture

chromatic: i could kiss you. smootch.

robertDouglass: I'd rather you install and test the code (wiping his cheek from the drool in disgust!)

:-)

Sorry guys! Couldn't resist that mental image!

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

tvst’s picture

i haven't looked at the code yet, so i don't know it's doable — but here's something that might be of use: a flash mp3 player i made. if anyone wants to integrate it to the module, be my guest :)

flash source is included.

robertDouglass’s picture

Three of the TODOs are showstoppers (volume control, playlists, only mp3).

Maybe you could talk to me a little bit about the capabilites/limitations of Flash? What file types can Flash handle? How much work (in your hours) do you think it would be to add these features? Webs4.com is sponsoring development on this module so there might be some budget to get these things done.

Thanks for sharing this!

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

tvst’s picture

i believe flash can only play mp3s (for sound) and sorenson (video), but don't quote me on that. i'm actually new to flash and that was my first program. also, i have a version on my hard-drive that has a volume control. i'm working on the playlist abilities too, but i was trying to do that with javascript/flash integration, so that files could be added to the playlist on-the-fly.

i'll keep you posted.

carlmcdade’s picture

The best way to do play lists on the fly is with XML. I will check with the Flash team and MM on the other items and post back.
---------------------------
www.hivemindz.com (running PHP5)
www.fireorb.org (documentation and hacks)
__________________________
Carl McDade
Information Technology Consult
Team Macromedia

tvst’s picture

yes, i guess xml would be the best approach for drupal. the reason i was looking into the javascript solution was because i was initially developing the mp3 player for people who don't have access to server-side scripting.

but i guess i could implement both solutions :)

robertDouglass’s picture

In terms of flash, communicating with it is usually a matter of using flashvars. Those are just like named parameters. Flash is capable of parsing XML, but that seems over the top to me.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

joshk’s picture

Check it out: XML playlists in action. Click "stream artist" to get it. To see one of the XML files: click here.

These are made to work with the non-Free wimpyplayer, which was a cheap solution 18 months ago when I was building the site. I found that having cron spit out text files for all the streaming music was easier than getting flash to correctly parse stuff from getvars.

The module that powers all this is a monument to custom hackishness, but it also has a couple cool features:

1) It can mark content to be "streaming only" for artists who don't want to let people (easily) download their music.

2) It works with a perl script (also non-free) which automatically downcodes a high quality file for hi and low bandwith streaming (128kbps stereo and 32kbps mono).

Anyway, I'll be looking at this module for a major overhaul of Music For America in the coming months. Great work!

------
Personal: Outlandish Josh
Professional: Pantheon

robertDouglass’s picture

Thanks for introducing me to this. I'll add it to the requested features.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

joshk’s picture

The recoding element will take some time because I do not believe there's a PHP interface to the LAME library, which kind of makes it tricky. Drop me a line if you want to see my code or anything.

------
Personal: Outlandish Josh
Professional: Pantheon

zirafa’s picture

It's really easy to parse any XML file using the XMLComponent in flash - and by using XML feeds then you have the ability to play XML Playlists which might be hosted on another site, if everyone uses the same standard. I parsed an XML playlist in flash, and I think it was much easier than using php to load variables into flash or to use a query command. Here is the XML file which loads into this (free) player.

I posted more about this below this thread.

robertDouglass’s picture

I've got a lot of homework to do on this :-)

Thanks for all the suggestions!

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

Bèr Kessels’s picture

Foing is a portal tool i have been playing with. It requires

[Ber | Drupal Services webschuur.com]

media girl’s picture

Some clarification of terms that might help the discussion:

* streaming technically is actual buffered streaming managed actively from the server. It allows the viewer to scrub ahead to the middle of a longer program, and after a moment of buffering, start playing from right there. No real download takes place. This is more bandwidth intensive as a result but offers more user friendliness for longer programs. With shared hosting plans, especially, support may be lacking, or cost extra.
* progressive download does not need special server support, and is encoded directly into the .mov, .swf or other media file format. Depending upon encoding parameters, the file can start playing after a certain amount is downloaded, or a percentage, or a buffer ratio that takes into account the connection speed.
* full download files will not play until they are downloaded to the browser fully.
* security is iffy. The fact is, with hacks or many professional software packages you can download and save media files. With some you can even crack them open and hack around, though Macromedia and Apple are always working to prevent that.

I'm delighted to learn of this module, and wonder what kind of additional features over a normal node it might offer. I use quite a bit of Flash-encoded video and Quicktime so this one is of great interest to me.

--
mediagirl.org

kbahey’s picture

That is why I asked for the clarification above. Real streaming is very resource intensive on the server, since the server maintains a connection with each client that is viewing/listening to the content for the duration of the connection, which means memory and networking resources are tied. Only so many concurrent connections can be served by a server with a given configuration, and companies who do a large amount of streaming need to have massive server farms to do so.

This does not belittle the work that Rob and Alan have done in anyway, just a clarification on terminology.

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

robertDouglass’s picture

I went into this not knowing very much beyond what my immediate needs were. That's why I wanted to get the module out in the open so that people who have more specialized knowledge in the area can start testing it and offering advice.

As you can see from my description, the module enables progressive downloading, not streaming. I'll update the terminology elsehwere as well.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

zirafa’s picture

I'm so glad you took the time to develop this module. This is one of the most useful things I've seen for drupal to date. I'd also be interested in working with you on developing a Flash media player for it. Currently, I've developed a flash player that loads an mp3 list as an RSS feed and plays it dynamically. You can check it out here:

https://netfiles.uiuc.edu/dfinnert/shared/simpleplayer.swf

The advantage to using flash for streaming is that it protects the file locations pretty well, I think. We could also have it so it could dynamically load a picture icon, info about the artist, song, and link to purchasing info, etc. through RSS/XML file using custom tags. I actually developed this flash player with drupal integration in mind, but am relatively new to Drupal so wasn't sure how to integrate it. But now that you've developed this, the goal is that much closer! Please contact me about integration as I'm extremely interested, and I don't think it would require too much effort to get it working with your module.

-Farsheed

zirafa’s picture

p.s:
this is actually a simplified version of the player. other versions I have done have had the following features:

+loads in RSS playlist
+cross domain RSS feeds allowed through php script (necessary due to flash security issue)
+volume control
+reads ID3 tag info for each song
+scrubber allows user to jump to middle of track
+email the playlist to a friend
+current time/total time
+percentage loaded
+plays tracks one after the other automatically
+scalable size (standard flash feature)

I took most of the features out because it was too buggy and I wanted something a little more rock solid. Currently it only works with mp3 files, but I will look into other file formats and video formats. If anybody else would like to use this flash code, let me know too. Keep up the good work!

-Farsheed

bertboerland’s picture

Excellen module (btw: http://drupal.org/node/14784#comment-24090)
--
groets
bertb

--
groets
bert boerland

robertDouglass’s picture

It could become, after all, a killer-app, just like you say.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

larry’s picture

First, robertDouglas and Alan Evans...thank you. I am the first to admit that I'm not a programmer and benefit from all the work that others here on Drupal have done, but I do try to help where I can. This module is awesome and I appreciate the effort that went into it. That said, I must ask a somewhat silly question. Suppose I use this module on my website, and everyone goes nuts for it. Is that a blessing or a curse? As I said, I'm not a programmer. I spend my days building volatility models and simulating dynamical systems using mathematics, not code, which in reality has very little difference...except that I speak math fluently, not php. Anyway, back to my question...can I get nailed by some slimy lawyer because my users are swapping shaggi's latest tunes on my site or am I mssing something. This module is VERY powerful, but what if any, are the legal repercussions? I'm just worried that some dirtbag lawyer will try to make a name for themselves at the expense of a Drupal user. Thanks again, you guys rock.

ciao,
larry

--There are no Kangaroos in Austria--

robertDouglass’s picture

Since I'm not a slimy lawyer I can't really answer the question, but the risk you have identified is not tied to this module. Media.module only handles stuff that's already been uploaded via the upload module. I guess you have an interest in preventing your users from uploading copyrighted materials to your site. You can probably protect yourself pretty well by having appropriate disclaimers and terms of use that users have to sign off on, as well as deleting any material that you know to be copyrighted.

Maybe I have to have a word with Alan about Shaggy ;-)

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

Gunnar Langemark@www.langemark.com’s picture

IANAL either
but AFAIK it depends.
There are local differences in legislature regarding sharing of copyrighted material. This means that in some countries it may be illegal to upload copyrighted files, in others it may be illegal to download copyrighted files, and in others it may be illegal to offer these files for download. It may even be illegal for the owner of the machine which is used to host the site, and even the ISP and the Telco may be liable in some way - in some countries. Also in some countries (Germany) if you have a website which is illegal in Germany or contains material which is illegal in Germany (like Nazi propaganda or documents questioning the Holocaust), and this website is accessible from a computer in Germany, you're under German law (regardless of where in the world you live or where the site is hosted), and the German authorities will be able to prosecute you! (No I'm NOT making this up, and YES it may be scaring and it may make you angry. Please air your anger somwhere else).
So it is not so simple, and I would not recommend anybody to embark on any project which is anywhere near copyright law. You may be in for a surprise....

Dropping in from Langemarks Cafe.

sulleleven’s picture

Robert, thanks for you and your team's work on this!
I have been waiting for an update and this made my day.

I read the thread below and to me, the most important request and which is already on your to-do list is automated rss feeds with enclosures.
Also, please look at this for probably the best way to do playlists in sharebale format:
http://xspf.org/
this player exists and uses xspf:
http://musicplayer.sourceforge.net/

I am going to grab the module now and test and might be able to work on some of the new features. If you want to contact me to loop me on dev chatter, please feel free.

Cheers!!

sull

B.X’s picture

The good idea but to use for upload a PHP-script is not correctly. Especially for media and video of files. Why to not use Perl?

bertboerland’s picture

or phyton... C#... basic.. or java? why not redo drupal in java all together?

questions querstions.
--
groets
bertb

--
groets
bert boerland

carlmcdade’s picture

I think I missed something here. But I think that if regular http upload is not appropriate then it would not matter if is written in Perl. What you may want to do though is to use PHPs FTP or Fsock protocols instead. They are easier to work with and have file controls that the http upload doesn't.

---------------------------
www.hivemindz.com (running PHP5)
www.fireorb.org (documentation and hacks)
__________________________
Carl McDade
Information Technology Consult
Team Macromedia

osmif’s picture

Hi Robert,

Great stuff. I thought I would point out that downhill battle has released blogtorrent, which is a php-based client for the torrent, that can be installed on a web server. It's aimed at making large media files (like the ones media.module handles) easier to share through blogs.

Might be a nice addition to / complement for this module.

Thanks for your work.

robertDouglass’s picture

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

sulleleven’s picture

http://www.blogtorrent.com/

btw, i know of a torrent tracker drupal module that should be released in near future.

media girl’s picture

I was just going to post on this. :D
--
mediagirl.org

garm’s picture

decided i had to finaly register and do a post :)

Glad to see a module like this being developed, and im even happier to see that people are already talking about flash support since flash realy is the best choice today for streaming video and audio on the web, including flash support in this module would for sure improve it´s value alot.

As for what flash can stream or progressively load today you can play both video and music and if needed include images and text with the streaming or progressively loaded music.

Im saying both streaming and progressively load because flash can do both, and there are as mentioned earlier in this thread a difference.

Playing videos with the use of flash is the fastest growing online video solution out there today amongst commercial companies since it will let you brand the video players and it´s gui anyway we see fit, which of course is valuable for any enterprise, not to mention that flash embeds flawlessly in any website and it is the most widely used media format today.

You can create flv(flash video files) from quicktime, wmw,avi etc and there are both free tools out there that does it for you and commercial tools from macromedia,swishzone,soorenson and several others, there´s even a macromedia dreamweaver flashvideo kit available for non flash developers/designers, and of course flashmx 2004 can do it aswell as providing you with all you need to customize the look and functinons as you see fit.

As for music you can play music with flv or embed your wave/mp3 files directly in flash(swf) or stream mp3 files as is, however flv realy is the best medium even tho swf and streaming mp3 files works as is.

cheers

sulleleven’s picture

can you grab metadata from flv format?
flv video quality is still not as good as native formats.
to use flv, you need to encode to it... which is an added step, and arguably unnecessary for many uses and users to bother with.
there are other ways to customize/brand a media player...not needing flash.
maybe there are some benefits to it, but regardless, i dont think this media module topic is the correct context for this debate anyways.

Bèr Kessels’s picture

We shouls, at all costs, try to avoid closed formats and promote the open ones. I vote against any depandancy on flash and or commercial trascoders.
We can consider adding this as third party modules, yes. But should avoid at all costs having them in core of media.module.

[Ber | Drupal Services webschuur.com]

garm’s picture

I can respect your opinion on closed formats but displaying media online which is what this module is all about is about user friendliness and flash is just that much smoother for the end user when it comes to playing video/music online, and since websites should be about web standards and a smooth user experience aswell flash is alot more common and widely spread and alot more cross browser/os friendly then the competition and the goal with this module is to play media formats which is where flash excells.

As for the quality, i realy dont see that much of a difference between a wmw or qt or flv file when it comes to quality and filesize and i work with online video on an almost daily basis, lots of differences in favour of flash tho.

and no you dont have to have or use a commercial application to create flv files, there´s several free tools available for that, so yes it´s one more step when creating the file but what you get out of it is alot better experience for the end user when they do watch your video and listen to your music files, and that´s what any website is about.

Just my opinion tho no one here has to agree with me :)

media girl’s picture

And if it's considered inappropriate for it to be part of the core, then it should definitely be offered as a module -- change the name if necessary.

Right now I use file upload and hand code display links for my media sites. It's okay for the occasional portfolio or reel post, but not a preferable solution for any site that uses such media postings on a routine basis.

At least that's how I feel about it.

--
mediagirl.org

iamanush’s picture

how do i download the test code.. thx..im total noobie to drupal

sulleleven’s picture

get a cvs client, and connect to cvs.drupal.org as anonymous... and checkout sandbox/robertdouglass/media

iamanush’s picture

how do i patch the upload.module with the patch from the cvs.. also should i setup another database with the media.module.mysql.sql in my domain apart from the drupal database. thx.

robertDouglass’s picture

Read about patching here: http://drupal.org/node/323

You should not test this on your production database - the code is buggy and unfinished. The database tables for the media module should be added to the same database that has your other drupal tables, but as said above, don't try this on a production site - use a test site.

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

joshk’s picture

Hey Guys,

I think you might want to look at how you're setting up your m3u files in terms of playlists. At the moment what happens when I play a playlist is all the files are added to my music library and they don't play in sequence. I worked on a similar problem a while back and I believe the answer might be in using the extended format. I'll do some research and see what i can find out.

------
Personal: Outlandish Josh
Professional: Pantheon

seaneffel’s picture

I work for a community television station in Cambridge, MA. I'm looking for a way to allow users upload video files (QuickTime or such) and have the movie files appear in a concise list for visitors to select and view. That could be in an RSS output too, then it can syndicate to other sites as well. Be nice if we could moderate the upload and approve/deny at our descretion.

Media.module was supposed to do this? I don't know, but I cannot get the code from anywhere... the webs4.com links provided at the top here have gone dead. Is there another module that can do what I want?

Test site: http://www.cctvcambridge.org

robertDouglass’s picture

http://drupal.org/node/19304

- Robert Douglass

-----
If this helped you, please take the time to rate the value of this post: http://rate.affero.net/robertDouglass/

www.hornroller.com, www.robshouse.net

seaneffel’s picture

It would be ideal to include a pre-patched upload.module file. I just plain do not know how to patch files, and not having access to lots of coder tools, I tried it by hand and blew it. Good thing I backed it up.

I understand the decision to include the patching file, in case I may have already made mods to upload.module, but it would be nice to include the patch file and the patched file for me to choose from.

deliot’s picture

This is a great module. For what it is worth, here are a few important things that I found hard to "get" regarding the module:

(1) The m3u files didn't work correctly for me unless I set Admin --> Settings --> Download Method to PUBLIC while using "clean URLs".

(2) If the files didn't have proper ID3 tags, they didn't show up in the Play List "Media Database". Once I made sure files had proper ID3 tag info, they showed up.

(3) Create the playlist first, then link it to whatever page, blog entry, book, etc.

danielems’s picture

I have several questions:

  1. Can the media module use files uploaded by the attachment module, which uses the filemanager module?
  2. Can the media module use files uploaded by the audio module or the video module?
  3. I have many mp3s that are about 20 MB large. I cannot upload these via the upload module. How can I get the media module to find them?

Disclaimer: I've only played with media.module a little, so my questions are probably uninformed. Please have mercy!

robertDouglass’s picture

Theoretically, since the media module introduces a file_api hook, it should be able to use the attachment module, but you will probably have to study the hook and add its calls to the attachment module.

Audio and video modules came after the media, and since media is unsupported and not being further developed, the hooks for those modules haven't been implemented either, but the principle would be the same... implement the hook.

The media module has no read-from-filesystem import feature.

- Robert Douglass

-----
My Drupal book: Building Online Communities with Drupal, phpBB and WordPress

Veggieryan’s picture

Description

This is crucial.
Look at how the video module allows you to play videos that are hosted elsewhere as if they were on your site...
Tricky and clean.... just paste the url in the node/add/video form....
now I can use youtube.com or ourmedia.org or internetarchive to host my audio and video files...
cha-ching....
whoa...
this is AMAZING..
please allow us to link to mp3's externally.. and then use the playlist module to make our own mixes of stuff on the web!

you da man!
ryan
thefractal.org

------------------------------
Ryan Grace
Webdev&design
Internal Combustion Retrofits
www.realenergy.net
www.veggiecarvan.com
www.puntamona.org
www.thefractal.org

r0g’s picture

A workaround?
Haven't tried the module myself but could you not upload a small mp3 file when you create the node and then replace that file with the full size one via FTP. Not sure if that'd work OK and it's probably not something you'd want to have to do on a regular basis but thought it might be worth a shot.

r0g.

sadaf’s picture

Is there anyway we can use this module to do a livestreaming event? Me and my group ( 4 participents) are doing a project that will allow us to live stream video over the internet to show community events.

We would like to help if we can,with anything in this modules in term of programming or debugging it and so on to help speed the development.

Please contact us at rcc.senior.proj@gmail.com. Thanks