MP4 support

aznboy - March 13, 2008 - 22:27
Project:FlashVideo
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:attheshow
Status:closed
Description

Any plans to have the option to encode in mp4 now instead of flv?

#1

ferrangil - March 17, 2008 - 10:18

You mean using H.264...
I'm also waiting for that...

#2

travist - March 18, 2008 - 02:15

Any takers for sponsoring this feature? I am slammed at the current moment, but sponsorship will bring this feature much sooner.

#3

Farreres - June 8, 2008 - 22:10

I entered the ffmpeg irc channel and they gave me those instructions:

Compile the most recent ffmpeg from cvs with those compile options:
./configure --enable-gpl --enable-libvorbis --enable-liba52 --enable-libdc1394 --enable-libgsm --disable-debug --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-libxvid --enable-pthreads --enable-libx264

Then follow the guides:

http://rob.opendot.cl/index.php/useful-stuff/ffmpeg-x264-encoding-guide/
http://rob.opendot.cl/index.php/useful-stuff/x264-to-ffmpeg-option-mapping/
http://ffmpeg.x264.googlepages.com/mapping

Following this guide, I created some flv encoded with H.264. They work Ok already with the module as is, but some videos stop playing abruptly midway, and I don't know why. When I play the encoded result (the mp4 file not the flv) locally I get some warning: first frame is no keyframe. It seems a keyframe is a totally encoded frame (other frames are encoded as differences between frames). In order to have good search capabilities (moving around the movie) key frames play some role.

That's all I know. I see video encoding is highly complex, many parameters and things to touch.

Also referring the same thing, I have tried changing the name of the file (thanks to cck) to mp4 and playing it as an mp4 not as an H.264 inside an flv, but it is not shown within the flash player, is there any way to do it? I mean, view the mp4 like in this link:
http://mirror05.x264.nl/Dark/Flash/index_lowbitrate.html with progress bar and all such nice things.

#4

Farreres - June 11, 2008 - 07:04

I have located the problem with viewing mp4 and flv with H.264 encoding. It's a problem of the JW Player. I have tried with FlowPlayer and it works like magic!

#5

jtolj - December 11, 2008 - 21:06

This works fine in the newest version of JW Player. Quality is much improved over non-h264 at the same bitrate.

Here is the command line we're using. It doesn't fit in the box given in the module config page, so you'll need to hard code it into flashvideo.module.

Video ends up being ~300kbps x.264 in flv container, 64kbps, 44.1khz mono mp3 audio.

-s 480x368 (change 480x368 to your output resolution... *both numbers should be divisible by 16*)

-crf 26 (26 controls quality, lower number is better quality / higher bitrate)

