[FFmpeg-user] c/c++ program for FFMPEG H.264 encoding
Lisa
lisas965624 at gmail.com
Mon May 20 11:56:24 EEST 2024
Hello,
Iam able to encode to H.264 video from */dev/video0* with *1920x1080 at 29 * fps
in *Raspberry pi 4 model B* using the below FFMPEG commands
>> *v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=UYVY*
[setting resolution and pixel format]
>>*ffmpeg -y -use_wallclock_as_timestamps 1 -t 60 -i /dev/video0 -c:v
h264_v4l2m2m -b:v 8M -vsync 2 sample.mp4*
ffmpeg version N-112782-g07c303b708 Copyright (c) 2000-2023 the FFmpeg
developers
built with gcc 10 (Raspbian 10.2.1-6+rpi1)
configuration: --arch=armel --target-os=linux --enable-gpl
--enable-libx264 --enable-nonfree
libavutil 58. 32.100 / 58. 32.100
libavcodec 60. 33.100 / 60. 33.100
libavformat 60. 17.100 / 60. 17.100
libavdevice 60. 4.100 / 60. 4.100
libavfilter 9. 13.100 / 9. 13.100
libswscale 7. 6.100 / 7. 6.100
libswresample 4. 13.100 / 4. 13.100
libpostproc 57. 4.100 / 57. 4.100
-vsync is deprecated. Use -fps_mode
Passing a number to -vsync is deprecated, use a string argument as
described in the manual.
[video4linux2,v4l2 @ 0x34ec440] ioctl(VIDIOC_G_PARM): Inappropriate ioctl
for device
[video4linux2,v4l2 @ 0x34ec440] Time per frame unknown
[video4linux2,v4l2 @ 0x34ec440] Stream #0: not enough frames to estimate
rate; consider increasing probesize
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1707747701.326956, bitrate: N/A
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080,
1000k tbr, 1000k tbn
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
Press [q] to stop, [?] for help
[h264_v4l2m2m @ 0x34ef590] Using device /dev/video11
[h264_v4l2m2m @ 0x34ef590] driver 'bcm2835-codec' on card
'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0x34ef590] requesting formats: output=UYVY/uyvy422
capture=H264/none
[h264_v4l2m2m @ 0x34ef590] Failed to set gop size: Invalid argument
Output #0, mp4, to 'sample.mp4':
Metadata:
encoder : Lavf60.17.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), uyvy422(progressive),
1920x1080, q=2-31, 8000 kb/s, 1000k fps, 1000k tbn
Metadata:
encoder : Lavc60.33.100 h264_v4l2m2m
[mp4 @ 0x34ee6b0] Non-monotonic DTS in output stream 0:0; previous: 0,
current: 0; changing to 1. This may result in incorrect timestamps in the
output file.
[out#0/mp4 @ 0x34ee5f0] video:56252kB audio:0kB subtitle:0kB other
streams:0kB global headers:0kB muxing overhead: 0.038329%
frame= 1729 fps= 29 q=-0.0 Lsize= 56273kB time=00:00:59.96
bitrate=7687.4kbits/s speed=0.999x
I want to accomplish the same task with a C program. I've searched the web
for examples, but they haven't been very helpful. Can you provide a C
program that encodes video from a specified node with a resolution of
1920x1080 at 30 fps and saves it in an .mp4 file?
More information about the ffmpeg-user
mailing list