compressionffmpegmpegvideo-codecs

How to encode grayscale video streams to MPEG-1 with FFmpeg?


I've got a grayscale video stream coming off a Firewire astronomy camera, I'd like to use FFmpeg to compress the video stream but it will not accept single byte pixel formats for the MPEG1VIDEO codecs. How can I use the FFmpeg API to convert grayscale video frames into a frame format accepted by FFmpeg?


Solution

  • MPEG-1 only accepts YUV so you need to convert your frame to the YUV format. Use the SwsContext structure which you create by calling sws_getContext(), and then use sws_scale().