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

Ram Shaffir ram at ram.sh
Wed May 20 15:56:54 EEST 2020


> This is more than eighteen months old.
> I don't know if this makes any difference for your problem but it is certainly a strong reason not to spend too much time on it.

> Carl Eugen

The old version I used is part of the latest Buster distro for RPI, I recompiled to an updated ffmpeg version and tried again, the same message appears:
' [video4linux2,v4l2 @ 0x29d5dd0] The driver changed the time per frame from 1/30 to 117/7013'

Command:
ffmpeg -loglevel debug -y -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 

Debug log:
ffmpeg version git-2020-05-20-86822cf Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
  configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs='-lpthread -lm' --arch=armel --enable-gmp --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-mmal --enable-nonfree --enable-omx --enable-omx-rpi --enable-version3 --target-os=linux --enable-pthreads --enable-openssl --enable-hardcoded-tables
  libavutil      56. 46.100 / 56. 46.100
  libavcodec     58. 86.100 / 58. 86.100
  libavformat    58. 43.100 / 58. 43.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 82.100 /  7. 82.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-thread_queue_size' ... matched as option 'thread_queue_size' (set the maximum number of queued packets from the demuxer) with argument '10000'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'alsa'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '2'.
Reading option '-itsoffset' ... matched as option 'itsoffset' (set the input ts offset) with argument '1.5'.
Reading option '-i' ... matched as input url with argument 'hw:1,0'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '30'.
Reading option '-thread_queue_size' ... matched as option 'thread_queue_size' (set the maximum number of queued packets from the demuxer) with argument '10000'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'v4l2'.
Reading option '-i' ... matched as input url with argument '/dev/video0'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264_omx'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'ac3'.
Reading option '-ab' ... matched as option 'ab' (audio bitrate (please use -b:a)) with argument '51k'.
Reading option '-qmin' ... matched as AVOption 'qmin' with argument '16'.
Reading option '-qmax' ... matched as AVOption 'qmax' with argument '16'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '6M'.
Reading option '-maxrate:v' ... matched as AVOption 'maxrate:v' with argument '100M'.
Reading option '-bufsize' ... matched as AVOption 'bufsize' with argument '100M'.
Reading option '-strict' ...Routing option strict to both codec and muxer layer
 matched as AVOption 'strict' with argument 'experimental'.
Reading option '-flags' ... matched as AVOption 'flags' with argument '+global_header'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'mp4'.
Reading option '/usr/ramDisk/h264_omx.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url hw:1,0.
Applying option thread_queue_size (set the maximum number of queued packets from the demuxer) with argument 10000.
Applying option f (force format) with argument alsa.
Applying option ac (set number of audio channels) with argument 2.
Applying option itsoffset (set the input ts offset) with argument 1.5.
Successfully parsed a group of options.
Opening an input file: hw:1,0.
[alsa @ 0x29c1340] All info found
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:1,0':
  Duration: N/A, start: 1589978525.178518, bitrate: 1536 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Successfully opened the file.
Parsing a group of options: input url /dev/video0.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 30.
Applying option thread_queue_size (set the maximum number of queued packets from the demuxer) with argument 10000.
Applying option re (read input at native frame rate) with argument 1.
Applying option f (force format) with argument v4l2.
Successfully parsed a group of options.
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x29d5dd0] fd:3 capabilities:84a00001
[video4linux2,v4l2 @ 0x29d5dd0] Current input_channel: 0, input_name: HDMI, input_std: 0
[video4linux2,v4l2 @ 0x29d5dd0] Querying the device for the current frame size
[video4linux2,v4l2 @ 0x29d5dd0] Setting frame size to 1920x1080
[video4linux2,v4l2 @ 0x29d5dd0] The V4L2 driver changed the pixel format from 0x32315559 to 0x56595559
[video4linux2,v4l2 @ 0x29d5dd0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x29d5dd0] The V4L2 driver changed the pixel format from 0x32315559 to 0x56595559
[video4linux2,v4l2 @ 0x29d5dd0] Trying to set codec:rawvideo pix_fmt:yuv420p
[video4linux2,v4l2 @ 0x29d5dd0] The V4L2 driver changed the pixel format from 0x32315659 to 0x56595559
[video4linux2,v4l2 @ 0x29d5dd0] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x29d5dd0] The V4L2 driver changed the pixel format from 0x50323234 to 0x56595559
[video4linux2,v4l2 @ 0x29d5dd0] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x29d5dd0] Setting time per frame to 1/30
[video4linux2,v4l2 @ 0x29d5dd0] The driver changed the time per frame from 1/30 to 117/7013
[video4linux2,v4l2 @ 0x29d5dd0] All info found
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 141980.058101, bitrate: 1988671 kb/s
    Stream #1:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (YUY2 / 0x32595559), yuyv422, 1920x1080, 0/1, 1988671 kb/s, 59.94 fps, 59.94 tbr, 1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output url /usr/ramDisk/h264_omx.mp4.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264_omx.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument ac3.
