Queuing up videos for live stream - php

Would first like to tell that am new to streaming and ffmpeg.
Would try to explain scenario as much as possible.
A web service is intended to receive chunks of video from a user. those chunks need to be simultaneously sent to the web for live streaming for a seamless viewing.
So the videos need to be queued up for streaming to the web so that it looks like a long single video. and the strict requirement is not to make any temp file on disk.
Did read something about pipes but am completely alien to that concept as well.
Kindly tell how / whether this can be achieved from FFMPEG or any other free tool .
Language used is PHP . The received videos also need to be saved to disk in parallel for new users to see from start.

You need to use an RTMP publisher that reads a flv/mpeg/avi/mov file (etc) and then connects to Red5, Wowza, or Flash Media Server.
You don't need tempfiles, just retrieve the video files from the user (in some manner) and then write a php scripts that uses ffmpeg to send them to the streaming server:
ffmpeg -i /home/video.avi -re -acodec libfaac - vcodec libx264 -vpre default -f flv rtmp://serverip/app/streamName

Related

how to stream video from FTP in PHP

is there any way, how to play movie or get some file (ex. jpg, pdf) from distance FTP server?
I've got an app on my PHP server and really lot of bigsized files, so I store it on FTP. I need to play (videos are the biggest problem) these videos via that app...
I've found ftp_get() function, but it seems to work like - "copy this file to my php server and than play",... it's not acceptable for long time.
Any ideas/solutions?
PS: excuse me my english and maybe not so detailed description.
FTP is a file transfer protocol so it's not the right tool.
Few ways to do it:
PHP HTML5 Video Streaming Tutorial (PHP stream)
Pseudo Streaming MP4’s with PHP
Streaming a large file using PHP

How to control the bitrate of youtube video on the go

I am using PHP as server side scripting. I want to know , How to control the quality of a video using php.
Here is what i want to do.
I will capture a video using any device and upload to server, and while retrieving the video
i would like to provide some options for the quality of a video to be displayed. Similar to how youtube provide some settings 240p,260p,480p etc
many thanks
You could use software such as wowza to do converting on the fly (http://www.wowza.com/)
Alternatively you could convert your uploaded video (straight after upload) by shelling out to ffmpeg.
exec("ffmpeg -i $input -b 128k $output", $output);
and then link to the different video files depending on selected bitrate.

Upload video and extract thumbnail using Amazon s3

i have been working in a video website [platform: php] where i need to upload videos in Amazon S3 server and extract thumbnail.
I have created a bucket and uploaded video file successfully in that bucket. But i don't know how to extract the thumbnail from that uploaded video. So, that's where i stuck.
Any help will be appreciated. Thanks in advance!
Here you've got some options.
First - you can "extract" a thumbnail from the video before you upload it to AWS. Something like: upload video to your server, convert it to appropriate format if needed, take a thumbnail (or thumbnails), save them somewhere (e.g. on S3 or your local server) and then upload the video to S3. The disatvantage of this method is that your local server will have to do a lot of extra work, instead of serving your web visitors.
Second - you can use Amazon EC2 computing service for that: upload video to S3, trigger EC2 (e.g. with cron jobs) to take the video from S3, convert it, take thumbnails and upload the final result (converted video + thumbnails) back to S3. Disatvantages are: it's not very easy to implement this "communication" (you'll have to solve a lot of problems, like ensuring stable converts, creating job queues etc.), plus you'll have to use one more AWS service along with S3.
What's about video converting and getting thumbnails? There are many tools and programs for that. I like using ffmpeg for video converting (also there's PHP wrapper for using it's functionality with php - php-ffmpeg, but using ffmpeg itself (e.g. using php's exec() function) will give you more flexibility and features, please read documentation for more details). FFMpeg can extract thumbnails from videos as well, but it takes some time (there are lots of discussions about how to do it effectively), but I'd suggest you to use ffmpegthumbnailer for this purpose. It has simpler usage and is optimized especially for getting thumbnails from video files.
You should do this on the machine you are using for the upload. Here you have direct file-system access to the file. Once it is in S3 it is accessible via HTTP only.
The tool ffmpeg can be used to create a thumbnail of many video formats.
Example:
ffmpeg -i "video.flv" -ss 00:00:10 -f image2 "thumbnail.jpg"
Would create a thumbnail at video second 10 and save it as thumbnail.jpg
When using PHP you can use system to execute

Remote video and thumbnails - all researched out

Greetings all,
I have been working to get thumbnail images for a site of mine and have made some fairly decent progress. I have been able to create thumbnails of images locally and those hosted on a remote server as I had hoped.
The issue I am having is that I am unable to do the same for Videos. I have successfully installed each of the following along with their dependencies and confirm they are all working locally:
ffmpeg (and vicariously ffmpeg-PHP and ffmpegthumnailer)
Imagick (currently working for all simple "image" thumbnail creation, local and remote)
mplayer
As of yet I have been unable to find a method that would allow me to capture a thumbnail from my own video files on a remote server. The reason I am trying to connect to a remote video file is because these videos can range from 5MB to 300MB each and I don't desire to copy the entire movie locally just to create a thumbnail.
I had come across one of these that "may" allow capturing an image from a rtmp stream, which I conveniently do have access to ... but nothing fruitful came of it.
Any ideas would be greatly appreciated,
Thank you,
Silver Tiger
Update from Silver Tiger:
Looks like i had an alternative method via a third party. I used Zendcoder to convert the video files on the fly to a standard format that can play on my web project reliably, and as part of thier service, they will automatically create a dynamic thumbnail and upload it to my Amazon S3 along side the converted Video file.
Crisis averted, but in a roundabout way, and not a solution I could provide as a "solution" to anyone else unfortunately.
If you have ffmpeg installed it should be quite easy. Try something like this
$movie = 'somefile.avi'; // video file
$time = '00:03:34'; // time where to take the snapshot
$cmd = "ffmpeg -i '{$movie}' -an -ss {$time} -an -r 1 -vframes 1 -y thumb.jpg";
$escCmd = escapeshellcmd($cmd);
system($escCmd);
Maybe you could have a script on the remote server to call? This way the thumbnail is generated on the remote server, and then passed back to the front-end server.
The easiest way to do this is to install apache (or whatever you prefer) and host the thumbnail generation scripts on there.
Then all you would need to do is call:
$imageData = file_get_contents('http://remotehost/generateThunmb.php?videoid=bleh');

how to save an image from video/quicktime video?

Hello is there a way in PHP to save an image from video/quicktime video ?
It's not possible in pure PHP. You would have to use an external command line tool like ffmpeg - but that makes the script less portable to other servers.
The only other idea that comes to mind is the Snapshot plugin to the LongTail Video player. With that, you can manually send snapshots of a video playing in the video player (an embeddable Flash player) to a server side script. The process can't be automated, though, and the video will need to be a FLV or MP4 one for this to work.

Categories