Php code for getting the first frame of a video(flv) - php

I have using flow player for playing my .flv videos.How i can create a thumbnail from the first frame.Is their any inbuilt Php code for doing this one.
Thanks in advance.

The only way I know of is using FFMPEG. I have never used this script, but looking at it seems to be what you need, and may need some tweaking.
http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/447/show-first-frame-as-preview-image
EDIT
To get the image / display it you would just use the html code:
<img src="http://my.domain.com/path-to-file/ffmpeg_image.php?file=video.flv&time=00:00:00&browser=false" />
From what I gathered from that script. But of course, it would probably be better to, when you upload the video, run that and generate a "cache" of the image so that whole process does not have to run for each call.

Not exactly what you are looking for but a good way of showing the first frame of a video in flowplayer is to set autobuffering to true:
clip: {
autoPlay: false,
autoBuffering: true,
}
This will load the video (wich might be very bad for you).
To do it yourself you need something like ffmpeg installed on your system. if it is installed check this out.

Hmm, some guy on the forums needed something similar and I tried to help him, idiot-proof style. Check out the last post on this thread. I hope it helps.
link

Related

AJAX image upload possible jquery with preview

I am trying to find some sort of plug-in for Ajax upload with a file preview. The image will be saved into a MySQL dataBase. Is that even possible? I guess all things are possible with certain requirements. Have you guys ever come across anything like that?
Let me tackle your question one bit at a time:
I am trying to find some sort of plug-in for Ajax upload...
BAM!
...with a file preview.
Yep, from the page above, although I might wonder why this is necessary and if it isn't remove it (I believe minimalist design is usually better) and go with fancy upload which seems to be more popular (sorry, I don't have much experience with ajax uploaders)
The image will be saved into a MySQL dataBase. Is that even possible?
Unfortunately, it is; you will have to use the blob data type (alternate tutorial). Personally though I would just create a directory and save the images there, because then you don't have to query MySQL every f***ing time you want to display the image (I would feel bad for hat server). In which case I suggest you use class.upload.php (I have good experiences with it), in conjunction with whatever ajax uploader you chose to use.
I guess all things are possible with certain requirements. Have you guys ever come across anything like that?
...yes
I also store the uploaded images in a directory and their names in the database.
I have developed a jQuery plugin that performs a dynamic upload of an image when it is selected, and previews it.
You can find a demo of the UploaderPreviewer plugin here:
http://dondedeportes.es/uploader-previewer
Hope it is useful for you or for anyone with the same problem.

Require a PHP Image Resizer/Cropping Script

I am grabbing links to images and need to convert them on the fly to 72x108 to display on a website. The source images come from various resolutions, so cropping is required.
I know a moderate level of PHP so I can probably make something work for my needs, but was hoping for something that could be called by a url request. EG: mysite.com/thumbnail.php?src=http://anothersite.com/image.jpg&w=72&h=108
That would be ideal, it needs to support jpg/png.
Thanks in advance!
Here is a really handy script for processing and uploading images that's been a top google result for forever. I used it years ago and it was really easy to implement. Looks like it was just updated a couple weeks ago too :)
http://www.verot.net/php_class_upload.htm
This may be overkill, but if you check out the examples you can see there's a lot you can do with it. If you don't use it for this project, it might be worthwhile to try out for the next one.
just read the image from the url with file_get_contents or using curl and use the php gd library to resize and crop the image as per your needs.
Go through the following links for more info:
http://php.net/manual/en/function.file-get-contents.php
http://php.net/manual/en/book.image.php
http://davidwalsh.name/download-urls-content-php-curl

Google/YouTube Insight style "Interactive PNGs"?

