trim is not truly trimming duration, keeping stillframe before after
See original GitHub issuei took trimming example and try to make use in app i am working on. its simple gui (pyqt5) to help me work do batch processing.
graph / operations happening in following order
Crop > trim > pad > drawtext > watermark
i tried changing order by keeping trim in start and moving crop ahead as well. same result.
previously i was doing all above via batch files separately, it works but i hate it,
Earlier in my tests with batch file, i had noticed same issue as well. Stack OverFlow searches taught me that, adding -strict -2 before end helps. command in batch file looked like this
ffmpeg -i %dtp% -ss %s% -strict -2 -t %t% %filepath%\%filename
above line worked correctly in batch file.
Q. how can i make use of that here if my triming funtion looks like below
def trim_video(input,ss=0,t=100):
trimmed_out = (
input
.trim(start_frame=ss, end_frame=t)
)
return trimmed_out
thanks again for support
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top GitHub Comments
Solved! I observed the same issue of the ‘still frames’. As ffmpeg-python is a wrapper the root cause lies in most cases in FFmpeg itself.
In this case, two additional filters are required:
ffmpeg: “Be aware that frames are taken from each input [video] in timestamp order, so it is a good idea to pass all overlay inputs through a setpts=PTS-STARTPTS filter to have them begin in the same zero timestamp, such as …”
Translating back to ffmpeg-python, this means you have to add the following calls to you filter chains. An respective API call is available for video (but not for audio):
.setpts('PTS-STARTPTS')
A generic filter call can be used in both cases:
–Bid
I think the problem may be keyframes. You can use
ss
on the input to seek to the needed frame.Starts
video.mp4
at 20 seconds and plays ten seconds of it without including a paused frame.See: https://trac.ffmpeg.org/wiki/Seeking#Cuttingsmallsections