Video size streaming to YouTube with FFMPEG on Raspberry Pi 4 - ffmpeg

I'm using FFMPEG to stream video to YouTube with my Raspberry Pi 4. It used to work well, but just recently YouTube has started displaying the video smaller than it should be with a black surround as pictured.
preview in YouTube studio
The command I am using is:
ffmpeg -re -i $path -r 24 -g 48 -pix_fmt yuv420p -x264-params kiyint=48:min-keyint=48:scenecut=-1 -video_size 1280x720 -b:v 2000k -b:a 128k -ar 44100 -acodec aac -vcodec h264_v4l2m2m -preset superfast -bufsize 960k -crf 28 -threads 4 -f flv rtmp://a.rtmp.youtube.com/live2/$key
I thought -video_size 1280x720 should set the resolution that FFMPEG is outputting, but it's still displaying as in the picture. The videos themselves are 720p.
I can't work out how to get YouTube and FFMPEG to understand the resolution of the video from one another and have it fill the frame.

Related

ffmpeg to YouTube with tee mux giving resolution warning (65535x65535), which is not optimal

I am streaming to YouTube and Facebook using ffmpeg , also writing data into disk (recording).
it's working fine on Facebook and recording but on YouTube it's giving warning that is
Please check the video resolution. The current resolution is (65535x65535), which is not optimal.
and output on YouTube is also 1:1 aspect ratio due to the above resolution.
I am using tee mux in ffmpeg Command.
ffmpeg -f dshow -framerate 30 -i video="Integrated Webcam":audio="Microphone Array (IntelĀ® Smart Sound Technology (IntelĀ® SST))" -s 1920x1080 -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 28 -pix_fmt yuv420p -c:a aac -strict -2 -ac 2 -b:a 128k -t 4 -map 0 -f tee "[f=ismv]pipe:1 | [f=flv]rtmps://youtube | [f=flv]facebook"

ffmpeg resulting in no audio and unplayble video

I am trying to get ffmpeg to work as expected however I am having all kinds of trouble getting it to work.
I need to output a webm and h264 for web play. However, the command I am using, while it used to work a few years ago, does not work at all now.
Both my webm and h264 do not have audio, and neither will play in any browser.
My command for webm is:
ffmpeg -y -i "$KMVAR_File" -c:v libvpx -crf 24 -b:v 1000k -vf scale=720:-2 -c:a libvorbis "$KMVAR_webmPath"
and my command for mp4 is:
ffmpeg -y -i "$KMVAR_File" -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -crf 32 -b:v 1M -minrate 1M -maxrate 1M -bufsize 2M -vf scale=720:-2 -c:a aac -strict experimental -movflags +faststart "$KMVAR_mp4Path"
When playing with multiple audio, downmixing or extracting, there's no "one size fit all" solution with ffmpeg.
Look at https://trac.ffmpeg.org/wiki/AudioChannelManipulation as it provides multiple possible solution to your problem.
(I usually go with the pan filter : not the easiest to use, but more powerful than the map_channel approach)

Record and stream desktop to Youtube by ffmpeg with HD resolution

I want to record and stream desktop to Youtube live by FFmpeg. But the output resolution is very low, maximum 360.
What options I need to change?
ffmpeg -framerate 30 -f x11grab -i :1 -f pulse -i default -c:v libx264 -s 1920x1080 -r 60 -b:v 5000k -crf 10 -vf format=yuv420p -c:a aac -b:a 128k -f flv rtmp://a.rtmp.youtube.com/live2/stream_key
Problem
Default size for x11grab is the full desktop or window (640x480 for old ffmpeg versions). Your ffmpeg is old, so it is capturing at 640x480. You are then upscaling 640x480 to 1920x1080 which is bad and looks ugly.
Solution 1: Upgrade ffmpeg
Fix by using a modern ffmpeg version and it will grab the full desktop or window size by default. See FFmpeg Download page for links or the FFmpeg compile and install guides.
Solution 2: Use -video_size input option
ffmpeg -framerate 30 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -i default -c:v libx264 -b:v 5000k -maxrate 5000k -bufsize 10000k -g 60 -vf format=yuv420p -c:a aac -b:a 128k -f flv rtmp://a.rtmp.youtube.com/live2/stream_key
See the FFmpeg x11grab documentation for more info and options.
For streaming it is recommended to add -g, -bufsize, and -maxrate to enable VBV.

FFMPEG HLS video speed is too fast

I am trying to make a .m3u8 hls playlist locally on my computer. I am using Windows 7, 32 bit.
I am a begginner of FFMPEG, and finally I combined some commands into this:
ffmpeg -re -rtbufsize 999999k -y -f dshow -video_size 640x360 -r 15 -i video="ManyCam Virtual Webcam" -c:v libx264 -crf 18 -profile:v main -maxrate 999999k -bufsize 99999k -pix_fmt yuv420p -flags -global_header -hls_time 10 -g 3 -hls_list_size 2 -hls_wrap 0 -start_number 1 D:\\stream\stream.m3u8 -tune zerolatency
The problem is that while playing the m3u8 playlist with VLC or a HLS player, the video speed is faster than normal.
If you need more info, please comment.
EDIT
If I play one of the .ts files, the problem is the same.
Thank you so much!

Audio is lost in some portions of a HLS stream

I have setup a HLS live stream on AWS. Significant part of the video plays as expected but in some portions audio is lost while the video continues to play. Please share you thoughts/insights if you have faced such an issue.
I transcode video to h264, baseline3.1 and audio to aac stereo 2 channels before segmenting to 10s files. Following commands are being used:
Transcoding:
ffmpeg -y -i ${file_path} -b:v ${vBitrate} -minrate ${vBitrate} -maxrate ${vBitrate} -c:v libx264 -b:a ${aBitrate} -c:a libfaac -ac 2 -r 25 -s ${resolution} -profile:v baseline -level 3.1 ${output_dir}/${file_name}.ts
Ex: vBitrate: 1m, aBirate: 128k, resolution: 960x540
Splittting:
ffmpeg -i ${file_path} -c:v copy -c:a copy -flags -global_header -map 0 -f segment -segment_time ${segment} -segment_list ${output_dir}/playlist.m3u8 -segment_format mpegts tmp0/${file_name}_%02d.ts
Ex: segment: 10
Setup: segments are being served from Nginx and playlist is managed by a Python/Flask app.

Resources