Need a big buffer to introduce delay in a pipe. (FIFO)
Hi,
I've been scratching my head to try to figure out how to achieve something like the following: Code:
some_video_output | my_big_buffer | delayed_video_output Code:
mkfifo --buffer=5GB I'm sure there is an easy way to do this, but I'm fairly new to linux and I just can't figure it out so I'd be terribly happy for some advice. |
using && between two commands, waits for the previous command to complete successfully before starting the next.
|
Why not just use video file, I don't see the advantage of a "buffered pipe", especially if you want to fill the buffer completly (eg, it becomes a full video file)
|
Thanks for the replies
I'm using dvgrab to catch live video from a camcorder and rawplay to show it on screen. Eventually what I want to achieve is a setup where I can press a button (or send a network signal or sth) so that the video instantly jumps back a fixed amount of seconds (45 sec in my case). Much like a replay of a goal in a sports match. The main problem has been to figure out how to save those 45 seconds in a proper way. That's where I thought it made sense to store in a file in a FIFO kind of way.. A mock-up way of achieving what I want is to use two terminals. In the first terminal, issue the following command: Code:
dvgrab -|tee temp.dv|rawplay Code:
rawplay <temp.dv
|
@keefaz: Do you mean why don't I just use a regular file instead of FIFO? If it's easier just using a regular file I don't mind that at all. I was just hoping to keep the buffer in RAM to keep diskload down and not having to worry about HD space. But not a big issue.
|
I would search on video player side, try to find one video player that could use a large buffer
(mplayer with -rawvideo would work for watching raw video but no buffer big enough to scroll back 45sec I am afraid) |
Apologies for resurrecting this thread, but I was also trying to solve this problem. Here's the solution for 5 gigabyte buffer. Use the program `pv`.
Code:
some_video_output | pv -5g | delayed_video_output |
Quote:
|
Would something like this work?
t=$(date "+%m%d%H%M.%S" --date="now + 45 seconds") at -t $t at> rawplay < temp.dv at> <EOT> #entered by pressing ctl-D dvgrab -|tee temp.dv|rawplay |
If I understood this correctly, you simply need to wait 45 seconds before the output temp.dv to be written, before you can re-direct temp.dv back into rawplay for input?
dvgrab -|tee temp.dv|rawplay; sleep 45 && rawplay < temp.dv The semicolon will allow the sleep command to run concurrently with the first. The && operator will succeed after 45s and then run the next command. I am a little unsure if this is the way you want to proceed however. I've had bad experiences of using a input file that is currently being written too. Perhaps copy it and running the 2nd command off of the copy? And thanks Sepero and BowCatShot, I learned both the PV and AT commands! Diego - http://en.wikipedia.org/wiki/Tee_(command) - http://www.tldp.org/LDP/abs/html/io-redirection.html - http://tldp.org/LDP/abs/html/special-chars.html |
All times are GMT -5. The time now is 04:49 PM. |