-
Notifications
You must be signed in to change notification settings - Fork 923
Open
Labels
Description
Thanks for good library for us.
As mentioned in title I want to process video in raw byte to numpy
then encode it into raw byte video.
I succeed to read byte to mp4 with below comment.
decode = (
ffmpeg
.input('pipe:')
.output('pipe:')
.get_args()
)
output_data = p.communicate(input=input_data)[0]
It's okay for don't process anything.
But I want to process like your tensorflow stream example
So I tried with two process but it's doesn't work and process.
Below test is for video(byte) => numpy => video(file)
def start_encode_process():
logger.info('Starting ffmpeg process1')
args = (
ffmpeg
.input('pipe:')
.output('pipe:', format='rawvideo', pix_fmt='rgb24')
.compile()
)
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def start_decode_process(out_filename, width, height):
logger.info('Starting ffmpeg process2')
args = (
ffmpeg
.input('pipe:', format='rawvideo', pix_fmt='rgb24', s='{}x{}'.format(width, height))
.output(out_filename, pix_fmt='yuv420p')
.overwrite_output()
.compile()
)
return subprocess.Popen(args, stdin=subprocess.PIPE)
process1.stdin.write(video_byte)
while True:
in_frame = read_frame(process1, width, height)
out_frame = process_frame_simple(in_frame)
write_frame(process2, out_frame)
I think first problem is stdin. Above reading raw video byte use communicate method for stdin.
But below case it's not suit method cause need to process by each frame.
Do you have any idea for this?
Thanks for reading.
Sangkwun