[FFmpeg-user] C920 h264 Problem

Jonathan Isom jeisom at gmail.com
Thu Jan 26 16:03:03 EET 2017


On Thu, Jan 26, 2017 at 3:25 AM, Canberk Demirsoy (Alumni)
<cdemirsoy at sabanciuniv.edu> wrote:
> Hi guys even though i make lots of settings i still see yuv format in debug
> file. How to correctly get h264 format from c920 using raspberry pi? And i
> wanna transfer file without encoding or decoding by copying vcodec.

Hi

I have one of these cameras. You can get a list of resolutions and
framerates with'v4l2-ctl --list-formats-ext'. This will list 3 modes
of operation with a straight YUYV format for encoding, a motion jpeg
and h264 modes. Once you set the -pixel_format to h264 the camera is
doing hardware encoding. This command below  will copy from the camera
at 10 frames per second at 864x480 in h264 and put in in a m4v file.

'ffmpeg -f v4l2 -framerate 10 -video_size 864x480 -pixel_format h264
-i /dev/video0 -codec:v copy ~/test.m4v'

If you want to change other settings, there is v4l2-ctl and
uvcdynctrl. For uvcdynctrl you'' have to do a little prep work by
addiong the relevant data for the camera with this 'uvcdynctrl
--addctrl=046d:082d'. You then could turn off the led with this below.

'uvcdynctrl --set='LED1 Mode' 0'

I did not find any other h264 encoding tweaks other that the framerate
and resolution. With v4l2-ctl and uvcdynctrl you can adjust other
things like zoom, focus and color controls(brightness, contrast, etc),
but otherwise no h264 settings. You can run those before and during
recording.

HTH

Jonathan


