支持转换器的多种文件格式如何工作?

How multiple file format supporting converters work?

ffmpeg/avconv、imagemagick convert等软件

他们是否使用中间格式:

format1 -> I. F.
format2 -> I. F.
I. F. -> format2
I. F. -> format3
...

或者他们是否有方法来转换每个支持的格式:

format1 -> format2
format1 -> format3
format2 -> format1
format2 -> format3
...

解码器和编码器是分开的。中间格式通常简称为“raw”。这是实际显示的格式。

来自ffmpeg documentation

The decoder produces uncompressed frames (raw video/PCM audio/...) which can be processed further by filtering. After filtering, the frames are passed to the encoder, which encodes them and outputs encoded packets. Finally those are passed to the muxer, which writes the encoded packets to the output file.

The transcoding process in ffmpeg for each output can be described by the following diagram:

 _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------> | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
 ________             ______________       |
|        |           |              |      |
| output | <-------- | encoded data | <----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|

ImageMagick 使用委托库在格式之间进行转换。例如用于 TIFF 的 libtif 和用于 PNG 的 libpng 等。一些格式转换直接内置到 ImageMagick 中。