LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading WMV file as it is being written

I am using a VideoCapture control to acquire video in the WMV format. While this file is written, I need to read it for transmission to  a remote device.
fopen, the standard C function fails to open the file, ReadFile, the LabWindows function seems to read incorrect data at times. For example, the first packet of 30 is correct, the second and third are incorrect.
However, if I run the Winodws medial player, that seems to read and play the file correctly. I would appreciate if someone who has solved this problem can reply to this post.
 
0 Kudos
Message 1 of 2
(3,034 Views)
Hello trillianguy,

The first thing I would like to address is the use of the fopen function.  When you are using the fopen, what is the option you are using to open the file.  I believe that the same file cannot be opened in write mode by two programs, I would recomend in CVI using fopen with an option to open the file in read mode only.  Also, make sure that you open it for binary data -- the data stored in the WMV file is propritary to Windows and cannot be interpreted by CVI other than by its raw data.  This somewhat leads us to our next topic which is about the use of the CVI ReadFile function.  How are you checking the data in the ReadFile is incorrect?  You mention packets -- is the data from the ReadFile being sent to the remote device and opened with a WMV video player on the remote device?  I noticed something interesting in the documentation for the ReadFile function

"If you open the file in ASCII mode, ReadFile counts each carriage return/linefeed (CR/LF) combination read as one character because the pair is translated into an LF when ReadFile stores it in the buffer."

This leads me to belive that if opened in ASCII mode, this function will actually modify the data coming into the buffer when it encounters a special character.

Thanks for posting, and please let me know if you have any other questions.

Travis M
Applications Engineer
National Instruments

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 2
(3,016 Views)