Embodiments of this application provide a
transcoding method and apparatus, and an electronic device. The
transcoding apparatus includes a decoder and an
encoder. The decoder is configured to: receive a first
bitstream output by an application; decode the first
bitstream to obtain a first image and first format information of the first image; embed the first format information into the first image to obtain a second image; and send the second image to the application. The
encoder is configured to: receive a third image output by the application, where the third image is the second image or a second image edited by the application; determine second format information based on the third image; obtain preconfigured third format information; perform format conversion on the third
image based on the second format information and the third format information to obtain a fourth image;
encode the fourth image to obtain a second
bitstream; and send the second bitstream to the application. In this way, a bitstream can be correctly transcoded, and an anomaly can be avoided in an image obtained by a receive end through decoding.