![](/img/trans.png)
[英]How to cut a video to a certain length and add an intro video to it using ffmpeg-python?
[英]Add the fillcolor to none or alpha 0, return the green background in the rendered video while using ffmpeg-python
我正在使用ffmpeg-python(用python編寫的ffmpeg的包裝器)下面是提到的示例代碼。
inp.filter_multi_output('split')[k]
.filter_('rotate', a=rotation, fillcolor='#00FF0000', ow=f"rotw({rotation})", oh=f"roth({rotation})")
.filter_('scale', width=(i['width'] * Factors().factors['w_factor']), height=(i['height'] * Factors().factors['h_factor'])).filter('setsar', '1/1')
.setpts(f"PTS-STARTPTS+{i['showtime']}/TB")
使用fillcolor=none
。 從旋轉過濾器文檔:
填充
c
色,fillcolor
設置用於填充旋轉圖像未覆蓋的 output 區域的顏色。 如果選擇了特殊值none
,則不打印背景。 默認值為black
。
如果背景為綠色,則您的 output 不支持 alpha 和/或輸入在將其提供給旋轉過濾器之前沒有 alpha 通道。 如果是后者,請使用格式過濾器在旋轉過濾器之前添加一個 Alpha 通道。 簡化ffmpeg
示例:
ffmpeg -i input.jpg -vf "format=rgba,rotate=PI/6:fillcolor=none" output.png
有關格式過濾器接受的像素格式列表,請參閱ffmpeg -pix_fmts
。 選擇一個名稱中帶有a
的,例如rgba
或yuva420p
。
inp.filter_multi_output('split')[k]
.filter_('scale', width=(i['width'] * Factors().factors['w_factor']), height=(i['height'] * Factors().factors['h_factor'])).filter('setsar', '1/1')
.filter_('rotate', a=rotation, fillcolor='#00FF0000', ow=f"rotw({rotation})", oh=f"roth({rotation})")
.setpts(f"PTS-STARTPTS+{i['showtime']}/TB")
只需在旋轉之前應用縮放,問題就會得到解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.