-ab 64k (audio bitrate)
-acodec libmp3lame (audio codec)
-ac 1 (# of audio channels - 1 = mono, 2 = stereo)
-ar 44100 (audio sample rate... cannot be 48000 for flv container)

ffmpeg -i input.mp4 -y -s 480x368 -acodec libmp3lame -ab 64k -vcodec libx264 -refs 6 -crf 26 -flags +loop -cmp +chroma -flags2 +bpyramid+wpred+mixed_refs+8x8dct -me_method umh -subq 7 -trellis 2 -bidir_refine 1 -refs 5 -deblockalpha 0 -deblockbeta 0 -bf 16 -b_strategy 1 -bframebias 0 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -r 24 -ac 1 -ar 44100 -f flv output.flv

#6

ferrangil - December 12, 2008 - 07:58

AFAIK, newest flash versions support the .mp4 format directly (with the video in H.264...), so why transcode it to .flv?
Just wondering why...

#7

jtolj - December 12, 2008 - 12:47

.flv works without any changes to the module, so it's just easier to configure.

I've tested .mp4 though, and it works fine with a few tweaks to flashvideo.module...

and changing [FileType, MimeType, DefaultPlayer] configuration:

[mp4, video/mp4, quicktime]
to
[mp4, video/mp4, flash]

#8

chawl - January 6, 2009 - 22:59

There can be an option for "not" transcoding MP4's (without NOCONVERT) but creating the thumbnail. I tried to hack the module but FLV extension is so hardcoded in the module that I am lost. Future updates would be an issue though.

There are many people using lighttpd MP4 pseudostreaming module out there and no smart brain will put H.264 (say x.264) in a FLV container from now on as Flash supports MP4 natively (sorry QT).

This option can be a major benefit I think.

#9

jtolj - January 7, 2009 - 00:30

chawl, does mod_flv_streaming with lighttpd not work if the video is h264 encoded? I wasn't aware of that.

As for passing through mp4 files without transcoding, are you using 5 or 6?

I'm not familiar with the 6.x module, but in 5 it shouldn't be too difficult... you could add something like:

if ($extension = 'mp4') { //special case for mp4 files
  $params['thumbext'] = 'jpg';
  $params['videoext'] = 'mp4';
  $params['videomime'] = 'video/mp4';
  $params['create_thumb'] = TRUE;
  $params['create_video'] = TRUE;
  }

right after ~ line 1171:

$extension = _flashvideo_get_filetype($file->filepath); // Get the file extension.

and also change:

if(!$create_thumbnail && $extension == 'flv')

to
if(!$create_thumbnail && ($extension == 'flv'|| $extension == 'mp4'))

That should pass through mp4s without transcoding and still make the thumbnail. I think it would even work with flashvideo_get_video() since you changed $params['videoext']... although I'm not 100% sure.

If that is true what you are saying about pseudo-streaming not working with h264 in an flv wrapper, I may implement something like this myself.

#10

chawl - January 7, 2009 - 02:21
Category:support request» feature request

Thank you jtolj. I am monkeying with 6.x-1.x-dev version anyway, sorry for not mentioning previously.

Two interesting threads on JW site about pseudostreaming and I think the situation is little bit "depends on" :
http://www.longtailvideo.com/support/forum/General-Chat/13751/Can-H264-V...
http://www.longtailvideo.com/support/forum/Modules/7099/Stream-h-264-wit...

I have not checked the very recent progress on this but I think to feed MP4 files directly without winding will make everyone happy.

But as having ffmpeg ready, I may also hijack the module and may directly transcode to MP4 (or whatever). Only thing I may need is to take control of the extension of the outputted file and make @output token name-only, then I can use @output.ext for ffmpeg parameters. But this can hurt the philosophy of the FV :)

Hacks are neither semantic nor updateproof unfortunately, and I am not a real PHP coder. Anyway I will check the code again with your inspiration and if I can manage something, I will post here.

But again, I think "don't transcode but create thumbnail" can be a native option for the module for Flash playable formats.

FV is still excellent anyway but may need a feature request :)

By the way, wish all a happy new year...

#11

chawl - January 7, 2009 - 22:54
Status:active» needs review

Ok. I made a small hack to the module just to treat MP4 files as native as FLV. So with this hack:

If you upload an xxx.mp4 file, it is not transcoded to xxx.flv but remains as xxx.mp4, copied to output folder as xxx.mp4, and the thumbnail xxx.jpg is generated.

That's all. Normal FLV procedure or other transcoding operations are not affected. This hack is for 6.x-1.4 version of the module not the dev. I am not a PHP coder that you have to use it with caution and expect no semantism. It just works.

I am not familiar with patches and I zipped the whole "flashvideo.module" file anyway, sorry for this.

Just unzip the content of the zip file under /sites/all/modules/flashvideo directory and replace the original flashvideo.module.

I included the changes in #7 in the file, but if you installed the module earlier, you have to check under FlashVideo Settings -> Global Settings if everything is intact as offered in #7.

Thank you for a great module and jtolj for inspiring :)

AttachmentSize
flashvideo_module.zip 21.27 KB

#12

chawl - January 8, 2009 - 01:41
Version:5.x-2.7» 6.x-1.4

