Hey guys I am learning to develop a website that converts videos to youtube quality (or close enough) 480p and 1080p, I am not much familiar with ffmpeg and struggling with its documentation.
I have these functions,
video_480p = subprocess.call([FFMPEG_PATH, '-i', input_file, '-codec:v', 'libx264', '-crf', '20', '-preset', 'medium',
'-b:v', '1000k', '-maxrate', '1000k', '-bufsize', '2000k','-vf', 'scale=-2:480', '-codec:a', 'aac', '-b:a',
'128k', '-strict', '-2', file_480p])
similarly I have another function,
new_video = subprocess.call([FFMPEG_PATH, '-i', input_file, '-codec:v', 'libx264', '-crf', '20', '-preset', 'medium',
'-b:v', '1000k', '-maxrate', '1000k', '-bufsize', '2000k','-vf', 'scale=-2:1080', '-codec:a', 'aac', '-b:a',
'128k', '-strict', '-2', output_file])
Both these functions, transcode the video, but returns low quality videos, Can anyone provide me with the right settings for 480p and 1080p which is similar or close to youtube quality?
Thanks
My guess is that your
-maxrate
argument is severly limiting the quality. Try dropping everything except-crf 20
and the scaling option. For higher quality, reduce its value (technical range: 0 = lossless, but huge filesize; 51 = worst quality, smallest size). Practical values are 23 (the default), and 17-18 for "visually lossless". The second dial is-preset
, which you could set toslow
orslower
if you have time to spend for better quality.For more details, see FFMPEG's own H.264 Encoding Guide.