Sync video duration to audio duration #96
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #42
I implemented a failsafe to ensure there is always enough video for the audio. No more still images or black images.
Following was changed:
search.py, main.py:
There is now a minimum duration for clips. (Default 10 seconds). Only longer clips will be accepted and downloaded.
This will reduce potential videos further but no worries because there is a failsafe and I increased the search results from 10 to 15.
video.py (combine_videos): The Failsafe
During clip combining it now calculates the remaning video length required to so that video and audio are the same length.
It will continue to add clips from the same downloaded ones until the video length matches the audio length.
Of course it will also check if a clip is too long and only add as much as needed to fill the audio length. It is perfectly matched.
Notes:
One downside that remains with this is that for long videos clips may be repeated BUT the ultimate goal is to have < 60 second videos anyway and with a minimum length of 10 seconds per clip and 5 clips (or increase to 6), it will never repeat. Thus this change will become only a failsafe.
Tested & works for me.