#13

travist - January 8, 2009 - 05:00

I think this will make its way into the next update. However, I would like to add a configuration where the user can pick and chose which extensions they wish to encode and create a thumbnail for, or which ones they wish to just leave alone. Great work everyone.

#14

Kripsy - January 14, 2009 - 07:58

I would also suggest changing the maximum length for the "ffmpeg Command" from 256 to 512 in the flashvideo.admin.inc file so that the longer -x264lib command lines can be entered. They must be so long because there are no defaults within ffmpeg for any of the values and not all hosting allows the installation of profiles.

#15

chawl - January 14, 2009 - 08:48

+1

#16

jtolj - January 14, 2009 - 14:16

Another way to approach this would be to allow the user to set $params['videoext'] and $params['videomime'] in the GUI (or just videoext and figure the mime type from that), and then a checkbox option to pass through videos that already have that extension

if (flashvideo_variable_get($node_type, 'passthrough', 'false') && $extension == $params['videoext'])

Might be more flexible than just allowing for pass through for a particular extension or extensions, for example if you wanted a hi-res mp4 for download and lower res mp4 for stream.

Although both approaches would be useful.

I can write a patch for 5.x to do this (because we will likely use it), but it sounds like most folks are moving on to 6.

#17

strangeluck - January 26, 2009 - 19:14

would immensely love to see this feature implemented. using the patches described here (i've actually applied the changes to the latest dev release in order to utilize the new filefield support as well; though i face the same issue with the 1.4 version of this patch) i find that videos convert properly and use .mp4 as their extension. however, when using [video] in my body i get the "video not available" image. does this have something to do with the fact that the extension is now .mp4 as opposed to .flv? any ideas?

oh, i've also included my patched copy of the 1/25/09 dev module should that make diagnosing this any easier.

AttachmentSize
flashvideo.module with mp4 support 1/25/09 dev version 23.43 KB

#18

PePiToO - March 30, 2009 - 02:36

same thing here, i got "video not available" when uploading a mp4 file

#19

PePiToO - March 30, 2009 - 02:36
Version:6.x-1.4» 6.x-1.5-beta2

same thing here, i got "video not available" when uploading a mp4 file

#20

strangeluck - March 30, 2009 - 15:28

i've taken to using the jquery media module in order to enable .mp4 playback with the flashvideo filefields. it works pretty well save for a few issues with passing flashvars.

#21

attheshow - April 26, 2009 - 05:30
Version:6.x-1.5-beta2» 6.x-1.x-dev
Assigned to:Anonymous» attheshow
Status:needs review» fixed

The features outlined above are now included in the latest dev version. If you have an existing FlashVideo site and are planning to begin uploading mp4 files, you'll want to visit the Universal Settings page at "admin/settings/flashvideo/universal" and make sure that in your "[FileType, MIMEType, DefaultPlayer] configuration:", you have:
[mp4, video/mp4, flash]

...and in your "Flash MIME Types:", you have:
video/mp4

Those two changes to your configuration should help to prevent the "video not available" issue that strangeluck and PePiToO mention above.

#22

ngreenwood6 - May 5, 2009 - 01:23
Version:6.x-1.x-dev» 6.x-1.5-rc2
Status:fixed» needs review

Still not working. I just changed that on mine and it didnt work.

#23

attheshow - May 5, 2009 - 02:50
Version:6.x-1.5-rc2» 6.x-1.x-dev

You need to be using the dev version currently for this, not RC2.

#24

attheshow - May 12, 2009 - 01:52
Status:needs review» fixed

#25

System Message - May 26, 2009 - 02:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#26

vr_mex - October 4, 2009 - 17:08
Status:closed» active

Have this changes been made to 6.x-1.5-rc4 ?

#27

attheshow - October 24, 2009 - 21:36
Status:active» closed

This information is available in the release notes. http://drupal.org/node/117287/release

 
 

Drupal is a registered trademark of Dries Buytaert.