我正在尝试将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报道:
$python AurOchs_dc_compiler.py Sample2Kprores.mov 24
Traceback (most recent call last):
File "AurOchs_dc_compiler.py", line 17, in <module>
pipe = sp.Popen(to_dpx,stdout = sp.PIPE, bufsize = 100**8)
File "/usr/lib/python2.7/subprocess.py", line 739, in __init__
self.stdout = os.fdopen(c2pread, 'rb', bufsize)
OverflowError: signed integer is greater than maximum
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