picam
picam copied to clipboard
Issue with Microphone after 15-30 mins of use
Ever since I have installed the picam, I am getting about 15 minutes of good audio and visual stream. The system then goes into a mass write over and over suddenly out of the blue, writing to system-journal this, 40 times a second:
Jan 17 05:57:05 raspberrypi picam[595]: microphone error: wait for poll failed Jan 17 05:57:05 raspberrypi picam[595]: trying to recover from error
SDometimes it continues on like this forawhile and then suddenly starts again. Sometimes it never stops and I have to reboot. Usually it is writing this so much, it throws the load avg to 2 almost, locking up the machine.
FYI I have also tested it with another microphone, lasted a bit longer but around 20 minutes in, it just locks up writing that to log.
Could you please run the following command and post the results? This tests the SD card write speed by writing a 500 MB file.
$ dd if=/dev/zero of=~/test.tmp bs=500K count=1024
sorry to steal the thread, but since I'm also having the same issue, if it helps I will leave here the output of my system:
~/picam-1.4.1-binary $ dd if=/dev/zero of=~/test.tmp bs=500K count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 27.9073 s, 18.8 MB/s
I haven't done the symlinks on the hsm, do you think this would help?
@armadaazteca Hmm, 18.8 MB/s seems fine. Can you record audio with arecord
command without any problems? Symlinks might make a difference when picam is recording to a file.
I think I found the culprit. The sound card for some reason is disconnecting over and over, so I guess the polling fails during this disconnects and floods the logs with the error. I'm checking to see if the disconnects are due to some kind of power saving setting or an issue with the driver/kernel combination. I have tested the same sound card in a couple of raspberry pi 2s and I see the same entries on the message logs, just as FYI, these are the ones, I found this because the same thing happened with the wifi card, and after upgrading the firmware the issue stopped on the wifi USB device, but persist on the sound card:
Jan 19 05:35:35 raspberrypi kernel: [190887.149395] usb 1-1.2: USB disconnect, device number 6
Jan 19 05:35:35 raspberrypi kernel: [190887.467519] usb 1-1.2: new full-speed USB device number 7 using dwc_otg
Jan 19 05:35:35 raspberrypi kernel: [190887.569918] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=000c
Jan 19 05:35:35 raspberrypi kernel: [190887.569946] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
Jan 19 05:35:35 raspberrypi kernel: [190887.569963] usb 1-1.2: Product: C-Media USB Headphone Set
Jan 19 05:35:35 raspberrypi kernel: [190887.605545] input: C-Media USB Headphone Set as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.3/0003:0D8C:000C.0003/input/input3
Jan 19 05:35:35 raspberrypi kernel: [190887.658145] hid-generic 0003:0D8C:000C.0003: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-3f980000.usb-1.2/input3
Jan 19 05:35:55 raspberrypi kernel: [190907.120210] usb 1-1.2: USB disconnect, device number 7
Jan 19 05:35:55 raspberrypi kernel: [190907.437758] usb 1-1.2: new full-speed USB device number 8 using dwc_otg
Jan 19 05:35:55 raspberrypi kernel: [190907.540075] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=000c
Jan 19 05:35:55 raspberrypi kernel: [190907.540103] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
Jan 19 05:35:55 raspberrypi kernel: [190907.540120] usb 1-1.2: Product: C-Media USB Headphone Set
Jan 19 05:35:55 raspberrypi kernel: [190907.576072] input: C-Media USB Headphone Set as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.3/0003:0D8C:000C.0004/input/input4
Jan 19 05:35:55 raspberrypi kernel: [190907.628368] hid-generic 0003:0D8C:000C.0004: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-3f980000.usb-1.2/input3
Jan 19 05:36:35 raspberrypi kernel: [190947.317415] usb 1-1.2: USB disconnect, device number 8
Jan 19 05:36:35 raspberrypi kernel: [190947.638209] usb 1-1.2: new full-speed USB device number 9 using dwc_otg
Jan 19 05:36:35 raspberrypi kernel: [190947.740690] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=000c
Jan 19 05:36:35 raspberrypi kernel: [190947.740719] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
Jan 19 05:36:35 raspberrypi kernel: [190947.740736] usb 1-1.2: Product: C-Media USB Headphone Set
Jan 19 05:36:35 raspberrypi kernel: [190947.774538] input: C-Media USB Headphone Set as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.3/0003:0D8C:000C.0005/input/input5
Jan 19 05:36:36 raspberrypi kernel: [190947.828963] hid-generic 0003:0D8C:000C.0005: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-3f980000.usb-1.2/input3
@armadaazteca maybe it helps if you try to use a USB hub with an external power supply.
I don't have one, but I do have one of those cheap USB tester monitors, and I don't see the pi consuming even close to 1A (I'm using a 2A source), so I don't think this is the problem.
@armadaazteca Thanks this is the exact issue I am having as well. Where did you find "firmware" upgrades for the pi?
you can use these 2 commands
# Check firmware version
/opt/vc/bin/vcgencmd version
# Upgrade firmware
sudo rpi-update
Basically the firmware is taken from a repository in github, either from the master or the next branch. you need to make sure the update tool is updated, so first you can run:
sudo apt-get update rpi-update
Hey, I've got a similar problem. PiCam runs fine, sound is also working and synchronous to video. But after some time (usually some hours) the microphone error appears and I have to restart the program, or sometime even the raspberry pi.
I let PiCam run in verbose mode, with the following output:
pi@raspberrypi ~/picam $ ./picam --verbose -w 1920 -h 1080 --rotation 180 --fps 25 --alsadev hw:1,0 --time --timept 28 --timeformat "%a %d. %b %Y %H:%M:%S" --tcpout udp://192.168.178.2:1234
using AVC High Profile Level 4
warn: fps > 20 might not work properly when width and height is large.
Use lower --fps or use --vfr. If you still want to use this
configuration, see if picam keeps up with 25.0 fps using --verbose.
video_width=1920
video_height=1080
video_fps=25.000000
fr_q16=1638400
video_pts_step=3600
video_gop_size=25
video_rotation=180
video_hflip=0
video_vflip=0
video_bitrate=2000000
video_avc_profile=high
video_avc_level=4
video_qp_min=-1
video_qp_max=-1
video_qp_initial=-1
video_slice_dquant=-1
alsa_dev=hw:1,0
audio_channels=1
audio_sample_rate=48000
audio_bitrate=40000
audio_volume_multiply=1.000000
is_hlsout_enabled=0
is_hls_encryption_enabled=0
hls_encryption_key_uri=stream.key
hls_encryption_key=0x75b0a81de17487c88a47507a7e1fdf73
hls_encryption_iv=0x000102030405060708090a0b0c0d0e0f
hls_output_dir=/run/shm/video
rtsp_enabled=0
rtsp_video_control_path=/tmp/node_rtsp_rtmp_videoControl
rtsp_audio_control_path=/tmp/node_rtsp_rtmp_audioControl
rtsp_video_data_path=/tmp/node_rtsp_rtmp_videoData
rtsp_audio_data_path=/tmp/node_rtsp_rtmp_audioData
tcp_enabled=1
tcp_output_dest=udp://192.168.178.2:1234
auto_exposure_enabled=0
auto_exposure_threshold=5.000000
is_vfr_enabled=0
white_balance=auto
awb_red_gain=0.000000
awb_blue_gain=0.000000
metering=average
manual_exposure_compensation=0
exposure_compensation=0.000000
manual_exposure_aperture=0
exposure_aperture=0
manual_exposure_shutter_speed=0
exposure_shutter_speed=0
manual_exposure_sensitivity=0
exposure_sensitivity=0
min_fps=-1.000000
max_fps=-1.000000
is_timestamp_enabled=1
timestamp_format=%a %d. %b %Y %H:%M:%S
timestamp_layout=15
timestamp_horizontal_margin=10
timestamp_vertical_margin=10
is_timestamp_abs_pos_enabled=0
timestamp_pos_x=0
timestamp_pos_y=0
timestamp_text_align=1
timestamp_font_name=FreeMono:style=Bold
timestamp_font_file=
timestamp_font_face_index=(null)
timestamp_font_points=28.000000
timestamp_font_dpi=96
timestamp_color=ffffff
timestamp_stroke_color=000000
timestamp_stroke_width=1
timestamp_letter_spacing=0
is_preview_enabled=0
is_previewrect_enabled=0
preview_x=0
preview_y=0
preview_width=0
preview_height=0
preview_opacity=255
is_audio_preview_enabled=0
audio_preview_dev=plughw:0,0
record_buffer_keyframes=5
state_dir=state
hooks_dir=hooks
configuring devices
exposure mode: auto
setting exposure:
eMetering: 0
xEVCompensation: 0
nApertureFNumber: 0
bAutoAperture: 0
nShutterSpeedMsec: 0
bAutoShutterSpeed: 1
nSensitivity: 0
bAutoSensitivity: 1
Set video_encode state to idle
Enable port buffers for camera 71
Enable port buffers for video_encode 200
Enable port buffers for video_encode 201
Set camera state to executing
Set video_encode state to executing
opening ALSA device for capture: hw:1,0
final audio_channels: 1
sample_rate: 48000
nb_samples: 1024
sample_fmt: 1
audio_codec_ctx->channel_layout: 4
av_frame->channel_layout: 4
audio_codec_ctx->channels: 1
av_frame->channels: 0
allocated 2048 bytes for audio samples
audio_pts_step_base: 1920
actual sample rate=48000 dir=0
microphone: buffer size: 204800 frames (channels=1 buffer_size=2048 multiply=100)
microphone: setting period size to 1024
actual_period_size=1024 dir=0
audio capture device:
Hardware PCM card 1 'C-Media USB Headphone Set' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 204800
period_size : 1024
period_time : 21333
tstamp_mode : NONE
period_step : 1
avail_min : 1024
period_event : 0
start_threshold : 1
stop_threshold : 204800
silence_threshold: 0
silence_size : 0
boundary : 1677721600
appl_ptr : 0
hw_ptr : 0
start capturing video
waiting for the first video buffer
start capturing audio
[microphone started]capturing started
.[NAL7][NAL8].......................... 24.54 fps k=1 a-v=10080 c-a=39 u=0 d=0 pts=93600
.............vSPEED_UP(11280)............ 23.95 fps k=2 a-v=12210 c-a=-69 u=1 d=0 pts=185550
......................... 24.09 fps k=3 a-v=12540 c-a=-712 u=1 d=0 pts=291840
......................... 24.07 fps k=4 a-v=10950 c-a=628 u=1 d=0 pts=373050
......................... 24.03 fps k=5 a-v=11280 c-a=183 u=1 d=0 pts=466800
...
......................... 24.01 fps k=6466 a-v=26640 c-a=2576128 u=250 d=1 pts=606583920
......................... 24.07 fps k=6467 a-v=26970 c-a=2575616 u=250 d=1 pts=606677670
......................... 24.04 fps k=6468 a-v=27300 c-a=2575104 u=250 d=1 pts=606771420
......................... 24.08 fps k=6469 a-v=25710 c-a=2576448 u=250 d=1 pts=606865170
..................trying to recover from error
microphone error: buffer overrun
[microphone started]..trying to recover from error
microphone error: buffer overrun
[microphone started]..trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started].trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
...
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
microphone error: buffer overrun
[microphone started]trying to recover from error
.microphone error: buffer overrun
[microphone started]Killed
I'm running PiCam on an Raspberry Pi 2+ with newest Raspbian and latest Raspberry Firmware. The sounddevice is also an "C-Media Electronics, Inc. Audio Adapter".
Does anybody know how to solve the problem?
Thanks in advance! Niklas
+1. Also have C-Media Electronics, Inc. Audio Adapter
and same problem.
@iizukanao i have
524288000 bytes (524 MB) copied, 57.725 s, 9.1 MB/s
- which speed is minimum required?
I have same issue. I think it isn't power problem because my device has enough power.
@niklasdoerfler There is a hint in your console output.
warn: fps > 20 might not work properly when width and height is large.
Use lower --fps or use --vfr. If you still want to use this
configuration, see if picam keeps up with 25.0 fps using --verbose.
@Frodox It depends on the video bitrate, but generally that write speed is fine.
Still suffering from the buffer overrun
issue:
pi@phpwvl-cam:~ $ ./picam/picam --alsadev hw:0,0 --fps 25 --tcpout tcp://127.0.0.1:8181 --verbose
video_width=1280
video_height=720
video_fps=25.000000
fr_q16=1638400
video_pts_step=3600
video_gop_size=25
video_rotation=0
video_hflip=0
video_vflip=0
video_bitrate=2000000
video_avc_profile=constrained_baseline
video_avc_level=3.1
video_qp_min=-1
video_qp_max=-1
video_qp_initial=-1
video_slice_dquant=-1
alsa_dev=hw:0,0
audio_channels=1
audio_sample_rate=48000
audio_bitrate=40000
audio_volume_multiply=1.000000
is_hlsout_enabled=0
is_hls_encryption_enabled=0
hls_encryption_key_uri=stream.key
hls_encryption_key=0x75b0a81de17487c88a47507a7e1fdf73
hls_encryption_iv=0x000102030405060708090a0b0c0d0e0f
hls_output_dir=/run/shm/video
rtsp_enabled=0
rtsp_video_control_path=/tmp/node_rtsp_rtmp_videoControl
rtsp_audio_control_path=/tmp/node_rtsp_rtmp_audioControl
rtsp_video_data_path=/tmp/node_rtsp_rtmp_videoData
rtsp_audio_data_path=/tmp/node_rtsp_rtmp_audioData
tcp_enabled=1
tcp_output_dest=tcp://127.0.0.1:8181
auto_exposure_enabled=0
auto_exposure_threshold=5.000000
is_vfr_enabled=0
white_balance=auto
exposure_control=auto
awb_red_gain=0.000000
awb_blue_gain=0.000000
metering=average
manual_exposure_compensation=0
exposure_compensation=0.000000
manual_exposure_aperture=0
exposure_aperture=0
manual_exposure_shutter_speed=0
exposure_shutter_speed=0
manual_exposure_sensitivity=0
exposure_sensitivity=0
roi_left=0.000000
roi_top=0.000000
roi_width=1.000000
roi_height=1.000000
min_fps=-1.000000
max_fps=-1.000000
is_timestamp_enabled=0
timestamp_format=%a %b %d %l:%M:%S %p
timestamp_layout=15
timestamp_horizontal_margin=10
timestamp_vertical_margin=10
is_timestamp_abs_pos_enabled=0
timestamp_pos_x=0
timestamp_pos_y=0
timestamp_text_align=1
timestamp_font_name=FreeMono:style=Bold
timestamp_font_file=
timestamp_font_face_index=(null)
timestamp_font_points=14.000000
timestamp_font_dpi=96
timestamp_color=ffffff
timestamp_stroke_color=000000
timestamp_stroke_width=1
timestamp_letter_spacing=0
is_preview_enabled=0
is_previewrect_enabled=0
preview_x=0
preview_y=0
preview_width=0
preview_height=0
preview_opacity=255
blank_background_color=0x0
is_audio_preview_enabled=0
audio_preview_dev=plughw:0,0
record_buffer_keyframes=5
state_dir=state
hooks_dir=hooks
configuring devices
exposure control: auto
setting exposure:
eMetering: 0
xEVCompensation: 0
nApertureFNumber: 0
bAutoAperture: 0
nShutterSpeedMsec: 0
bAutoShutterSpeed: 1
nSensitivity: 0
bAutoSensitivity: 1
Set video_encode state to idle
Enable port buffers for camera 71
Enable port buffers for video_encode 200
Enable port buffers for video_encode 201
Set camera state to executing
Set video_encode state to executing
opening ALSA device for capture: hw:0,0
final audio_channels: 1
sample_rate: 48000
nb_samples: 1024
sample_fmt: 1
audio_codec_ctx->channel_layout: 4
av_frame->channel_layout: 4
audio_codec_ctx->channels: 1
av_frame->channels: 0
allocated 2048 bytes for audio samples
audio_pts_step_base: 1920
actual sample rate=48000 dir=0
microphone: buffer size: 204800 frames (channels=1 buffer_size=2048 multiply=100)
microphone: setting period size to 1024
actual_period_size=1024 dir=0
audio capture device:
Hardware PCM card 0 'USB PnP Sound Device' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 204800
period_size : 1024
period_time : 21333
tstamp_mode : NONE
period_step : 1
avail_min : 1024
period_event : 0
start_threshold : 1
stop_threshold : 204800
silence_threshold: 0
silence_size : 0
boundary : 1677721600
appl_ptr : 0
hw_ptr : 0
start capturing video
waiting for the first video buffer
start capturing audio
[microphone started]capturing started
.[NAL7]........vSPEED_DOWN(-11520).................. 23.36 fps k=1 a-v=-36990 c-a=54244 u=0 d=1 pts=90750
......................... 21.16 fps k=2 a-v=-67560 c-a=107995 u=0 d=1 pts=177000
......................... 23.03 fps k=3 a-v=-103890 c-a=158142 u=0 d=1 pts=263250
......................... 20.37 fps k=4 a-v=-138300 c-a=217796 u=0 d=1 pts=349500
......................... 21.64 fps k=5 a-v=-174630 c-a=272309 u=0 d=1 pts=435750
......................... 20.75 fps k=6 a-v=-212880 c-a=333792 u=0 d=1 pts=309120
........................trying to recover from error
microphone error: buffer overrun
[microphone started]. 20.53 fps k=7 a-v=-249210 c-a=395488 u=0 d=1 pts=608250
......................... 21.33 fps k=8 a-v=-283620 c-a=449657 u=0 d=1 pts=694500
......................... 21.64 fps k=9 a-v=-321870 c-a=506841 u=0 d=1 pts=780750
......................... 21.41 fps k=10 a-v=-354360 c-a=561235 u=0 d=1 pts=867000
......................... 20.72 fps k=11 a-v=-396450 c-a=625960 u=0 d=1 pts=953250
......................... 22.18 fps k=12 a-v=-430860 c-a=678352 u=0 d=1 pts=1039500
......................... 23.32 fps k=13 a-v=-472950 c-a=731951 u=0 d=1 pts=652800
......................... 23.09 fps k=14 a-v=-507360 c-a=777997 u=0 d=1 pts=1212000
.trying to recover from error
microphone error: buffer overrun
.[microphone started]....................... 20.67 fps k=15 a-v=-539850 c-a=835838 u=0 d=1 pts=758400
......................... 23.92 fps k=16 a-v=-580020 c-a=885640 u=0 d=1 pts=804480
....^Cstop requested (signal=2)
Reverting pBuffer to its original value
shutdown sequence start
stop capturing video
shutdown_openmax: ilclient_flush_tunnels
shutdown_openmax: disable port buffer for camera 71
shutdown_openmax: disable port buffer for video_encode 200
shutdown_openmax: disable port buffer for video_encode 201
shutdown_openmax: disable tunnel[0]
shutdown_openmax: teardown tunnels
shutdown_openmax: state transition to idle
shutdown_openmax: state transition to loaded
shutdown_openmax: ilclient_cleanup_components
shutdown_openmax: OMX_Deinit
shutdown_openmax: ilclient_destroy cam_client
shutdown_openmax: ilclient_destroy ilclient
shutdown_video
teardown_audio_encode
teardown_audio_capture_device
hls_destroy
pthread_mutex_destroy
teardown_tcp_output
teardown_socks
free_encoded_packets
stop_watching_hooks
stop requested (signal=15)
pthread_join hooks_thread
free keyframe_pointers
shutdown successful
I'm using a microphone connected to a USB sound card on a RPi Zero W. Is there any more useful information I can provide to get this solved?
I had the same issue :microphone error: buffer overrun [microphone started]trying to recover from error
After I changed a new USB microphone everything is working fine. The one I had costs only a dollar so please try a new USB microphone. I am still using the same type but new one
Hello everyone I'm having the same issue. I tested the code yesterday since morning and somewhere in the evening, I started receiving the microphone error: buffer overrun
How can it be resolved? What causes the error?