我的代码中有这一行:
writer = cv.CreateVideoWriter('video.avi', cv.CV_FOURCC('X','V','I','D'), 30 ,(480,800), 1)
哪个输出来控制这个:
Output #0, avi, to 'video.avi':
Stream #0:0: Video: mpeg4, yuv420p, 480x800, q=2-31, 24576 kb/s, 90k tbn, 30 tbc
我想阻止它打印任何东西到标准输出,但保持我自己在代码中进一步输出的可能性。我怎样才能做到这一点?
我试过这个,但没有奏效。
class NullStream:
def write(self, text):
pass
sys.stdout = NullStream()
sys.stderr = NullStream()
print "hello" #This doesn't outputs
#This function still outputs to console:
writer = cv.CreateVideoWriter('video.avi', cv.CV_FOURCC('X','V','I','D'), 30 ,(480,800), 1)
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__