UTF-8 is a variable-length way to represent Unicode text. It uses fewer bytes for common characters, supports more than a million characters across languages, and preserves ASCII encoding for the first 128 characters. section 6.3.2
A practical image or video workflow often ends with UTF-8: binary data is first encoded as base64 text, then decoded into a UTF-8 string that can be included in a GPT-4o prompt. section 6.3.2 section 6.4.2
The conversion workflow is:
- Read an image as binary data and encode it with Python's base64 library. section 6.3.2
- Decode the base64 result with decode('utf-8') to obtain a text string. section 6.3.2
- For video, convert a frame to JPEG bytes with OpenCV, base64-encode the buffer, and decode it as UTF-8. section 6.4.2
Preparing a video frame
After OpenCV produces a JPEG buffer, use encoded = base64.b64encode(buffer) followed by frame = encoded.decode('utf-8'). The resulting string can be included in a GPT-4o prompt. section 6.4.2
image = encoded.decode('utf-8')
Use Python's UTF-8 decode operation to turn encoded binary content into a text string. section 6.3.2










