User video upload to be played in all browsers - php

I am creating an web application, where user can upload his profile introduction video. I tried searching around to look for tutorials, but did not find any. I have the user video upload part/ code in PHP, but my question is that how can I make the video playable in all browsers?
Is there a library for it or application I have to use for that? If anyone can point me in the right direction, I'd appreciate it.

try this it's work for you
<video controls>
<source src="<?php echo $this->webroot; ?>img/uploads/profile/<?php echo $listdata['SubscriberVideo'][0]['name'];?>" type="video/mp4">
</video>
change video path to your path.

If you want the video to play in most major browsers on most common devices an OS's (all is tricky as there are many small niche browsers), then, as I am guessing you have noticed, you need to be aware of the video formats that different combinations require.
Partly this is because new and better encoding methods emerge over time and are adopted at different times by different browsers etc, and partly it is because the video encoding world is full of patented software and different browsers, OS's etc have different rights and different philosophies around this.
On top of that you need to be aware that the requirements change over time as new devices and new codecs etc are released.
You can narrow things down by restricting yourself to the most recent versions of OS's and browsers, and by using HTML5 playback.
There are several resources that provide some example HTML5 code to support playback across as wide a set of devices as possible - e.g.:
http://v4e.thewikies.com
As you can see you do need to convert the uploaded video into several different encodings and packaging format to achieve maximum coverage.
You can do this sever side by using a package like ffmpeg, open source video manipulation software:
https://www.ffmpeg.org
There is a PHP wrapper library for ffmpeg which may be worth looking at if your server is PHP based:
https://github.com/PHP-FFMpeg/PHP-FFMpeg
Having said all the above, if you want a simpler solution that will play back in nearly all browsers at this time, the mp4 format (MP4 container and H.264 codec) will probably meet your needs. You can check current coverage using links such as this one (make sure you use a well known reputable source as this areas changes frequently):
http://caniuse.com/#feat=mpeg4
https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats

Related

Converting PPTX to PDF with PHP

I am developing an API, in PHP, hosted on a linux server, that requires me to make jpeg previews for a .pptx powerpoint presentation.
I first convert the file to pdf and then convert the pdf to jpegs.
The second step is easy, with ghostscript, it's the first part that's proving difficult.
I have tried using the libreoffice executable, but pptx isn't completely compatible. Certain backgrounds become invisible.
I have the same problem with many 3rd party APIs (which I suspect also use libreoffice); the ones that do work, are ridiculously expensive.
Installing office on a Linux server and using COM functions seems impossible, or very tedious at best.
I have looked at Aspose.Slides, which also seems rather expensive, and their documentation is filled with errors.
I could use suggestions on how to tackle this problem.
I have tried to find the underlying problem of why LibreOffice and online conversion tools have a problem with the backgrounds of the presentations I need to convert.
The background is a .emf file, which has bad support.
My solution
I've unzipped the presentation, converted the .emf files to png (using ghostscript), changed all mentions of .emf to .png in the XML, and rezipped the altered presentation.
When I now use the LibreOffice headless to convert to pdf, the background shows up.
It might be a bit hacky, but it works for the intent of my program.
ps. I see that my question has gathered a few downvotes. In my opinion it was a valid question, and listed the various solutions that had worked for others, but not for me. If anyone has insights or ways to improve it, feel free to comment.

Playing large videos online

I have a few videos (avi, mp4, mkv) each is around 1 GB and I have one around 7 GB.
I want to play these videos online, so I tried FlowPlayer which seems to be broken with videos larger than 600MB.
is there any solution that will allow me to play these videos online? without converting to flv as I intend to allow downloads for these videos too.
I've been thinking of red5, but I don't know if it will work for this kind of videos nor if it works with the above-mentioned extensions + I am not familiar on how to make its applications and get direct downloads links (I don't want duplicated files for watch/download).
I will also need a timed captioning support like '.srt' files.
Your suggestions are highly appreciated.
You won't find a web-based player that supports all of the features you mention. However, you can get folks to install VLC's browser plugin. This is not ideal, as most folks won't do this, but it will do what you ask.
Otherwise, I suggest keeping the original available for download, and converting the videos to FLV as well. For the captions, you will need to convert the file to whatever format the player you end up using supports.
For the player, I recommend looking into Longtail.

generate images from swf

Is there any library/module available with which i can generate images from a swf file?
The problem i am trying to solve is: I want to create a pdf from a web page and i am having problems in doing that when the web page has swf (question in stackoverflow)
I am thinking if i am able to read a swf and write out an image, i will be able to solve the above the problem
Will appreciate your help, Thanks
In fact, that is quite a hard task. I've spent hours looking for a program that could fulfill such a task. However, I eventually only found one. It isn't open-source but would really help you I guess.
Flash Animation Source can output all frames of a SWF file. It uses a DirectShow filter to do so. Therefore, a Windows operating system is required should you not want to use WINE.
In short, you'll just need to install Flash Animation Source on your computer and then find a way to get DirectShow frames using your desired programming language. Everything else is actually quite easy. You tell Windows the directory and the name of your SWF file and it'll do the rest, thus delivering you with an image. And did you know DirectShow filters can deliver all frames of a video? Therefore, you can choose which one you'd like to have.
By the way, please don't try to find another way to get an image of your SWF file. Believe me, you won't find one. I have looked for an open-source program that fits my needs but all of them fail. You need to use the propriertary Adobe Flash player for your outputs. There is no other option as the open-source alternatives still need a lot of development to genuinely output the vector-based frame as it is.

PHP rotate video

I have my own video sharing app,
My question is... is there any library,script or something else, to help me in rotating videos whatever their file extension is?
Many peoples are uploading videos but sometimes i found video (guessing shared with iphones or mobile phones) and i see them horizontally instead of vertically...
Does anyone have any ideas how to rotate them dynamically?
Im not familiar with any "libraries" that will do that. I think your better bet would be to find a command-prompt-enabled video software package (like Any Video Converter [See Q7]) that PHP can execute via command prompt on the fly.
PHP doesn't do that, and there are no extensions that I know off, made for that purpose.
You can use ffmpeg to manipulate videos, by calling it from your scripts (see shell_execute() and such functions). Reading the ffmpeg documentation will help you figure what can (and can't) be done with that powerful tool.

Change MP3 frequency on the fly somehow?

Does anybody know a purely PHP based way to alter the frequency of an MP3 file?
I am on shared hosting with this, so installing ffmpeg or something similar is out of the question.
If this requires actually altering the audio data, then I guess it is not possible nor feasible to do with PHP, but I was thinking maybe this is just a header setting. I don't know.
Background:
A client's website is utilizing a Flash based MP3 player to play some audio.
The client is producing the audio herself.
The trouble is that the tools that she is producing it with, and is familiar with, automatically produces MP3 files with a frequency of 48000hz, while some versions of Flash have trouble playing anything with a frequency differing from 44100khz. (See my related question here).
I would like to avoid adding yet another program to the already complex audio production process, and solve this on the web server end if possible.
I was thinking maybe this is just a header setting.
No. That is, you can probably change it in the header, if you don't mind your MP3s being played too slow or too fast with a shifted pitch.
If you want it to sound the same, you will need to re-encode. Decoding to WAV (or raw samples), resampling, then re-encoding is a possibility, and probably your only one.
Maybe the way MP3 works allows for a shortcut (like JPEG allowing for lossless rotation), but I am unaware of any such methods.

Categories