Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3346032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:15:20+00:00 2026-05-18T01:15:20+00:00

I’m trying to execute a command in the background using PHP so the web

  • 0

I’m trying to execute a command in the background using PHP so the web application can continue to load, but having no luck so far.

The command is for a live streaming application, so involves the following:

<stream pre-process> | ffmpeg <options> | <stream segmenter>

I can stick the above in a script and execute it fine in the background in bash with &, but this doesn’t work in PHP. I also tried using nohup before, and “nohup & echo $!”, but no luck.

I am also piping all of stderr to /dev/null, and I can verify in apache logs that there is no output generated when I execute the command (but it is executing).

Some example code below.. what I have after this code doesn’t execute until this finishes, which is a long time.

function streamVid ($mid, $width, $height, $br) {
    $cdir = "./temp";
    $zmstrm = "zmstreamer -m ".$mid." 2> /dev/null";
    $seg = "segmenter - 3 ".$cdir."/sample_".$mid." ".$cdir."/stream_".$mid.".m3u8 ./ 2>/dev/null";
    $ffparms = "-f mpegts -analyzeduration 0 -acodec copy -s ".$width."x".$height."   -vcodec libx264 -b ".$br." -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate ".$br." -bufsize ".$br." -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -analyzeduration 0 -async 2 - 2> /dev/null";
    $url = $zmstrm . " | ffmpeg -t 10 -analyzeduration 0 -i - ". $ffparms . " | " . $seg;
    shell_exec("nohup ". $url." & echo $!");       
    ob_flush();
    flush();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:15:21+00:00Added an answer on May 18, 2026 at 1:15 am

    If you need to stream out the result of an operation, use the system or passthru methods, or use popen or proc_open to have full control over the input and output of the process.

    In general, the PHP scripts which are triggered by your web server are meant to generate a page and exit. They are not the best place to do background tasks such as video encoding, your web server will impost a limit on the programs execution time, and it will be difficult to get status information from your browser (it will appear to hang).

    Your best bet is to create a separate daemon process in a language like Python (or PHP) which will run on your computer. When your web scripts need to transcode a video, they can place the necessary information in a database or file which can be polled by the daemon process. The daemon process can also update the database with status information.

    In general, your web served pages should be as “non-blocking” as is possible, meaning if something is going to take more than a second or two, do it in the background and create pages on your site to allow the user to view the operations status and manipulate it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.