LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2008, 07:37 AM   #1
bwashed
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Rep: Reputation: 0
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
Ideally I would be having some kind of
Code:
mkfifo --buffer=5GB
-command, where the FIFO has to be filled before data comes out at the other end.

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.
 
Old 10-16-2008, 09:44 AM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
using && between two commands, waits for the previous command to complete successfully before starting the next.
 
Old 10-16-2008, 11:40 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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)
 
Old 10-16-2008, 12:45 PM   #4
bwashed
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
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
And then in the second terminal 45sec later:
Code:
rawplay <temp.dv
By doing that there will be two videos running, one of which is 45 sec delayed and we can easily switch between them with alt-tab. But there are of course drawbacks:
  • Both windows play the sound at the same time
  • temp.dv is constantly growing
  • There are two cpu-heavy rawplay instances at the same time.
  • I don't know how to switch between the two windows over network or from a program
 
Old 10-16-2008, 12:56 PM   #5
bwashed
LQ Newbie
 
Registered: Oct 2008
Posts: 4

Original Poster
Rep: Reputation: 0
@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.
 
Old 10-16-2008, 01:10 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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)
 
Old 08-08-2014, 11:39 AM   #7
Sepero
Member
 
Registered: Jul 2004
Location: Tampa, Florida, USA
Distribution: Ubuntu
Posts: 734
Blog Entries: 1

Rep: Reputation: 33
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
 
1 members found this post helpful.
Old 08-09-2014, 06:30 AM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
Quote:
Originally Posted by Sepero View Post
Apologies for resurrecting this thread ...
It's not "resurrecting a thread" if you find an important new discovery. Threads from many years past are regularly searched-for by people who are encountering problems (again) now. Thanks.
 
Old 08-15-2014, 09:25 PM   #9
BowCatShot
LQ Newbie
 
Registered: Aug 2014
Posts: 15

Rep: Reputation: Disabled
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
 
1 members found this post helpful.
Old 08-15-2014, 09:51 PM   #10
slugman
Member
 
Registered: Jun 2010
Location: AZ
Distribution: Slackware
Posts: 106

Rep: Reputation: 1
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

Last edited by slugman; 08-15-2014 at 09:57 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
any way to increase CD-ROM buffer, increase spindown delay, XMMS buffer r00tb33r Linux - Hardware 5 06-12-2009 12:10 AM
LXer: Why Big Compute and Big Storage will meet Big Pipe at the Last Mile LXer Syndicated Linux News 0 12-23-2007 01:20 PM
Clonning data, fifo/pipe/tee problem : Resource temporarily unavailable rmarco Linux - General 2 05-05-2005 11:15 AM
Creating FIFO messaege buffer using shared memory indika7777 Programming 1 03-27-2004 05:14 AM
How do i change FIFO-Buffer on SuSE 7.0 ?? Problemer Linux - Networking 0 01-10-2002 08:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration