'Compress video to jpeg with python

This is the part of my code that is posing a problem:

final_video = concatenate_videoclips(clips, method='compose')
    
    final_path =subdir_ +'/output1.avi'
    final_video.write_videofile(final_path,fps=15, threads=1, codec="rawvideo",audio=False)
    # print(final_path)

This code gives me videos with very big sizes. So I thought about changing the codec to jpeg but when I do this I get this error message:

The video export failed because FFMPEG didn't find the specified codec for video encoding and I can't choose png because these are the formats supported:

Uncompressed 8 bit with palette (LUT)
Uncompressed 8 & 16 bit grayscale
Uncompressed 24 & 32 bit RGB (alpha channel ignored)
Uncompressed 32 bit AYUV (alpha channel ignored)
Various YUV 4:2:2 compressed formats
PNG or JPEG-encoded individual frames.
MJPG (motion-JPEG) 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source