Input redirection script

Hi,

#!/bin/bash

while [ 1 ];
do
  rm -f /tmp/pipe
  mkfifo /tmp/pipe
 ./yuv4mpeg_to_v4l2 < /tmp/pipe &
  mplayer tom_and_jerry.mp4 -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe
  sleep 65;
done

When I run this - after mplayer finishes playing video it says - Exiting... (End of file) hangs!

How can I make it to continue to run in while loop ?

Thanks!

I'm not sure I'm following what is going on here, but I think you want something more like:

#!/bin/bash
rm -f /tmp/pipe
mkfifo /tmp/pipe
./yuv4mpeg_to_v4l2 < /tmp/pipe &
while [ 1 ]
do
  mplayer tom_and_jerry.mp4 -vf scale=480:360 -vo yuv4mpeg:file=/tmp/pipe
  sleep 65;
done > /tmp/pipe

This assumes that yuv4mpeg_to_v4l2 is reading data from standard input and feeding it into your display device while mplayer is converting tom_and_jerry.mp4 into a format that yuv4mpeg_to_v4l2 reads and directs its output to the file named by the -vo yuv4mpeg:file=pathname option's option argument.

It also assumes that mplayer does not write anything to its standard output (and that nothing else inside the while loop writes anything to standard output). The FIFO has to be kept open by something on both the read end (which is being done by yuv4mpeg_to_v4l2 ) and on the write end (which I am doing with the redirection on the while loop). If mplayer is the only thing writing to the FIFO, the write end will close after mplayer finishes the conversion once and yuv4mpeg_to_v4l2 will see an EOF.

Why using redirection for playing the video?
Also, having a sleep duration of over a minute, COULD cause the 'hang' (actually just a delay) at its end, as it is waiting before writing the actualy EOF-bit of the video into the FIFO, where it would read and end then.

To just play the video, this should suffice:

mplayer -vf scale=480:360 tom_and_jerry.mp4 

Either way, i'm confused by ./yuv4mpeg_to_v4l2 as the last part indicates 'video 4 linux (2)', or otherwise a transformation of the mp4 to an mpeg video.
But after all, this just seems like another tempfile, so you dont read from the pipe directly.

But (my) question is, why read from a non-fifo file, when redirectig output to fifo, but redirecting the fifo its output to another (regular) output file?

Dont have mplayer installed, but with ffplay there is an option called: -autoexit

Hope this helps