I have been looking at the YouTube Insight function and want to learn how their chart PNGs are created.
If you have a video and look at the statistics, you get a bunch of PNG-images that in many ways can be considered interactive. Look at the image below.
As far as I can tell, everything consist of PNG images. I expected to see flash elements, but I do not.
For example: The slider where you chose date range can be dragged, clicked and the image updates dynamically without the page reloading. I am thinking, maybe ajax-style calls are made that replaces the image? It is totally seamless as far as I can see.
Another example: You can chose country by clicking the world map. The images are instantly updated to display the demography chosen. Are something simple as image maps used to catch the clicks?
Google/YouTube Insight screenshot http://www.mattis.st/images/google_insight.png
My questions are:
1). How do you create PNG images with information from a database? I prefer to use PHP so if you like tweak your answers in that direction. I am not looking for any third part "plugins", other than perhaps jQuery.
2). How are they creating the "interactivity" on their PNGs?
The PNGs are only clickeable and interactive when you check Google Insight on your own videos. Checking normal statistics for a video only loads static PNGs.
I know about Open Flash Chart and the likes, however I want to create my own code to learn as much as possible and be able to tailor the code for my use.
I truly appreciate any answers. Please ask for clarification if I am unclear.
EDIT: I examined the Google/YouTube source code further and found one of the images to be:
<img src="http://chart.apis.google.com/chart?chs=422x110&cht=lc&chco=808080&chd=s:At9j0jSUPJKMM&chls=1&chm=B,F7F7F7,0,0,0%7Ch,CCCCCC,0,-0.5,1" class="GDYWU0EBBG">
Which looks like this (saved from my valid session):
Image from source http://www.mattis.st/images/google_insight2.png
As you can see, this is the background PNG image without the bars and the range selection overlay.
<div id="GEOMAP_map" style="">
<embed type="application/x-shockwave-flash"
src="/insights/search/resources/544738731-geomap.swf"
width="500" height="310" style="undefined" id="geomap"
name="geomap" bgcolor="#FFFFFF" quality="high"
allowscriptaccess="always" wmode="opaque" flashvars="(...)"></div>
Looks like flash to me.
AFAIK you will always need a plugin to generate images from PHP (be it GD or ImageMagick). I don't have any experience with ImageMagick, but I know GD isn't the quickest of cats.. I wouldn't count on it to generate your charts on-the-fly!
And as suggested by justkt, you could use any js library to create interactivity. No fancy flash required :)
After thinking about it, examining the source even more, and considering the replies you guys have made I have come to the following conclusions:
1). The PNG's are generated with the Google Charts API (thanks Tom!).
2). The interactivity is created with nifty javascript programming. The seamlessness of it is hugely impressive, and I will try to implement something alike in my project.
Thank you for your replies and your time.

How to use imagefill() from file?

Thanks for looking at this question.
I wanted to know how can I use the GD function imagefill() to patch an image with another image.
imagefill() currently accepts resource of a color.
I can do that. But wanted to know how this can be done with a file.
I noticed a user note - But that didn't worked and took a long time for completion :-( http://www.php.net/manual/en/function.imagefill.php#84288
Okay people, have figures it out...
One needs to use imagecopymerge() function to achieve what i was trying to.
Thanks to all the viewers!

Ajax with slide effects onready witout using a toolkit

I'm really not that good at Javascript and that, so I need another bit of help. I want to be able to do a quick bit of AJAX using PHP then when the ajax response is finished show the response in a div and SLIDE it down nicely.
The basic AJAX side of it is no problem. But I want to be able to have it slide nicely without using any framework like jQuery or MooTools. Mainly for learning, but there are other reasons. So, any help on a very simple way od doing so would be handy. I can't really find much online. If I have to use jQuery then I guess I can, I have played about with it but I'm not a fan of Javascript at the best of times...
So yeah, pretty much any advice/tips/thoughts/help would be really handy!
I guess the basics would be something of a timeOut() in combination with increasing the height until it is full height:
set the display of the element to none
get the full height of the element, something like:document.getelementById('IDofElement').style.height
set the height to 0 and the display to something like block
set a timeOut() and increase the height in the called function, activate a new timeOut() if the element is not already full height.
The only real disadvantage of not using a library would be that you would have to test in a lot of different browsers and perhaps make modifications according to the browser used. Libraries have already solved that problem for you.
Personally, I'd just use JQuery. If you want to see how they do it, then download the developer version of the library and look at the code.
If you're not a fan of javascript, then use a library, it means you have to write less.

Categories