.mov file to .flv file conversion issue for ffmpeg using PHP - php

Is there any possible way to convert .mov file to .flv file conversion issue for ffmpeg using PHP. If yes, kindly let me know how to do?
Thanks in advance,
Fero

I agree with Kemo, though following the conventions of Stackoverflow, I'll offer the key bit provided by the link given:
ffmpeg -i <filename.mpg> -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6 <filename.flv>
I often transcode with ffmpeg and I don't ever bother to give all those flags, so you may find my typical use works well enough for you too:
ffmpeg -i inputFile.mov outputFile.flv
That's supposed to just change container formats and it tries to keep everything else as close as possible. I just did that and it seemed to work fine, though I'm uploading my flv somewhere it I'm having an issue, but that's probably totally unrelated to ffmpeg. Any tips?

Related

How to mix/merge 2 mp3 files in PHP?

I need a tool to join 2 mp3 files in 1.
The first file ( background ) will be some sound ( music, submitted by user ),
second file will be a machine (google) speaking text, which was submitted ( by user ).
In output I need a single mp3 file, with background music and speaking robot text playing together.
I can't really find any PHP standalone solution like some library or something like, only shell commands atc.
So are there some libraries?
or there's some unique shell command which works on all OS to combine files?
Or how do I complete the task?
Based off of this question, you should be able to install FFMPEG onto your server (hopefully not a shared host?) and use
//Reduce background volume, assuming it's input2.mp3
shell_exec('ffmpeg -i input2.mp3 -af "volume=0.3" backround.wav');
//Merge the two
shell_exec('ffmpeg -y -i input1.mp3 -i background.wav -filter_complex amerge -c:a libmp3lame -q:a 4 output.mp3');
Then you can simply serve up the output.mp3 file. If this is being performed by PHP running under apache (or other web host, instead of CLI) you'll need to make sure your www-data user has read access to the input files, and write access to the output directory.
All your temporary output, like the background, should be saved as .wav, and only converted back to .mp3 for the final output. Recompressing the audio at each step may result in a very poor final output.
I am making assumptions about how FFMPEG works here, so you may need to consult the documentation for it in order to build a functioning or more efficient set of commands.
You can simply do this
file_put_contents('combined.mp3',
file_get_contents('file1.mp3') .
file_get_contents('file2.mp3'));

Does PHP have voice conversion library for 3gpp to mp4

I need to convert an upload voice file from 3gpp format to mp4 format in PHP server code.
I googled but there seems no conversion library for this purpose. Can I do that in PHP and is there exist any library for it?
Thanks
AFAIK php don't have any library for this purposes, but you can always use ffmpeg for conversions:
ffmpeg -i test.3gp -sameq -ab 64k -ar 44100 test.mp4
Someone asked about how to convert 3gp to mp4 in the official forums, so you can take a look: http://ffmpeg-users.933282.n4.nabble.com/3gp-to-mp4-td942632.html (the example has been taken from there)

PHP Script for FFMPEG conversion

Not been programming for long, so go easy.
Basically I'm attempting to write a PHP script that'll be able to automatically convert a folder full of .mp4's for me, and make them .flv's. This will be done for my entire TV collection (which is quite large) to allow for streaming over my local network within browsers.
I've currently got the following code:
// Save video files into an array
$vid = glob("../../*.mp4");
// Open text file in write mode
$fp=fopen("test.txt","w+");
// Write contents of array to file
foreach($vid as $key => $value){
fwrite($fp,$value."\n");
}
This is taking all of the mp4 files within the folder, and saving their filenames into a text file. The next step I need to take is to read each line, one by one, and perform an FFMPEG command on them until each line has been completed.
Any idea how I can achieve this? I know I'll have to use shell_exec somehow, but I've never used this before, and I'm a little bit stuck as to what to do next.
Thanks for any help
Here is the ffmpeg command line to convert all the mp4 files in a directory to flv files
for i in *.mp4; do ffmpeg -i $i -ar 44100 $i.flv; done
Here it is in php
// Change directory to the directory of the videos
chdir('../..');
// Run the command
exec('for i in *.mp4; do ffmpeg -i $i -ar 44100 $i.flv; done');

Parsing Thumbcache in PHP

I always wondered if it was possible to parse the thumbs db files located in Windows 7 in:
C:\Users\%userdata%\AppData\Local\Microsoft\Windows\Explorer
In Windows XP they used to be located in each folder, but I assume I would have to traverse these to find the directory I want, etc. I'm aware there are ways to generate thumbnails using ffmpeg and such, but want to find a way in PHP to parse that db file since Windows has already generated thumbs for me. It's not in plain text (which I was hoping for).
you could use a parser like vinetto via php's exec
I gave up trying to do parse these out and instead used ffmpeg to generate thumbs like this. The system call takes the 10th frame of the all the mp4 videos in my recordings folder and saves it as a 320x240 image and as the filename.jpg. I had a bunch of videos so I had to increase the max execution time of PHP to handle it.
foreach (glob("F:\\Recordings\\*.mp4") as $filename) {
$path = pathinfo($filename);
system("c:\\ffmpeg\\bin\\ffmpeg.exe -itsoffset -10 -i \"$filename\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 \"".$path['filename'].".jpg\"");
}

mp3 to flv on the server side how to?

I googled it for a long time, all I found was the ffmpeg php api, and a site called mp32tube .. now I was to have the exact same functionality of mp32tube I want to give my users the ability to upload an mp3 add a picture, then compile an FLV on the server that contains the picture and the mp3...
the rest I can do, like uploading the video to youtube, it's simple with their own API ..
can anyone please guide me to something that automatically does this on my server? (a centos powered VPS)
thank you very much.
Rami
You should read FAQ first.
http://www.ffmpeg.org/faq.html#SEC14
then to add sound you may try;
ffmpeg -ar 22050 -ab 128k -i song.mp3 -i videoHaveNoSound.flv VideoWithSound.flv
Let me know the result.
in addition:
you findout a shorter way;
ffmpeg -r 12 -b 1800 -i img.jpg -i yourSound.mp3 -acodec copy outVideo.flv
There is no "automatic" way to do this. You'll have to have the user upload the 2 pieces of data, then run them through ffmpeg. There is tons of documentation for ffmpeg out there, just research the command you'll need to run, test it outside of php first, then once you get it working, implement it in your script. After its gone through ffmpeg, delete the files used for creation, and let them download the resulting flv.

Categories