1

I'm trying to make a video recorder, to capture video of my partners seizures for her doctor. Because they're unpredictable, the system needs to be recording constantly, saving as 15 minute clips for example.

The system is actually debian but I think this is as good a place as any to ask.

I have raw video in h264 from raspivid and sound from a USB microphone. Raspivid is functioning and the USB microphone is capturing sound when I've tested with arecord, however any files I get with avconv don't play, they simply display a frame when opened, then finish.

raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - |
avconv -y -ac 2 -f alsa -ar 16000 -i plughw:1  -r 30 -i pipe:0  -filter_complex asyncts=compensate=1
-c:a ac3 -c:v copy -t 300 file%04d.mkv

Additional info:

pi@raspberrypi:~ $ raspivid -t 10000 -rot 270 -w 1280 -h 720 -b 3500000 -fps 30 -n -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv
ffmpeg version N-82665-gbda6f29 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Raspbian 4.9.2-10)
  configuration: --pkg-config-flags=--static --extra-cflags='-fPIC -I/root/ffmpeg_build/include' --extra-ldflags=-L/root/ffmpeg_build/lib --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-pic --extra-ldexeflags=-pie --enable-shared
  libavutil      55. 41.101 / 55. 41.101
  libavcodec     57. 66.108 / 57. 66.108
  libavformat    57. 58.101 / 57. 58.101
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 67.100 /  6. 67.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'plughw:1':
  Duration: N/A, start: 1480449777.042259, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Input #1, h264, from 'pipe:0':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: h264 (High), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Output #0, segment, to 'file%04d.mkv':
  Metadata:
    encoder         : Lavf57.58.101
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, q=2-31, 25 fps, 25 tbr, 1k tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
[alsa @ 0x80e062f0] ALSA buffer xrun.
[segment @ 0x80e8de90] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[h264 @ 0x80e17620] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:40.88 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:45.77 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:50.28 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:04:55.84 bitrate=N/A speed=1.01x    
[alsa @ 0x80e062f0] ALSA buffer xrun.ime=00:17:48.47 bitrate=N/A speed=   1x    

This goes on indefinitely. I did get one file from it, after trying different combinations of keys to terminate the command, it finished some time after I gave up, the resultant file was 10s of video and then numerous minutes of the last frame with continuing audio.

migrated from askubuntu.com Nov 21 '16 at 12:20

This question came from our site for Ubuntu users and developers.

  • Debian version is Jessie (raspbian), players were Omxplayer and VLC, on 2 separate devices after initially assuming the Raspberry Pi was the playback issue – ShatPank Nov 17 '16 at 19:06
  • Updated original post. wasn't certain between 'asyncts=compensate=1' or 'compensate=1' but identical output from both. – ShatPank Nov 19 '16 at 21:05
  • Sorry, been out of the house for 2 days. ALSA is not in the list of devices, so i'm guessing the compiled file I found wasn't the time saver I was hoping for. I shall get ffmpeg installed via backports (doesn't sound so simple with Raspbian) and run the command again to see what happens. – ShatPank Nov 23 '16 at 15:40
  • So ffmpeg installed via backports, command simply throws out Illegal Instruction – ShatPank Nov 24 '16 at 1:43
  • This got migrated to Unix & Linux so not sure if you've ceased to be notified with comments @LordNeckbeard – ShatPank Nov 26 '16 at 23:32
0

You can use the segment muxer:

raspivid <options> -o - | ffmpeg -f alsa -i plughw:1 -i pipe:0 -codec copy -f segment -segment_time 900 file%04d.mkv
  • It seems as though audio is working OK, but it appears as though it continues to just add more and more audio to the file currently. The command spit's out some issues about time stamps, so I'm assuming its related. – ShatPank Nov 29 '16 at 20:50
  • Sorry, forgot to mention I'd updated the original post – ShatPank Nov 29 '16 at 23:27
  • @ShatPank Didn't realize you updated it. Is the command the same as my example? Does the output look and play fine despite the messages? – llogan Nov 30 '16 at 0:10
  • I shall check the file properly when I get back in, I was focusing on the video stopping at 10s (how long I'm running raspivid to test), but just realised the segment command may have been making 15 minute clips? In which case it may well have been working fine and I may have been focusing on a non issue. – ShatPank Nov 30 '16 at 14:10
  • I tried testing the file, issue seems to be that the most recent attempt has over written the one file I managed to get to complete, so it's just a corrupt file that wont open. Running the command again simply just continues indefinitely without completing (I left it for 40 mins one time) I haven't altered your command in any way other than to add the raspivid options. I did notice on the output above it says bitrate=N/A but I don't know if that's in any way relevant. – ShatPank Nov 30 '16 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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