Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Show all videos in flash player (requires ffmpeg)  (Read 44215 times)

0 Members and 1 Guest are viewing this topic.

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Show all videos in flash player (requires ffmpeg)
« on: July 09, 2009, 05:41:53 am »

This plugin requires ffmpeg (with mp3 codec) pre-installed and working on your server. Please DO NOT ask for support on installing or configuring ffmpeg. If you don't have ffmpeg or can't install ffmpeg on your server then this plugin is not meant for you.

What will this plugin do?
This plugin will convert all uploaded videos to flv format and create thumbnail from the uploaded video file on the fly. FLV and thumbnails will be placed in the directory where the videos are uploaded/batch added. Though ffmpeg supports many video formats but i am unsure about wmv. File formats which i tested were avi, mpg, asf, mov.

Secondly on displayimage page a flash player (JW FLV Player) will play those videos. So the functionality of this plugin is similar to what Youtube offers i.e. upload video in any format and it will be converted to flv and played using flash player.

So what are you waiting for? Turn your personal gallery into youtube.

Note: This plugin is in early stages of development and might have lots of issues and weaknesses. Comments and feedback are welcomed.

Latest Release : v1.1

Download: http://sourceforge.net/projects/coppermine/files/Plugins/1.5.x/cpg1.5.x_plugin_video2flash-ffmpeg_v1.1.zip/download
« Last Edit: January 28, 2010, 10:26:56 am by Joachim Müller »
Logged
Chief Geek at Ranium Systems

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Show all videos in flash player (requires ffmpeg)
« Reply #1 on: July 09, 2009, 09:54:52 am »

Works exactly as advertized on my testbed - great plugin.

Here are my suggestions:
  • Rename the plugin folder from "video" to "video2flash_ffmpeg"
  • Add the plugin to the SVN
  • Add a readme that explains license and usage
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Show all videos in flash player (requires ffmpeg)
« Reply #2 on: July 09, 2009, 11:46:18 am »

Thanks Joachim for the suggestions. Will be implementing them in the next couple of days.
Logged
Chief Geek at Ranium Systems

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Show all videos in flash player (requires ffmpeg)
« Reply #3 on: July 10, 2009, 08:16:00 am »

Added the plugin to svn repository and implemented the other suggested changes. Please note that videos uploaded earlier won't work as the plugin name and a few other things changed in the code.

For now i have replaced the old attachement with the new one as the plugin is not released to public yet.
Logged
Chief Geek at Ranium Systems

Gremlyn1

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Show all videos in flash player (requires ffmpeg)
« Reply #4 on: July 21, 2010, 07:49:29 pm »

Installed this plugin today, running 1.5.6. I'm wondering if I'm missing something to get this working. I've definitely got FFMPEG with MP3 support installed, working, and the binary path pointed correctly, so as far as the set up go goes I believe I should be fine.

I'm using the Batch Add to add the AVI files, but they are just showing up as AVI files in the album. Is there something else i need to do to get the script to work it's magic? Thanks!
Logged

Spoter

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Show all videos in flash player (requires ffmpeg)
« Reply #5 on: November 15, 2010, 08:58:09 pm »

Hello I have a problem with the plugin, I installed the path ffmpeg well, because it creates very well  the thumbs; but it only plays audio because it didn´t turn the files on flv. Which could be the problem?
 http://www.morfeofilms.com/cpg142/displayimage.php?album=58&pid=437#top_display_media

My coppermine is v1.5.8

Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #6 on: January 03, 2011, 01:57:20 pm »

Hello!
First of all - Thank you very much for a great job (I mean CPG and your great plugin).

I am newbie here but wanna to share some info about this plugin.

