How to run feeding each other processes simultaneously?

Hello,
I need to run multiple shell processes simultaneously and output of the first process shall be the input of the second process but first process is never ending so both should be running in parallel. I do not wish to wait the end of the first process. I am under ubuntu 16.04.

First_process.sh: It is the same with wget , downloads 2389.ts file and put it into directory.

ffmpeg -y -re -i http://xx.yy.zz/2389.ts ...some_codes_here.... -f mpegts 2389.ts 

Second_process.sh:

tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000

Not giving expected method:

First_process.sh &
Second_process.sh & 

This way, I can't get expected output, because first process is never ending. and second process will always be kept waiting by the first one.

After some research, I found below algorithm but could not make it working.

list.txt:

http://xx.yy.zz/2389.ts

final.sh

#!/bin/bash
cust_func(){
  ffmpeg -y -re -i "$1" .some_codes_here.. -f mpegts 2389.ts
}
while IFS= read -r url
do
        cust_func "$url" &
tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000
done < list.txt
wait
echo "Finished."

But not working... Would Xarg command be a solution ?

Thank you
Boris

Edit:
Sorted by this way:

ffmpeg -y -re -i http://xx.yy.zz/2389.ts .some_codes_here.. -f mpegts 2389.ts > output.log 2>&1 < /dev/null &
tsplay 2389.ts -loop -maxnowait 2 -waitfor 500 -udp 234.5.5.5:5000

Thanks
Boris

I'd think this is what pipelines ( command1 | command2 ) are for.

Hello Rudic,
I agree with you but unfortunately not working like this way:

command 1 | command2 

Somehow, command2 is waiting for the first command to be finished.
Redirection to /dev/null method is okay.

Kind regards
Boris

Probably because your commands aren't written to work that way.

wget must write to a pipe, not a file, second command must read from pipe, not file, etc, etc, etc.

For wget, that means -O - to make it write to standard output. not sure what that means for ffmpeg, etc. If - doesn't work as an input/output filenames, /dev/stdin and /dev/stdout might.

1 Like