视频到j2k转换的脚本不工作

2024-05-16 11:22:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将2k prores文件转换为j2c图像序列,以便我可以将它们包装在mxf文件中。我试图绕过中间dpx或tiff转换。 但以我有限的编程知识,我并没有取得成功。你能告诉我我的代码有什么问题吗。在

import subprocess as sp

import subprocess as sp

import sys

import numpy


FFMPEG = "ffmpeg"

IMAGEMAGICK = "convert"

COLOUR_MATRIX = "0.4124564,0.3575761,0.1804375,0.2126729,0.7151522,0.0721750,0.0193339,0.1191920,0.9503041"

infile = sys.argv[1]
fps = sys.argv[2]
outfile = ('0'.zfill(8))


to_dpx = [FFMPEG,'-i',infile,'-f','image2pipe','-pix_fmt','rgb24','-c:v','dpx','-r',fps,'-']
to_j2k = [IMAGEMAGICK,'-','-alpha','off','-depth','12','-gamma','0.454545','-recolor',COLOUR_MATRIX,'-evaluate','multiply','0.9166',str(outfile)+'.j2c']

pipe = sp.Popen(to_dpx,stdout = sp.PIPE, bufsize = 10**8)


while(pipe.pull() is NONE):
raw_image = pipe.stdout.read(2048*872*3)
image = numpy.fromstring(raw_image,dtype = 'uint8')
image = image.reshape((2048,872,3))
pipe = sp.Popen(to_j2k,stdin = sp.PIPE,stderr = sp.pipe)
outfile = int(outfile) + 1

错误报告: python报道:

^{pr2}$

ffmpeg错误消息:

Stream mapping:
Stream #0:0 -> #0:0 (prores (native) -> dpx (native))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Broken pipe
frame= 1 fps=0.0 q=-1.0 Lsize= 5234kB time=00:00:00.04 bitrate=1028964.3kbits/s

Tags: 文件toimageimportnumpyassyssp