c/c++ program for FFMPEG H.264 encoding
*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
Hello, Iam able to encode to H.264 video from */dev/video0* with *1920x1080@29 * fps in *Raspberry pi 4 model B* using the below FFMPEG commands 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?
Am 20.05.24 um 10:56 schrieb Lisa:
Iam able to encode to H.264 video from */dev/video0* with *1920x1080@29 * fps in *Raspberry pi 4 model B* using the below FFMPEG commands
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?
why should anybody re-invest the wheel in Pure C? how does the programming language matter? what's warong with FFmpeg?
Thank you for your response. I am working on an rtsp server that uses V4l2 to get frames from mipi-csi2 and then it will encode with ffmpeg Apis (C/C++ language). As I said with the ffmpeg command line it is able to encode 1920x1080@29 fps, so now I need the similar process with C/C++ to encode 1080p at 30fps. On Mon, May 20, 2024 at 11:43 PM Reindl Harald <h.reindl@thelounge.net> wrote: > > > Am 20.05.24 um 10:56 schrieb Lisa: > > Iam able to encode to H.264 video from */dev/video0* with *1920x1080@29 > * fps > > in *Raspberry pi 4 model B* using the below FFMPEG commands > > > 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? > > why should anybody re-invest the wheel in Pure C? > how does the programming language matter? > what's warong with FFmpeg? > _______________________________________________ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-request@ffmpeg.org with subject "unsubscribe". >
On Mon, May 20, 2024 at 10:43 PM Lisa <lisas965624@gmail.com> wrote:
Thank you for your response. I am working on an rtsp server that uses V4l2 to get frames from mipi-csi2 and then it will encode with ffmpeg Apis (C/C++ language). As I said with the ffmpeg command line it is able to encode 1920x1080@29 fps, so now I need the similar process with C/C++ to encode 1080p at 30fps.
I run ffmpeg from my c++ program using the traditional fork/exec process. It allows me to use the standard ffmpeg without having to maintain all of the libraries to build it. https://github.com/wcbonner/WimsConstructionCam/blob/239c10034c4c18cded8c247... Years ago I started developing with the libav libraries and realized that for small projects it was going to be a much larger learning and maintenance curve than I wanted to travel. I've used ffmpeg from c++ in linux as in the previous example, and in windows I've used createprocess with ffmpeg output going to a pipe that I'm reading in my C++ code and sending over tcp. https://github.com/wcbonner/WimTiVoServer/blob/8ac14adbf5da84220d719f00d5468... Wim
participants (3)
-
Lisa -
Reindl Harald -
William C Bonner