Losslessly convert from RGBA rawvideo to H.264 I am creating a tool that generates frames of RGBA video and pipes it to ffmpeg to create an .mp4 video. Here is the command that I give ffmpeg:

ffmpeg -y -f rawvideo -vcodec rawvideo -s 960x540 -pix_fmt rgba -r 60 -i - 
-an -c:v libx264 -pix_fmt yuv420p -b:v 995328k vigeo_demo.mp4


However, the quality is very, very, poor. The video consists of around 2-px wide lines being drawn across the screen at various angles. The lines are very blurry and blocky. What could be the cause of this and how do I fix it?

Things I've tried:


-q:v 0
crf 1 (crf 0 gives me an error)
You are downsampling the chroma, so thin lines will lose definition. Either use full chroma sampling

ffmpeg -y -f rawvideo -s 960x540 -pix_fmt rgba -framerate 60 -i - 
       -c:v libx264 -pix_fmt yuv444p -crf 0 video_demo.mp4


or keep pixels as RGB.

ffmpeg -y -f rawvideo -s 960x540 -pix_fmt rgba -framerate 60 -i - 
       -c:v libx264rgb -crf 0 video_demo.mp4