<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>openRTSP saving to a microSD card</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Hi. A brain-teaser for your coffee break... (but I don't know the solution!)...</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I'm using openRTSP to read incoming streaming mpeg4 video over ethernet and store it on a micro SD card. The aim is to then download the mp4 file(s) over the USB port onto a host pc for subsequent viewing. The input video stream comes from our thermal imaging camera: 320x240 at 10fps. The Linux target is an ARM-based 3rd party embedded card with ethernet, SD card and USB connections.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">It's &quot;so nearly&quot; working! I can successfully record video onto the micro SD card and play it back reliably... which proves it's all possible. The devil is in the detail though...</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Once I've started openRTSP running in the background from the command line it seems to be that: </FONT>
</P>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">IF (the recording is =&gt; 2 minutes long) then it is successfully saved onto the micro SD card... I can turn off the camera straight after stopping the recording and &quot;all is well&quot; when I come to play back the file over USB</FONT></P>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">ELSE a short recording (&lt; 2 minutes) is only successfully saved onto the micro SD card if I wait about 2 minutes from starting the recording to subsequently stopping it and turning off the camera.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">&nbsp;</FONT>

<BR><FONT SIZE=2 FACE="Arial">The only code I've written is a short bit of C that establishes if the record button has been pressed, a bit of filename control and ethernet link checking. Oh, and the following command line that gets run if (and only if) the record button has been pressed and the ethernet is up and running (established by a successful &quot;ping&quot;):</FONT></P>

<P><FONT SIZE=2 FACE="Arial">strcpy(start_command_str,&quot;\n&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(start_command_str, &quot;./openRTSP -V -b 50000 -4 -w 320 -h 240 -f 10 rtsp://10.133.1.20:554/tic04 &gt;&nbsp; &quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(start_command_str, &quot;/mnt/uSDcard/&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(start_command_str, new_filename);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(start_command_str,&quot; &amp;\n&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">system(start_command);</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">On further investigation it appears that the micro SD card is &quot;somehow&quot; put into<B> read only</B> mode for about 2 minutes from the point at which I invoke openRSTP. I can't even write to a text file on the micro SD card during that magic 2 minute period.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Saying that though, in order to be able to stop the recording session I redirect the output of &quot;ps&quot; to a text file (after about 1 second) and use fscanf to find the Process ID of the existing openRTSP process from this file. So, creating this file within the 2 minutes worked but I can't seem to write to any others. I fopen it as readonly and fclose it once I've found the Process ID (</FONT><FONT COLOR="#008000" SIZE=2 FACE="Arial">pid_str</FONT><FONT SIZE=2 FACE="Arial">). Confusing.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Once the record button has been pressed to stop recording (it's polled many times a second) I issue the following :</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">strcpy(stop_command_str,&quot;kill -HUP &quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(stop_command_str, </FONT><FONT COLOR="#008000" SIZE=2 FACE="Arial">pid_str</FONT><FONT SIZE=2 FACE="Arial">);</FONT>

<BR><FONT SIZE=2 FACE="Arial">strcat(stop_command_str, &quot; \n&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">system(stop_command_str);</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">This all seems to work fine. It's the &quot;2 minute thing&quot; that's getting me. I haven't got the luxury of making software changes on the camera. I'd really appreciate any help you may be able to offer and I'm more than happy to provide more details on the implementation, background, output logs etc. I'm not and expert in C or Linux - but I'm not usually defeated.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Many thanks and I look forward to hearing from you soon.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Alan</FONT>
</P>
<BR>


<BR>
Sent by E2V TECHNOLOGIES PLC or a member of the E2V group of companies. <BR>
A company registered in England and Wales. <BR>
Company number; 04439718. <BR>
Registered address; 106 Waterhouse Lane, Chelmsford, Essex, CM1 2QU, UK.<BR>
<BR>
______________________________________________________<BR>
________________<BR>
This email has been scanned by the MessageLabs Email Security System.<BR>
For more information please visit http://www.messagelabs.com/email <BR>
______________________________________________________________________<BR>
</BODY>
</HTML>