Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.09k stars 1.51k forks source link

How to preserve transparent mask layers in exported videos #2076

Open Good0007 opened 7 months ago

Good0007 commented 7 months ago

Expected Behavior

My original video was in mov format with Alpha channels, but the transparent channels were lost after exporting. I can use ffmpeg to export, It is normal :

ffmpeg -i test.mov -vf "scale=640:-1:flags=lanczos" -c:v qtrle out_test.mov

Actual Behavior

Steps to Reproduce the Problem

# 加载带透明通道的视频
alpha_video_clip = VideoFileClip("/Users/kangkang/Downloads/videos/test.mov",has_mask=True)
alpha_video_clip = alpha_video_clip.resize((720,1080))
# 导出视频丢失了透明度
alpha_video_clip.write_videofile("out_test.mov", codec='qtrle', threads=8,audio_codec='aac')
# ffmpeg命令导出正常
# ffmpeg -i test.mov -vf "scale=640:-1:flags=lanczos" -c:v qtrle out_test.mov

Specifications

SohamTilekar commented 6 months ago

Do You know how to get the transparent video.

Good0007 commented 6 months ago

Do You know how to get the transparent video.

According to my test, Moviepy does not support loading and exporting a transparent video as another transparent video. You can use ffmpeg to complete this task

SohamTilekar commented 6 months ago

Could You Give the Example Commands for the FFMPEG.

Good0007 commented 6 months ago

Could You Give the Example Commands for the FFMPEG.

Royallseal commented 3 weeks ago

I have tried a method from another guy and solved this problem, link here "https://github.com/Zulko/moviepy/issues/1555", according to his code, I just add a tag as "has_mask=True" in my code when using the func 'VideoFileClip()', then it works, that's amazing, but it's not bad.