[FFmpeg-user] Newbie needs help on capture video/audio using ffmpeg on RPI

Ram Shaffir ram at ram.sh
Mon May 18 15:27:41 EEST 2020


Got some progress, using the command below bypassed the two errors ('[video4linux2,v4l2 @ 0x2015cd0] Error allocating a packet.' And '/dev/video0: Cannot allocate memory') also, CPU is around 25% and recording time is much longer now.

However, I get a new problem and other issues; the major problem is that the output is "fast forward", I guess due to the:
'[video4linux2,v4l2 @ 0xd4cd70] The driver changed the time per frame from 1/30 to 117/7013'

And there are two repeating alerts that I'm not sure their severities:
'ALSA buffer xrun'
and
'Non-monotonous DTS in output stream 0:1;....'

My latest command is:
ffmpeg -y -hide_banner -thread_queue_size 10000 -f alsa -ac 2 -itsoffset 1.5 -i hw:1,0 -r 30 -thread_queue_size 10000 -re -f v4l2 -i /dev/video0 -vcodec h264_omx -acodec ac3 -ab 51k -qmin 16 -qmax 16 -b:v 6M -maxrate:v 100M -bufsize 100M -strict experimental -flags +global_header -f mp4 /usr/ramDisk/h264_omx.mp4
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
  Duration: N/A, start: 1589804042.680866, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[video4linux2,v4l2 @ 0xd4cd70] The driver changed the time per frame from 1/30 to 117/7013
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 2077.501466, bitrate: 1988671 kb/s
    Stream #1:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1920x1080, 1988671 kb/s, 59.94 fps, 59.94 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo (native) -> h264 (h264_omx))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> ac3 (native))
Press [q] to stop, [?] for help
[h264_omx @ 0xd53160] Using OMX.broadcom.video_encode
Output #0, mp4, to '/usr/ramDisk/h264_omx.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (h264_omx) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, q=16-16, 6000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.35.100 h264_omx
    Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 48 kb/s
    Metadata:
      encoder         : Lavc58.35.100 ac3
[alsa @ 0xd39450] Thread message queue blocking; consider raising the thread_queue_size option (current value: 10000)
[alsa @ 0xd39450] ALSA buffer xrun. 8960kB time=00:00:31.50 bitrate=2329.5kbits/s speed=0.554x    
[alsa @ 0xd39450] ALSA buffer xrun. 9472kB time=00:00:35.06 bitrate=2213.1kbits/s speed=0.552x    
[alsa @ 0xd39450] ALSA buffer xrun. 9984kB time=00:00:39.38 bitrate=2076.8kbits/s speed=0.553x    
[alsa @ 0xd39450] ALSA buffer xrun.10496kB time=00:00:42.55 bitrate=2020.7kbits/s speed=0.55x     
[alsa @ 0xd39450] ALSA buffer xrun.11520kB time=00:00:48.76 bitrate=1935.4kbits/s speed=0.547x    
[alsa @ 0xd39450] ALSA buffer xrun.13312kB time=00:00:51.99 bitrate=2097.5kbits/s speed=0.546x    
[alsa @ 0xd39450] ALSA buffer xrun.15872kB time=00:00:56.05 bitrate=2319.5kbits/s speed=0.549x    
[alsa @ 0xd39450] ALSA buffer xrun.17152kB time=00:00:59.03 bitrate=2380.3kbits/s speed=0.553x    
[alsa @ 0xd39450] ALSA buffer xrun.17920kB time=00:01:01.97 bitrate=2368.7kbits/s speed=0.549x    
[alsa @ 0xd39450] ALSA buffer xrun.22272kB time=00:01:05.76 bitrate=2774.3kbits/s speed=0.556x    
[alsa @ 0xd39450] ALSA buffer xrun.25344kB time=00:01:10.02 bitrate=2965.0kbits/s speed=0.558x    
[alsa @ 0xd39450] ALSA buffer xrun.26368kB time=00:01:13.13 bitrate=2953.4kbits/s speed=0.558x    
[alsa @ 0xd39450] ALSA buffer xrun.26880kB time=00:01:15.82 bitrate=2904.0kbits/s speed=0.554x    
[alsa @ 0xd39450] ALSA buffer xrun.27904kB time=00:01:19.53 bitrate=2874.1kbits/s speed=0.553x    
[alsa @ 0xd39450] ALSA buffer xrun.29184kB time=00:01:21.55 bitrate=2931.3kbits/s speed=0.551x    
[alsa @ 0xd39450] ALSA buffer xrun.29440kB time=00:01:23.27 bitrate=2896.2kbits/s speed=0.552x    
[mp4 @ 0xd51e60] Non-monotonous DTS in output stream 0:1; previous: 4014288, current: 4014166; changing to 4014289. This may result in incorrect timestamps in the output file.
[mp4 @ 0xd51e60] Non-monotonous DTS in output stream 0:1; previous: 4014289, current: 4014138; changing to 4014290. This may result in incorrect timestamps in the output file.
[mp4 @ 0xd51e60] Non-monotonous DTS in output stream 0:1; previous: 4014290, current: 4014163; changing to 4014291. This may result in incorrect timestamps in the output file.
[alsa @ 0xd39450] ALSA buffer xrun.31744kB time=00:01:26.67 bitrate=3000.4kbits/s speed=0.55x     
[alsa @ 0xd39450] ALSA buffer xrun.37888kB time=00:01:30.91 bitrate=3413.9kbits/s speed=0.552x    
[alsa @ 0xd39450] ALSA buffer xrun.38656kB time=00:01:33.21 bitrate=3397.0kbits/s speed=0.549x    
frame= 2840 fps= 16 q=-0.0 Lsize=   39185kB time=00:01:37.30 bitrate=3298.9kbits/s speed=0.564x    
video:38681kB audio:452kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.131004%


More information about the ffmpeg-user mailing list