moviepy icon indicating copy to clipboard operation
moviepy copied to clipboard

Is it possible to generate the video in 'yuv420p10le' format

Open OneWorld-github opened this issue 3 years ago • 0 comments

Hello

For other readers,

Moviepy uses FFMPEG to render videos, and FFMPEG has a set of parameters that allows you to change the output bit depth of the video. You can do this by changing the sub sampling pixel format. By changing the bit depth it allows you to achieve smoother transitioning gradients in rendered assets.

I was wondering if it is possible to generate a moviepy video using 'yuv420p10le' 10bit format.? From this link here:-

https://github.com/chunder/moviepy/commit/d107e6b28339a6b703da141aac19bf31aff3bf07

it seems that it is not possible, + (['-pix_fmt', 'yuv420p'] if (codec == 'libx264') else [])

because the -pix_fmt is statically set to 'yuv420p'.

Note, that older versions of ffmpeg only supported 8bits, whereas newer versions support both 8 and 10 bit. So you'd need a more recent ffmpeg binary to allow for this.

If you could make the second item in the list after -pix_fmt a variable, that would be great. So then it would allow for moviepy users to specify the bitdepth of the video.

Alternatively, any suggestions would be much appreciated.

ps. here is some code to generate an MP4, which uses imageio-ffmpeg, but really what you want is to be able to set the ffmpeg parameters that render the video.

import moviepy.editor as mped
import numpy as np

def composite_colour_wheel_on_colour():
    bg_color = mped.ColorClip(size=[830, 650], color=np.array([255, 255, 255]).astype(np.uint8), duration=2)
    bg_color = bg_color.set_position((0, 0))
    rgb_wheel_postition = [5, 5]
    rgb_wheel = mped.ImageClip("./rgb_wheel.jpg", duration=3).set_position((rgb_wheel_postition))
    canvas_size = bg_color.size
    stacked_clips = mped.CompositeVideoClip([bg_color, rgb_wheel], size=canvas_size).set_duration(3)
    stacked_clips.write_videofile('rgb_wheel_video_ffmpeg-imageio.mp4', fps=5)

composite_colour_wheel_on_colour()

any help much appreciated

OneWorld-github avatar Aug 06 '21 10:08 OneWorld-github