I've downloaded an installed a C complier for Windows. What do I need to do next?
Get video dimensions (width & height)
Collapse
X
-
-
Microsoft Visual C++ 2008 Express Edition. Thank you for all the time you're spending on this. I really do appreciate it.Comment
-
Anything for a fellow brit. ;)
Right. I think you may also need the re-distributable - don't worry, this one's a small download.
Now, to compile an extension, we need the PHP headers and the php5 library file. However, I'm assuming you downloaded the binary files from php.net, i.e., you didn't compile PHP yourself. If that is the case, we'll have to download the PHP source.
<break>
This can be quite hairy for a newcomer. You could, instead, find an ffmpeg binary that has already been compiled for windows, and then use one of the system functions in PHP to call the binary, as dlite922 suggested.
Now, we can either do the whole compile-from-source thing, or just use a pre-built binary. With the former, it's a tedious process and may also involve a PHP-upgrade or downgrade, depending on your current PHP version and what tags there are in the PHP SVN repository. Also, this would mean producing a new php.exe with either the php-ffmpeg extension statically compiled into the binary or compiled to a shared library (.dll). However, the benefits of this give you a well-defined PHP API to work with, as opposed to running the ffmpeg binary with command-line switches to get the desired output.
The second option is as simple as installing a compiled ffmpeg binary on your system, pointing your PATH environment variable to it, and then running system('ffmpeg -some -switches -etc); to get your desired functionality. Pros: simple to setup. Cons: no well-defined PHP API to use, involves using command line switches, etc.
Let me have a think of how this could be made easier.Comment
-
I've downloaded a Windows binary for ffmpeg to give my self a choice of what to do. The file extension is 7z. Does that sound right? I might have to use your second option but I'm a bit worried how it will affect the other websites on my server.Comment
-
I have had a think about this after being on holiday. I'm not too sure about ffmpef-php since the project is not up to date and there could be some problems with IMAP.
Would it help if you new my web server configuration details, or is there any other way to do this?
Is it possible to extract the funactionality of ffmpeg-php and put it into a php file?
Would the CLI method suggested by Dan work and if so would someone be able to help me through with that?Comment
-
Is they a way to do this with JavaScript? I'm total willing to use JavaScript if that will work. I just think the ffmpeg-php is getting to complicated more me (and from what I can make out, far to risky).Comment
-
Ok, I didn't read the entire thread, but I read enough. The ffmpeg option will work, and you shouldn't even need ffmpeg-php, regular shell-based ffmpeg will work (that is, if you have a Linux server...not sure about Windows).
I recently needed to find the length of multiple video files (over 100) and I wasn't about to do it manually, so I found an alternative:
Running the command (ffmpeg -i "videofile. mov" 2>&1) returns something like this:Code:function getDuration($videofile) { ob_start(); passthru("/usr/bin/ffmpeg -i \"". $videofile . "\" 2>&1"); $results = ob_get_contents(); ob_end_clean(); preg_match("#Duration: ([\d]{2}):([\d]{2}):([\d]{2}).([\d]{1,2}), start#si", $results, $match); $seconds = makeSeconds($match[1], $match[2], $match[3], $match[4]); return $seconds; }
You can see in my function that I used regular expressions to find the duration, you can do this with the dimensions as well. I don't want to figure out the regular expression right now, but you'd want to go after the Video: text, since it only occurs once in the output, then just iterate through until you find the dimensions, which in this case are 640x360.Code:FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al. configuration: --prefix=/usr --libdir=${prefix}/lib --shlibdir=${prefix}/lib --incdir=${prefix}/include/ffmpeg --enable-shared --enable-libmp3lame --enable-gpl --enable-libfaad --mandir=${prefix}/share/man --enable-libvorbis --enable-pthreads --enable-libfaac --enable-xvid --enable-libdts --enable-amr_nb --enable-amr_wb --enable-pp --enable-libogg --enable-libgsm --enable-x264 --enable-liba52 --enable-libtheora --extra-cflags=-Wall -g -fPIC -DPIC --cc=ccache cc --enable-swscaler libavutil version: 49.4.0 libavcodec version: 51.40.2 libavformat version: 51.11.0 built on Feb 4 2008 14:49:27, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'videofile.mov': Duration: 00:00:08.7, start: 0.000000, bitrate: 1483 kb/s Stream #0.0(eng): Video: svq3, yuv420p, 640x360, 29.97 fps(r) Stream #0.1(eng): Audio: mp3, 44100 Hz, stereo Must supply at least one output file
I hope this helps you out, it sure saved me a ton of time.Comment
-
This looks like it could be the answer I'll have a play on Monday (after a weekend's rest) and let you know how I get on.
Many thanks.Comment
-
Thanks for your help HaLo2FrEeEk. Is there anyone who knows if there is a shell based ffmpeg for Windows or how I can run one from Windows or am I going back to sqaure 1?Comment
-
I did a quick search and found this page:
You'll want to download the most recent build of ffmpeg. Is your Windows server your own computer, or are you at a hosting company? Are you on dedicated hosting or shared? You'll need to know these things, but ultimately you should be able to run the binary.
Basically, download the executable to a root folder, outside of the scope of the actual website, then use command prompt to use it. The code in PHP should be the same, exec().
I'm not absolutely 100% sure on this because I'm on a Linux server which has ffmpeg installed natively.Comment
-
-
I think I've found another solutuion.
I found this code
I don't know if this will get the information I want. Will this help me and if so, how do I get the Internet to talk to the command promt?Code:for filename in $(ls *mpg *avi) do mplayer -nosound -vo null -ss 03:00:00 -really-quiet -identify $filename echo -e "\n**************\n" done >>info.txt
Comment
Comment