ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

ffmpeg-python write webm format video with alpha channel, the speed is very slow

Open mrlihellohorld opened this issue 2 years ago • 1 comments

I convert a lot of rgba pictures with alpha channel to numpy array, and then encode to webm format video by ffmpeg-python. Here is how I do it: self.process2 = ( ffmpeg .input('pipe:', format='rawvideo', framerate=25, pix_fmt='rgba', s='{}x{}'.format(frame_width, frame_height)) .output(outfile_dfl, threads=8,preset='ultrafast', speed=8, quality='realtime',
vcodec='libvpx-vp9', pix_fmt='yuva420p', crf='30', video_bitrate='0') .overwrite_output() .run_async(cmd='ffmpeg', pipe_stdin=True) ) for i in range(1000): self.process2.stdin.write( input_img_array .astype(np.uint8) .tobytes() )

  1. I found that when encoding, the speed is very slow. Looking at the printed log, it is about 0.1 times faster: frame= 1154 fps=3.3 q=0.0 size= 3966kB time=00:00:45.16 bitrate= 719.4kbits/s speed=0.128x
  2. If I encode the rgb webm video in the same way, the speed is much faster, and it takes about 50ms to encode a frame of pictures. To encode rgb images, I changed pix_fmt to 'rgb24' in input, and changed pix_fmt to 'yuv420p' in output.
  3. Please how can I increase the speed of encoding webm video with alpha channel

mrlihellohorld avatar Jun 15 '23 03:06 mrlihellohorld

I have the same problem, I tried to transcoding video:

image

But the speed is very slow about 0.3x. Did you have solution for this?

tranvuluan avatar Mar 13 '24 03:03 tranvuluan