Poor use of syntax
See original GitHub issueNo offence but this
import ffmpeg
in_file = ffmpeg.input('input.mp4')
overlay_file = ffmpeg.input('overlay.png')
(
ffmpeg
.concat(
in_file.trim(start_frame=10, end_frame=20),
in_file.trim(start_frame=30, end_frame=40),
)
.overlay(overlay_file.hflip())
.drawbox(50, 50, 120, 120, color='red', thickness=5)
.output('out.mp4')
.run()
)
looks ugly you should rewrite your library so it works like a type method for example to add an element to a list type you do this
some_list.append(new_item)
well your example code should work like this
from ffmpeg import media, media_write
# media is a type
with open("input.mp4", 'rb') as media_file:
input_media = media(media_file)
with open("overlay.png", 'rb') as media_file:
overlay_media = media(media_file)
new_media = media.concat(
input_media.trim(start_frame = 10, end_frame = 20),
input_media.trim(start_frame = 30, end_frame = 40),
)
new_media.overlay(overlay_media.hflip())
new_media.drawbox(50, 50, 120, 120, color='red', thickness=5)
with open("out.mp4", 'wb') as media_file:
media_write(media_file, new_media)
new_media.run()
please don’t use return self
everywhere so you can make non-pythonic code. take a leaf out of list, str, int, float, dict, set, etc the built-in python data-types as ffmpeg media is just creating a new data type really. A data-type which you should be able to do comparisions, I will add that media comparison is a complex thing but you should still implement an easy way to check for “exact & precise” comparrision then allow the end user to built upon it to make more complex comparison tools.
Adding frames together? why can’t you utalize __add__()
so the end user can just do +
, or subtract info from frames. I hope this helps
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top GitHub Comments
I agree that the syntax of this library would benefit from another pass / rewrite.
Someone DID a full rewrite with great syntax, but I can’t find their source code (no “homepage”) link and it’s brand new, so I’m a bit worried:
https://pypi.org/project/ffmpeg-generator/#description
“This project is based on ffmpeg-python. But rewrite all.”
Edit: Found their repo: https://github.com/fujiawei-dev/ffmpeg-generator
Edit 2: I see that they actually support every ffmpeg filter, unlike
ffmpeg-python
. Wow. The new project looks very good but needs code review/testing/etc since it’s brand new.