mpromonet / v4l2tools

V4L2 tools using V4L2 C++ wrapper
The Unlicense
117 stars 49 forks source link

Camera Rotation and Flipping / passing args to ffmpeg #41

Open SealedJoy opened 2 years ago

SealedJoy commented 2 years ago

Currently using v4l2-tools (specifically v4l2compress and v4l2rtspserver) Its working for the most part but i am struggling to find a way to rotate the video feed (ideally in the v4l2compress program?) sadly my driver contains no such controls, so i cannot seem to set image rotation through the driver which leaves me with only software as option. The ffmpeg args: ' -vf "transpose=dir=1" ' seems to work okay, but i would like to do this through v4l2compress is this possible? otherwise afaik i will need to make 2 dummy devices and perform reencoding again.

Full command below:

ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -video_size 1280x1080 -i /dev/video0 -pix_fmt yuyv422 -vf "transpose=dir=1" -f v4l2 /dev/video5

mpromonet commented 2 years ago

Hi SealedJoy,

I guess this should be possible in the libyuv conversion before encoding for instance in https://github.com/mpromonet/v4l2tools/blob/master/include/x264encoder.h#L90

                libyuv::ConvertToI420((const uint8*)buffer, rsize,
                        m_pic_in.img.plane[0], m_width,
                        m_pic_in.img.plane[1], (m_width+1)/2,
                        m_pic_in.img.plane[2], (m_width+1)/2,
                        0, 0,
                        m_width, m_height,
                        m_width, m_height,
                        libyuv::kRotate0, m_informat);

Best Regards, Michel.