title: Avconv on Raspberry Pi to record RTSP h264 stream from AXIS camera doesn't close session
body: <p>We have a cron job running on a Raspberry Pi set to record an h264 stream from an Axis M3026 camera.  The job runs at various intervals and will record a 15 second video about 4 times an hour throughout the day.</p>
  
  <pre><code>avconv -rtsp_transport tcp -i rtsp://root:xxxxxxxx@192.168.1.59/axis-media/media.amp -t 15 -an -f  mp4 -vcodec copy -y  /home/pi/Vid-0159.mp4
  </code></pre>
  
  <p>On startup, the job works fine.  It records the first 7-10 clips, but then the Axis becomes unresponsive and it skips a job.  Typically when the next request is made, the Axis is back online and streaming continues for another few jobs.</p>
  
  <p>Looking through the camera logs, it appears that after the 15 recording duration is completed, the Axis camera isn't tearing down the RTSP stream.</p>
  
  <p>We've opened a case with Axis support, who have been less than helpful.  Their suggestion was to set the recording parameters on the camera (set the duration and time interval on the camera itself).  We don't want to have to pre-configure every camera and adjust to every new Axis software release.</p>
  
  <p>If we swap out the Axis with a Samsung camera, the above command works perfectly continuously without issue.</p>
  
  <p>Any suggestions on how we can get the avconv to properly teardown the stream? </p>
  
  <p>--
  Chuck</p>