I have my own server box powered by gentoo and my gallery with my family photos. My photocamera allows me to make short movies in MOV format (i think it's quicktime codecs).

I added a lot of such videos and used quicktime plugin for browser until found that new cpg was released with this great plugin.

So what can I say about it. First - I add new video, this plugin converts it to flv format, makes thumb JPGs. Thats all ok. But when you are trying to add some more new videos to the same album  - cpg as always select by default new files you have uploaded by ftp (i think it uses mySQL to compare what new files were added to directory). So here is the problem - cpg selects by default all FLV files as they are new one in that dir. So you have to uncheck all checkboxes with flv files, because you don't add them. These files were generated by plugin. As the solution I think plugin must register all generated FLVs in DataBase tables.

Second problem I faced with plugin that command line in main script where main video encoding runs doesn't work for me. And it fails here:
Quote
-acodec mp3

I have gentoo and emerged ffmpeg with mp3 support:

Quote
# emerge -pv ffmpeg

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] media-video/ffmpeg....  USE="bzip2 encode jpeg2k mmx mp3 network threads x264 xvid zlib

So I emerged next lame

Quote
# emerge -pv lame

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] media-sound/lame.....

and change the audio codec like this:
Quote
-acodec libmp3lame

and it works for me fine. May be it helps someone.

