Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am looking to understand how recording video (and audio) and playing it back in realtime work (on the same pc or over a network)? I understand for a file stored on the disk. You read it and play it back but in recoding, you don't know how long the file is, when it will end etc. Can someone explain it, preferably using some code (or psudocode)?


share|improve this question

closed as off topic by Walter, Ryathal, Yusubov, Tim Post, StuperUser Nov 1 '12 at 11:58

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

Rather than saving to a file, the data is sent to a stream. Rather than taking the data and storing it, the OS/whatever takes a bite of the data and an immediately sends it to... wherever. –  Philip Oct 31 '12 at 16:50
Why do you need the file size to play a file? You just need to find whether you've reached the end or not (unless you want to jump between positions or such, which doesn't make sense for real-time) And then ... a file is just a specialized stream ... and a stream can be a network stream or some other IPC mechanism or ... –  johannes Oct 31 '12 at 17:06

1 Answer 1

Okay here is about how it could work, in pseudocode:

1. record 1/100 seconds of media to a file
   on some very fast disk (think RAM disk)
2.1. play back recorded file from disk
2.2. in the same time, record
     next 1/100 seconds of media to next file
3. go to 2.1 above and repeat
   until stop button is pressed

As you may note, above playback goes with 2*(1/100) = 1/50 seconds delay, expecting that this is not noticeable for listener.

Above, step 2.1 assumes that you understand for a file stored on the disk as you mentioned. Approach like that - doing something more complicated based on what you already know - is called decomposition.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.