Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Encode 将图像转换为YUV格式(不同类型:BT.601或BT.709)并以原始格式保存_Encode_Codec_Yuv - Fatal编程技术网

Encode 将图像转换为YUV格式(不同类型:BT.601或BT.709)并以原始格式保存

Encode 将图像转换为YUV格式(不同类型:BT.601或BT.709)并以原始格式保存,encode,codec,yuv,Encode,Codec,Yuv,有没有工具可以将给定的图像(jpg)转换为YUV格式并将其保存为原始数据 我尝试了Python-PIL,但没有找到如何做到这一点 谢谢您的建议。您可以使用安装在大多数Linux发行版上的、适用于macOS和Windows的ImageMagick来实现这一点。仅在终端中,您可以运行: convert input.jpg -depth 8 -colorspace Rec601YCbCr yuv:result.bin 或者,对于Rec709YCbCr,您可以使用: convert input.jpg

有没有工具可以将给定的图像(jpg)转换为YUV格式并将其保存为原始数据

我尝试了Python-PIL,但没有找到如何做到这一点


谢谢您的建议。

您可以使用安装在大多数Linux发行版上的、适用于macOS和Windows的ImageMagick来实现这一点。仅在终端中,您可以运行:

convert input.jpg -depth 8 -colorspace Rec601YCbCr yuv:result.bin
或者,对于
Rec709YCbCr
,您可以使用:

convert input.jpg -depth 8 -colorspace Rec709YCbCr yuv:result.bin

下面是一个小例子,说明了这一过程及其逆转:

# Create a gradient image, magenta-green, save as JPEG
convert -size 1024x768 gradient:magenta-lime input.jpg

# Convert to YUV, saving as raw YUV in "image.bin"
convert input.jpg -depth 8 -colorspace Rec601YCbCr yuv:image.bin

# Convert back from raw YUV back to JPEG to check
convert -size 1024x768 -depth 8 YUV:image.bin -set colorspace Rec601YCbCr -colorspace RGB result.jpg

使用ffmpeg从jpg转换为yuv

ffmpeg -i filename.jpg -pixel_format yuv420p -s 656x500 filename.yuv
-pixel_格式
可以是
yuv420p
yuv422p
yuv444p

-s
是jpg的分辨率


来看看吧

ffplay -f rawvideo -pixel_format yuv420p -video_size 656x500 -i filename.yuv

如果视频大小不准确,您将看到垃圾。

很高兴!祝你的项目好运。