Quantcast
Channel: MediaSPIP
Viewing all articles
Browse latest Browse all 118210

FFmpeg h264_v4l2m2m encoder changing aspect ratio from 16:9 to 1:1 with black bars

$
0
0

When switching from libx264 to h264_v4l2m2m encoder in FFmpeg for YouTube streaming, the output video's aspect ratio changes from 16:9 to 1:1 with black bars on the sides, despite keeping the same resolution settings.

Original working command (with libx264):

ffmpeg -f v4l2 \
 -input_format yuyv422 \
 -video_size 1280x720 \
 -framerate 30 \
 -i /dev/video0 \
 -f lavfi \
 -i anullsrc=r=44100:cl=stereo \
 -c:v libx264 \
 -preset ultrafast \
 -tune zerolatency \
 -b:v 2500k \
 -c:a aac \
 -b:a 128k \
 -ar 44100 \
 -f flv rtmp://a.rtmp.youtube.com/live2/[STREAM-KEY]

When I replaced libx264 with h264_v4lm2m, it always produce a square resolution, and it automatically adds black bars to the top and the bottom of the sides of the camera. I currently using a Rasberry Pi 4 model B, with a webcam that I believe supports the 16:9 ratio (I've verified using v4l2-ctl --list-formats-ext -d /dev/video0 command)

I've tried the follows:

  • Adding -aspect 16:9 parameter in the ffmpeg command
  • Adding video filters such as -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1" None of these give me the correct aspect ratio.

How can I make the h264_v4l2m2m encoder maintain the original 16:9 aspect ratio without adding black bars? Is this a known limitation of the encoder, or am I missing some required parameters?


Viewing all articles
Browse latest Browse all 118210

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>