Applying option ab (audio bitrate (please use -b:a)) with argument 51k.
Applying option b:v (video bitrate (please use -b:v)) with argument 6M.
Applying option f (force format) with argument mp4.
Successfully parsed a group of options.
Opening an output file: /usr/ramDisk/h264_omx.mp4.
[file @ 0x29df1d0] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
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
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 3840
detected 4 logical cores
[graph 0 input from stream 1:0 @ 0x29e15f0] Setting 'video_size' to value '1920x1080'
[graph 0 input from stream 1:0 @ 0x29e15f0] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 1:0 @ 0x29e15f0] Setting 'time_base' to value '1/30'
[graph 0 input from stream 1:0 @ 0x29e15f0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 1:0 @ 0x29e15f0] Setting 'frame_rate' to value '30/1'
[graph 0 input from stream 1:0 @ 0x29e15f0] w:1920 h:1080 pixfmt:yuyv422 tb:1/30 fr:30/1 sar:0/1
[format @ 0x29e1560] Setting 'pix_fmts' to value 'yuv420p'
[auto_scaler_0 @ 0x29e2010] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x29e2010] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x29e1560] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x29c1270] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto_scaler_0 @ 0x29e2010] w:1920 h:1080 fmt:yuyv422 sar:0/1 -> w:1920 h:1080 fmt:yuv420p sar:0/1 flags:0x4
[h264_omx @ 0x29dc3d0] Using OMX.broadcom.video_encode
[h264_omx @ 0x29dc3d0] OMX state changed to 2
[h264_omx @ 0x29dc3d0] OMX state changed to 3
[h264_omx @ 0x29dc3d0] OMX port 201 settings changed
Clipping frame in rate conversion by 0.000008
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[graph_1_in_0_0 @ 0x29fb730] Setting 'time_base' to value '1/48000'
[graph_1_in_0_0 @ 0x29fb730] Setting 'sample_rate' to value '48000'
[graph_1_in_0_0 @ 0x29fb730] Setting 'sample_fmt' to value 's16'
[graph_1_in_0_0 @ 0x29fb730] Setting 'channel_layout' to value '0x3'
[graph_1_in_0_0 @ 0x29fb730] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
[format_out_0_1 @ 0x29fbc40] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x29fbc40] Setting 'sample_rates' to value '48000|44100|32000'
[format_out_0_1 @ 0x29fbc40] Setting 'channel_layouts' to value '0x4|0x3|0x103|0x7|0x603|0x33|0x107|0x607|0x37|0xc|0xb|0x10b|0xf|0x60b|0x3b|0x10f|0x60f|0x3f'
[format_out_0_1 @ 0x29fbc40] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[AVFilterGraph @ 0x29faec0] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_resampler_0 @ 0x29fd080] [SWR @ 0x2a2c7f0] Using s16p internally between filters
[auto_resampler_0 @ 0x29fd080] ch:2 chl:stereo fmt:s16 r:48000Hz -> ch:2 chl:stereo fmt:fltp r:48000Hz
Output #0, mp4, to '/usr/ramDisk/h264_omx.mp4':
  Metadata:
    encoder         : Lavf58.43.100
    Stream #0:0, 0, 1/15360: Video: h264 (h264_omx), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, 0/1, q=16-16, 6000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.86.100 h264_omx
    Stream #0:1, 0, 1/48000: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, delay 256, 48 kb/s
    Metadata:
      encoder         : Lavc58.86.100 ac3
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 3840
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 11 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 3840
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384052 bitrate=   0.3kbits/s speed=2.89x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384052 bitrate=1373.9kbits/s speed=1.46x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384052 bitrate=2747.6kbits/s speed=0.969x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384052 bitrate=5495.0kbits/s speed=0.727x    
    Last message repeated 7 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384061 bitrate=6484.9kbits/s speed=0.62x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384090 bitrate=6601.5kbits/s speed=0.609x    
    Last message repeated 10 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384032 bitrate=7226.5kbits/s speed=0.638x    
    Last message repeated 7 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384054 bitrate=7414.5kbits/s speed=0.614x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384086 bitrate=6584.1kbits/s speed=0.614x    
    Last message repeated 11 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384028 bitrate=6389.9kbits/s speed=0.631x    
    Last message repeated 10 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384063 bitrate=5771.0kbits/s speed=0.638x    
    Last message repeated 8 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384095 bitrate=5834.3kbits/s speed=0.636x    
    Last message repeated 10 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384033 bitrate=5801.1kbits/s speed=0.645x    
    Last message repeated 7 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384059 bitrate=5934.6kbits/s speed=0.634x    
    Last message repeated 8 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384091 bitrate=5548.1kbits/s speed=0.634x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384023 bitrate=5609.4kbits/s speed=0.634x    
    Last message repeated 9 times
[rawvideo @ 0x29dab20] PACKET SIZE: 4147200, STRIDE: 384055 bitrate=5286.2kbits/s speed=0.633x    
    Last message repeated 3 times
[h264_omx @ 0x29dc3d0] OMX event 4 c9 1
Not writing 'clli' atom. No content light level info.
Not writing 'mdcv' atom. Missing mastering metadata.
frame=  173 fps= 19 q=-0.0 Lsize=    4003kB time=00:00:05.73 bitrate=5719.8kbits/s speed=0.633x    
video:3975kB audio:24kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.101218%
Input file #0 (hw:1,0):
  Input stream #0:0 (audio): 1732 packets read (798948 bytes); 1732 frames decoded (199737 samples); 
  Total: 1732 packets (798948 bytes) demuxed
Input file #1 (/dev/video0):
  Input stream #1:0 (video): 173 packets read (717465600 bytes); 173 frames decoded; 
  Total: 173 packets (717465600 bytes) demuxed
Output file #0 (/usr/ramDisk/h264_omx.mp4):
  Output stream #0:0 (video): 173 frames encoded; 173 packets muxed (4070165 bytes); 
  Output stream #0:1 (audio): 130 frames encoded (199680 samples); 130 packets muxed (24960 bytes); 
  Total: 303 packets (4095125 bytes) muxed
1905 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x29df320] Statistics: 2 seeks, 19 writeouts
[h264_omx @ 0x29dc3d0] OMX state changed to 2
[h264_omx @ 0x29dc3d0] OMX state changed to 1
Exiting normally, received signal 2.



More information about the ffmpeg-user mailing list