> My script
>
>  ffmpeg -report -f v4l2 -r 20 -s 1920x1080 -pix_fmt h264 -input_format h264
> -i /dev/video0 -copyinkf -vcodec copy -loglevel debug -t 15 logging.mp4
>
> Report
>
>
> ffmpeg started on 2017-01-26 at 09:20:07
> Report written to "ffmpeg-20170126-092007.log"
> Command line:
> ffmpeg -report -f v4l2 -r 20 -s 1920x1080 -pix_fmt h264 -input_format h264
> -i /dev/video0 -copyinkf -vcodec copy -loglevel debug -t 15 logging.mp4
> ffmpeg version git-2016-12-15-745f4bc Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.9.2 (Raspbian 4.9.2-10)
>   configuration: --enable-cross-compile --arch=armel --target-os=linux
> --enable-gpl --enable-libx264 --enable-nonfree --enable-libfdk-aac
> --enable-libvpx --enable-libopus --enable-librtmp --enable-libmp3lame
> --extra-libs=-lasound
>   libavutil      55. 43.100 / 55. 43.100
>   libavcodec     57. 68.100 / 57. 68.100
>   libavformat    57. 60.100 / 57. 60.100
>   libavdevice    57.  2.100 / 57.  2.100
>   libavfilter     6. 68.100 /  6. 68.100
>   libswscale      4.  3.101 /  4.  3.101
>   libswresample   2.  4.100 /  2.  4.100
>   libpostproc    54.  2.100 / 54.  2.100
> Splitting the commandline.
> Reading option '-report' ... matched as option 'report' (generate a report)
> with argument '1'.
> Reading option '-f' ... matched as option 'f' (force format) with argument
> 'v4l2'.
> Reading option '-r' ... matched as option 'r' (set frame rate (Hz value,
> fraction or abbreviation)) with argument '20'.
> Reading option '-s' ... matched as option 's' (set frame size (WxH or
> abbreviation)) with argument '1920x1080'.
> Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel
> format) with argument 'h264'.
> Reading option '-input_format' ... matched as AVOption 'input_format' with
> argument 'h264'.
> Reading option '-i' ... matched as input url with argument '/dev/video0'.
> Reading option '-copyinkf' ... matched as option 'copyinkf' (copy initial
> non-keyframes) with argument '1'.
> Reading option '-vcodec' ... matched as option 'vcodec' (force video codec
> ('copy' to copy stream)) with argument 'copy'.
> Reading option '-loglevel' ... matched as option 'loglevel' (set logging
> level) with argument 'debug'.
> Reading option '-t' ... matched as option 't' (record or transcode
> "duration" seconds of audio/video) with argument '15'.
> Reading option 'logging.mp4' ... matched as output url.
> Finished splitting the commandline.
> Parsing a group of options: global .
> Applying option report (generate a report) with argument 1.
> Applying option loglevel (set logging level) with argument debug.
> Successfully parsed a group of options.
> Parsing a group of options: input url /dev/video0.
> Applying option f (force format) with argument v4l2.
> Applying option r (set frame rate (Hz value, fraction or abbreviation))
> with argument 20.
> Applying option s (set frame size (WxH or abbreviation)) with argument
> 1920x1080.
> Applying option pix_fmt (set pixel format) with argument h264.
> Successfully parsed a group of options.
> Opening an input file: /dev/video0.
> [video4linux2,v4l2 @ 0x2e07bd0] fd:5 capabilities:84200001
> [video4linux2,v4l2 @ 0x2e07bd0] Current input_channel: 0, input_name:
> Camera 1, input_std: 0
> [video4linux2,v4l2 @ 0x2e07bd0] Setting time per frame to 1/20
> [h264 @ 0x2e08bd0] nal_unit_type: 7, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] nal_unit_type: 8, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] nal_unit_type: 5, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] nal_unit_type: 5, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] nal_unit_type: 5, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] nal_unit_type: 5, nal_ref_idc: 3
> [h264 @ 0x2e08bd0] Reinit context to 1920x1088, pix_fmt: yuvj420p
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [h264 @ 0x2e08bd0] nal_unit_type: 1, nal_ref_idc: 2
> [video4linux2,v4l2 @ 0x2e07bd0] All info found
> Input #0, video4linux2,v4l2, from '/dev/video0':
>   Duration: N/A, start: 2409.495782, bitrate: N/A
>     Stream #0:0, 8, 1/1000000: Video: h264 (Constrained Baseline), 1
> reference frame, yuvj420p(pc, progressive, left), 1920x1080 (1920x1088)
> [SAR 1:1 DAR 16:9], 0/1, -3 kb/s, 20 fps, 20 tbr, 1000k tbn, 40 tbc
> Successfully opened the file.
> Parsing a group of options: output url logging.mp4.
> Applying option copyinkf (copy initial non-keyframes) with argument 1.
> Applying option vcodec (force video codec ('copy' to copy stream)) with
> argument copy.
> Applying option t (record or transcode "duration" seconds of audio/video)
> with argument 15.
> Successfully parsed a group of options.
> Opening an output file: logging.mp4.
> [file @ 0x2ee6470] Setting default whitelist 'file,crypto'
> Successfully opened the file.
> Output #0, mp4, to 'logging.mp4':
>   Metadata:
>     encoder         : Lavf57.60.100
>     Stream #0:0, 0, 1/10240: Video: h264 (Constrained Baseline), 1
> reference frame ([33][0][0][0] / 0x0021), yuvj420p(pc, progressive, left),
> 1920x1080 (0x0) [SAR 1:1 DAR 16:9], 0/1, q=2-31, -3 kb/s, 20 fps, 20 tbr,
> 10240 tbn, 20 tbc
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
> Press [q] to stop, [?] for help
> cur_dts is invalid (this is harmless if it occurs once at the start per
> stream)
> [mp4 @ 0x2ed1c80] Non-monotonous DTS in output stream 0:0; previous: 0,
> current: -2561; changing to 1. This may result in incorrect timestamps in
> the output file.
> [mp4 @ 0x2ed1c80] Non-monotonous DTS in output stream 0:0; previous: 1,
> current: -2028; changing to 2. This may result in incorrect timestamps in
> the output file.
> [mp4 @ 0x2ed1c80] Non-monotonous DTS in output stream 0:0; previous: 2,
> current: -1536; changing to 3. This may result in incorrect timestamps in
> the output file.
> [mp4 @ 0x2ed1c80] Non-monotonous DTS in output stream 0:0; previous: 3,
> current: -1003; changing to 4. This may result in incorrect timestamps in
> the output file.
> [mp4 @ 0x2ed1c80] Non-monotonous DTS in output stream 0:0; previous: 4,
> current: -512; changing to 5. This may result in incorrect timestamps in
> the output file.
> frame=   18 fps=0.0 q=-1.0 size=     370kB time=00:00:00.55
> bitrate=5504.0kbits/s speed= 1.1x
> frame=   28 fps= 28 q=-1.0 size=     560kB time=00:00:01.05
> bitrate=4365.9kbits/s speed=1.05x
> frame=   38 fps= 25 q=-1.0 size=     745kB time=00:00:01.55
> bitrate=3936.3kbits/s speed=1.03x
> frame=   48 fps= 24 q=-1.0 size=     928kB time=00:00:02.05
> bitrate=3705.7kbits/s speed=1.02x
> frame=   58 fps= 23 q=-1.0 size=    1115kB time=00:00:02.55
> bitrate=3582.3kbits/s speed=1.02x
> frame=   68 fps= 23 q=-1.0 size=    1298kB time=00:00:03.05
> bitrate=3484.6kbits/s speed=1.01x
> frame=   78 fps= 22 q=-1.0 size=    1480kB time=00:00:03.55
> bitrate=3414.9kbits/s speed=1.01x
> frame=   88 fps= 22 q=-1.0 size=    1665kB time=00:00:04.05
> bitrate=3366.6kbits/s speed=1.01x
> frame=   98 fps= 22 q=-1.0 size=    1846kB time=00:00:04.55
> bitrate=3322.6kbits/s speed=1.01x
> frame=  108 fps= 21 q=-1.0 size=    2027kB time=00:00:05.05
> bitrate=3287.4kbits/s speed=   1x
> frame=  118 fps= 21 q=-1.0 size=    2261kB time=00:00:05.55
> bitrate=3337.0kbits/s speed=   1x
> frame=  128 fps= 21 q=-1.0 size=    2427kB time=00:00:06.05
> bitrate=3285.4kbits/s speed=   1x
> frame=  138 fps= 21 q=-1.0 size=    2607kB time=00:00:06.55
> bitrate=3259.7kbits/s speed=   1x
> frame=  149 fps= 21 q=-1.0 size=    2807kB time=00:00:07.09
> bitrate=3238.9kbits/s speed=1.01x
> frame=  159 fps= 21 q=-1.0 size=    2989kB time=00:00:07.59
> bitrate=3222.0kbits/s speed=1.01x
> frame=  169 fps= 21 q=-1.0 size=    3174kB time=00:00:08.09
> bitrate=3210.2kbits/s speed=1.01x
> frame=  179 fps= 21 q=-1.0 size=    3381kB time=00:00:08.59
> bitrate=3220.8kbits/s speed=1.01x
> frame=  189 fps= 21 q=-1.0 size=    3551kB time=00:00:09.09
> bitrate=3197.1kbits/s speed=   1x
> frame=  199 fps= 21 q=-1.0 size=    3732kB time=00:00:09.59
> bitrate=3184.7kbits/s speed=   1x
> frame=  209 fps= 21 q=-1.0 size=    3925kB time=00:00:10.09
> bitrate=3183.3kbits/s speed=   1x
> frame=  219 fps= 21 q=-1.0 size=    4103kB time=00:00:10.59
> bitrate=3171.4kbits/s speed=   1x
> frame=  229 fps= 21 q=-1.0 size=    4287kB time=00:00:11.09
> bitrate=3164.0kbits/s speed=   1x
> frame=  239 fps= 21 q=-1.0 size=    4470kB time=00:00:11.59
> bitrate=3156.7kbits/s speed=   1x
> frame=  249 fps= 21 q=-1.0 size=    4652kB time=00:00:12.09
> bitrate=3149.4kbits/s speed=   1x
> frame=  259 fps= 21 q=-1.0 size=    4835kB time=00:00:12.59
> bitrate=3143.5kbits/s speed=   1x
> frame=  269 fps= 21 q=-1.0 size=    5018kB time=00:00:13.09
> bitrate=3137.9kbits/s speed=   1x
> frame=  279 fps= 21 q=-1.0 size=    5201kB time=00:00:13.59
> bitrate=3132.8kbits/s speed=   1x
> frame=  290 fps= 21 q=-1.0 size=    5403kB time=00:00:14.15
> bitrate=3127.5kbits/s speed=   1x
> frame=  300 fps= 21 q=-1.0 size=    5586kB time=00:00:14.65
> bitrate=3123.0kbits/s speed=   1x
> No more output streams to write to, finishing.
> frame=  307 fps= 20 q=-1.0 Lsize=    5719kB time=00:00:15.00
> bitrate=3123.1kbits/s speed=   1x
> video:5714kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 0.077692%
> Input file #0 (/dev/video0):
>   Input stream #0:0 (video): 308 packets read (5870212 bytes);
>   Total: 308 packets (5870212 bytes) demuxed
> Output file #0 (logging.mp4):
>   Output stream #0:0 (video): 307 packets muxed (5851314 bytes);
>   Total: 307 packets (5851314 bytes) muxed
> 0 frames successfully decoded, 0 decoding errors
> [AVIOContext @ 0x2ee0ff0] Statistics: 34 seeks, 339 writeouts
>
>
> *Canberk Demirsoy*
>
> B.Sc. Electrical Engineering, Sabancı University
> M.Sc. Computer Engineering, Munich Technical University
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list