Find the answer to your Linux question:
Results 1 to 2 of 2
In shell, I execute "./ffmpeg -f h264 - | xxx" Now I hope use execl function to execute above operations, I call execl("/bin/sh", "sh", "-c", "./ffmpeg -f h264 - | ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    2

    how can I use pipe in execl function?

    In shell, I execute "./ffmpeg -f h264 - | xxx"
    Now I hope use execl function to execute above operations,
    I call execl("/bin/sh", "sh", "-c", "./ffmpeg -f h264 - | xxx");
    but ffmpeg doesn't work, it seems that "|" pipe don't work.
    how could I solve this?

    Thanks.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    The pipe operator is a shell thing and it separates two commands. So the pipe and what follows it are not an argument to the first command and can't be handled by an exec function inside a program.

    It is possible to get a program to launch two other programs piped together, but it's quite complicated. You would have to

    1) create the pipe in the parent program with the read end in 0 and the write end in 1
    2) fork off the first child
    3) in the child, close the read end of the pipe and execl ffmpeg
    4) fork off a second child in the parent program
    5) close the write end of the pipe in the child and execl xxx.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...