| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Pass Resources Between PHP Scripts; Or a better way? | |
|---|---|
| Tweet Topic Started: Apr 10 2011, 03:43 PM (1,845 Views) | |
| IceMetalPunk | Apr 10 2011, 03:43 PM Post #1 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Hey, everyone . I know it's been a while since I've been around here, but I'm back (for now) and I need some PHP help .I've recently been starting work with FFmpeg, using it to convert videos into .flv's so I can play them with one of many freeware Flash video players. I want to be able to do this via PHP; for some reason I wasn't able to get it working with exec(). However, I did get it working with popen() to open a process. This is the code I started with:
That works and correctly converts the files. However, it waits until the conversion is complete (or rather, until the process terminates) before outputting anything, creating major hanging. My ingenious solution to this was to put some AJAX Javascript on the page which would pass the process handle to another PHP file to fread() the data (freading the data does work, by the way, hence the 2>&1 redirection) and update the status on the page. Here's the problem: how do I pass a resource ID from one PHP script to another? When I tried echo'ing the handle to the page, it converts it to a string "resource ID #2", which obviously doesn't work. So how do I do this? Or, is there a better way to run a process in the background and still get updates about its progress? Specifically, FFmpeg. I've seen php-ffmpeg, but there are no instructions on how to install it on Windows (or rather, on any non-Linus system). -IMP
|
![]() |
|
| IceMetalPunk | Apr 16 2011, 01:57 AM Post #2 |
|
We are all IMPerfect. Be proud!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Nevermind. Turns out I can track progress within the same script. I just needed to use flush() and ob_flush() one after another to flush the output to the browser. Don't know why either alone doesn't work, but together they do, so I'm good .If anyone wants to see what I've done with it, head over to my website: http://imperfectdesigns.dyndns.org and click on the Video Service Demo link. -IMP
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
10:14 AM Jul 11
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)
. I know it's been a while since I've been around here, but I'm back (for now) and I need some PHP help
.



10:14 AM Jul 11