One more thinf I found in plugin (think it's a bug!). It generates normal and thumb preview for images BUT when it generate JW player object to insert it's HTML into cpg output it uses !thumb! images but NOT !normal!
So when you load your vide and JW player opens it's preview (screenshot from your video) it uses small image and it looks so ugly! So here is the line I corrected in your plugin:

Quote
/**
 * Function to return html required for displaying the flv palyer
 */
function video2flash_ffmpeg_file_data($pic_data) {
    global $CONFIG;
.................
        //$thumb = $CONFIG['fullpath'] . $pic_data['filepath'] . $CONFIG['thumb_pfx'] . $matches[1].".jpg";
      $normal = $CONFIG['fullpath'] . $pic_data['filepath'] . $CONFIG['normal_pfx'] . $matches[1].".jpg";
        $flashvars = '';
        if (file_exists($normal)) {
            $flashvars = '&image=' . $CONFIG['ecards_more_pic_target'] . $normal;
        }

because we need normal image size. Normal in this plugin as i see is the size of JW player object but not the original video width.

One more thing. ffmpeg by default generates FLVs with very poor quality. To fix this problem I added this param - "sameq" to CMD line:

Quote
$cmd = "{$CONFIG['video2flash_ffmpeg_ffmpeg_path']} -y -i $src_file -acodec libmp3lame -ar 22050 -f flv -sameq $ff_dest_file";
It helps to make FLVs with much more better quality (some thing near to it's original) but with a bit bigger size of FLV files.

(note: please be careful with your OS. Look at this line
Quote
if (eregi("win", $_ENV['OS'])) {
and choose you CMD line)

And one moe thing but very important. As I already said there were a lot of MOV files. So There was a problem for me to convert that files to FLVs, because this plugin only runs on video adding action. So I had to learn some bash basics and wrote this little script to convert all my MOVs to FLVs.

Quote
#!/bin/bash
#Script just put commands into file that can be used as a shell programm to encode video and make ScreenShots
#Done like this because ffmpeg always breaks the while cycle
ConvertTaskFileName=~/ConvertTask.sh
if [[ ! -f $ConvertTaskFileName ]]; then
echo "#!/bin/bash" > $ConvertTaskFileName
chmod u+x $ConvertTaskFileName
fi

FullFileName=$1
#Get File name, dir and extension (in this version we don't need extension)
dir=$(dirname $FullFileName)
filename=$(basename $FullFileName)
extension=${filename##*.}
filename=${filename%.*}
#Encode to Flv our video files
echo "ffmpeg -y -i ${FullFileName} -acodec libmp3lame -ar 22050 -f flv -sameq ${dir}/${filename}.flv"  >> $ConvertTaskFileName
#make a thumb ScreenShot. In my case it's 100x75 pixels
echo "ffmpeg -i ${dir}/${filename}.flv -an -ss 00:00:07 -r 1 -vframes 1 -s 100x75 -y ${dir}/thumb_${filename}.jpg"  >> $ConvertTaskFileName
#make normal screenShots. In my case it's the same as video width x height so I don't need to convert it to JW Player's size
echo "ffmpeg -i ${dir}/${filename}.flv -an -ss 00:00:07 -r 1 -vframes 1 -y ${dir}/normal_${filename}.jpg"  >> $ConvertTaskFileName

Then go to your album dir and run this script as

 
Quote
# find $PWD/upload/ \( -name "*.MOV" -o -name "*.mov" \) -type f -exec ~/encode.sh {} \;

It finds all MOV and mov files (as I said my camera makes only MOVs).
but you can use any vide extensions as you want (I think this will work):
 
Quote
# find $PWD/upload/ \( -name "*.ext1" -o -name "*.ext2" -o -name "*.ext3" \) -type f -exec ~/encode.sh {} \;

Then go to home dir and run the programm that was generated by my script:

Quote
# ./ConvertTask.sh

Note: I advise you to run it in screen, especially if you have a lot of video files and use ssh to connect to your server.

I am not an expert in such programming stuff but that worked out in my case.

And it will be very great if such feature as encoding old video files will be as a part of this plugin in the future.
 I hope that it my post will help someone.
Thanks a lot. Thats all for now.   ;)
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #7 on: January 03, 2011, 03:23:47 pm »

One more bug:

Quote
        if (file_exists($normal)) {
            $flashvars = '&image=' . $CONFIG['ecards_more_pic_target'] . $normal;
        }
        if ($CONFIG['video2flash_ffmpeg_player_autostart'] == 'yes') {
            $flashvars = '&autostart=true';
        }

FlashVar variable rewrites here. need to use ".=" instead of "="
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #8 on: January 03, 2011, 07:51:57 pm »

Modifies a bit this plugin for myself. May be it will be usefull for someone else except me.

First of all update JW Player from its homepage, update it's object tag (html to call JW flash player) by changin the way it's called (as for e.g. added fullscreen mode), add some params to plugin's admin interface.
Using this code you can change position of control buttons of JW from OVER (when they disappear when you don't touch mouse) to BOTTOM (fixed, always ontop).
Other FLashVars I don't think people wants to change. But you can read about them here - http://developer.longtailvideo.com/trac/wiki/Player5FlashVars
and add any FlashVars to JW HTML object as you want manually or even expend plugin's admin interface. (also you can read here about it http://kb2.adobe.com/cps/127/tn_12701.html )

And also now you can change skins of the player.
You can find skins here http://www.longtailvideo.com/addons/skins

To change skin you have to fill in plugin's admin interface skin's address, for e.g.:
Quote
www.longtailvideo.com/files/skins/fs40/5/fs40.zip
or
Quote
www.longtailvideo.com/files/skins/playcasso/5/playcasso.zip
and so on. By default it uses this http://www.longtailvideo.com/addons/skins/196/Glow skin.

Just don't have access to your SVN repository so attaching my full plugin code here in this post (with new JW player as well). By the way it will be great in the future to migrate from php4 in this plugin to php5 with it's Object Orientation, and code will be much more readable and safe!

And one more time - "Thanks for this Plugin Ali!"
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4453
    • Windsurf.me
Re: Show all videos in flash player (requires ffmpeg)
« Reply #9 on: January 03, 2011, 08:50:38 pm »

Thanks for your work Alex. I have added you to the contributor group. I'm in the process of testing your modifications and so far they are looking great. Well done and keep up the good work.

If testing all goes well I'll add your version to the repository tomorrow.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #10 on: January 03, 2011, 09:54:58 pm »

Found one more new problem in new JW Player. By default it comes with viral plugin. And it's annoying very much. WHen you are trying to pause video  this pluggin shows up menu over the video stream.

To control this plugin you can use FlashVars. See post of Ethan LongTail here - http://www.longtailvideo.com/support/forums/addons/using-and-creating-skins/10040/how-to-disable-embed-share

As for me I fixed a bit Ali's plugin one more time.
Quote
      //Viral Plugin. For more info see  http://www.longtailvideo.com/support/forums/addons/using-and-creating-skins/10040/how-to-disable-embed-share
      $flashvars .= '&viral.onpause=false'; //Show menu on pause button press or not
      $flashvars .= '&viral.oncomplete=false';//Show menu video oncompleted playing
      $flashvars .= '&viral.allowmenu=true';//shows viral menu button
      $flashvars .= '&viral.functions=all';//Viral functions. Shows all. ;)

Full version of file I attached to the post. I do hope it will help someone.



Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #11 on: January 04, 2011, 09:58:17 am »

Thank you! But please don't add it to SVN. I have some more upgrades of code. I hope to post it here today a bit later.
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #12 on: January 04, 2011, 03:48:17 pm »

Finished some work with the plugin today. Now I am happy with it so want to share it with the community.

What was done (here is my changelog file):

Code: [Select]
2011-01-04 [A] Added video encoding with better quality (sameq param for ffmpeg) {Alex.inf}
2011-01-04 [A] Added codec selection (mp3 or libmp3lame) {Alex.inf}
2011-01-04 [A] Added ability to change skins {Alex.inf}
2011-01-04 [A] Added ability to change audio discretization rate {Alex.inf}
2011-01-04 [A] Added ability to change control Bar Position {Alex.inf}
2011-01-04 [A] Added shell script to encode old video files in Unix like systems {Alex.inf}
2011-01-04 [B] Fixed bug in FlashVars string generating {Alex.inf}
2011-01-04 [B] Fixed bug in after_delete_file action {Alex.inf}
2011-01-04 [B] Fixed thumb showing bug. A preview image that JW Player shows. {Alex.inf}
2011-01-04 [M] Updated JW Player fow lates version {Alex.inf}
2011-01-04 [M] Maintenance the viral plugin for JW Player {Alex.inf}
2011-01-04 [M] Updated changelog file and README file with a bit more detailed instructions {Alex.inf}
2011-01-04 [O] Rewrite some code, optimized flash object output

What have to be done in the future:

Quote
1) Improve shell script (encoding old videos). I thought a lot about it and I think that the only way to deal with old videos is using shell but not php. Because big, long videos php can't encode correctly. It make takes you an hour or a day to encode all your old video files.

2) Problem of registration FLV files. When you add new video, this plugin converts it to flv format, makes thumb JPGs. Thats all ok. But when you are trying to add some more new videos to the same album  - cpg as always select by default new files you have uploaded by ftp (i think it uses mySQL to compare what new files were added to directory). So here is the problem - cpg selects by default all FLV files as they are new one in that dir. So you have to uncheck all checkboxes with flv files, because you don't need to add them. These files were generated by plugin and don't need to be added again. As the solution I think plugin must register all generated FLVs in DataBase tables.

And at the final I'm attaching my latest package version of Ali's video2flash_ffmpeg plugin. I updated all files like readme and changelog as can, added my bash script and instruction to it. Also put in package some skins for JW Player. You can download, explore archive, test or update files any way you like it and of course commit changes to repository.
Thanks.
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #13 on: January 04, 2011, 09:18:58 pm »

Spoter
Please check if you have mp3 support with your ffmpeg installation. If screenshots are generating it means only that ffmpeg works fine, but it fails when it tries to encode video. I've got the same problem until started using libmp3lame instead of mp3.

Check your apache error logs for more details. ffmpeg writes everything there in case of problems.
Logged

Spoter

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Show all videos in flash player (requires ffmpeg)
« Reply #14 on: January 04, 2011, 09:47:51 pm »

Thank you for your help Alex, but the problem I have is that the files dont become to flv. I talked to the server managers and they said the script was invalid, they ask me to use their script but I don´t know very much about codes so I don´t know where to put it or how to change it. The script is the following:

Quote
<?php
ini_set("display_errors",1);
// Set our source file
$srcFile = "/web/htdocs/www.domain.com/home/test.avi";
$destFile = "/web/htdocs/www.domain.com/home/test.flv";
$ffmpegPath = "/usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/bin/flvtool2";
// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);
// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
// Call our convert using exec()
$command = $ffmpegPath ." -i " . $srcFile ." -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . "- | " . $flvtool2Path . " -U stdin " . $destFile;
exec($command,$out);
chmod($destFile,0755);
echo "<br><br><b>Comando</b>$command<br>";
// Make multiples function
function makeMultipleTwo ($value)
{
$sType = gettype($value/2);
if($sType == "integer")
{
return $value;
} else {
return ($value-1);
}
}
?>

I have tried your new version and the problem is the same and the flv files up stay in blank screen. After uninstall the new version the flv files are loading very slow.
Excuse my bad English and thanks again.
Logged

Spoter

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Show all videos in flash player (requires ffmpeg)
« Reply #15 on: January 04, 2011, 10:11:35 pm »

These are the ffmepg of my server:
ffmpeg-php version  0.6.0-svn 
ffmpeg-php built on  Dec 24 2010 10:36:47 
ffmpeg-php gd support  enabled 
ffmpeg libavcodec version  Lavc52.20.0 
ffmpeg libavformat version  Lavf52.31.0 
ffmpeg swscaler  disabled 

Directive Local Value Master Value
ffmpeg.allow_persistent 0 0
ffmpeg.show_warnings 0 0
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #16 on: January 08, 2011, 05:04:24 pm »

Hello!
Don't worry about your english because mine is the same =)

Script that you put here is using ffmpeg-php (php extension that helps to determinate bit rate, size and ohter parameters of video).
First in this script an object of ffmpeg-php class was created. Then main params like width, height, audio bit rate and discretization were determinated.
Take your attention at makeMultipleTwo functon. It as I see  decrease video size (for example 640x480 -> 320x240) and I think must be called  makeDivisionByTwo or something like bitwiseShift.

Also your specialist used /usr/bin/flvtool2 programm but I don't know what exactly it does.

Look also at final command line
Quote
$command = $ffmpegPath ." -i " . $srcFile ." -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . "- | " . $flvtool2Path . " -U stdin " . $destFile;
there is no -acodec option for an audio codec. So I think that's why their script may work at their server.

Script by Ali also works fine. Did you see your apache logs or do you have SSH access to your server?
May be "-acodec copy" option can help you.
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #17 on: January 25, 2011, 07:24:45 pm »

Hi, everybody!
Had to spent some time with ffmpeg, so decided to add a bit more functionality to plugin.

So added ability to set up audio bit rate. By default it was 64k if I remember correctly. Now you can set it for your purpose, for example 128k or a bit more if you have a really good audio source.

Have fun with it!
Logged

romeonet

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 2
    • Service Calculatoare
Re: Show all videos in flash player (requires ffmpeg)
« Reply #18 on: April 06, 2011, 01:03:19 am »

Hi,

Great work Alex, bravo! ;)

But, I think there is a problem with JW Player on Internet Explorer. All other browser are ok only on IE don't want to start...

Please have a look here http://media.romeonet.ro/displayimage.php?pid=2689

Probably somethink in your source code is not ok ...

I want to notice that with video2flash_ffmpeg 1.1 player run in IE.

Thank you!
Logged

Alex.inf

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 12
Re: Show all videos in flash player (requires ffmpeg)
« Reply #19 on: July 20, 2011, 07:06:40 pm »

Thank you very much! That was a bug in my html output code I think. I don't know what was the problem even till this moment but it doesn't matter any more.
I rewrote that part of code. Now embedding of player in your site is done in JavaScript way. I updated JWPlayer Version to 5.7 with viral support plugin and used JS embedding method described at offiicial JWPlayer's manual on its site. Also constant config params now store in XML file.
Latest version 1.3 with new JWPLayer and with fixed bugs (now tested in Internet Explorer 8.0.7601.17514, Opera 11.50 and FireFox 5.0) you can download in the attachment of this post.
« Last Edit: July 26, 2011, 08:21:01 pm by Alex.inf »
Logged
Pages: [1] 2   Go Up
 

Page created in 0.044 seconds with 21 queries.