Final background video length is not right
Describe the bug When the final video is created around 4 seconds before it ends (this is when the voiceover and the screenshots have finished) the background video freezes and a still image of it is shown (for those remaining 4 seconds).
Expected behavior Obviously the final video has to end when the voiceover and screenshots (the selected reddit thread in general) have finished and not continue further.
Additional context Other users have experienced the same problem with the latest version (2.3).
Hi, i think this is a duplicate issue from #869
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.
Hi, i think this is a duplicate issue from #869
this is not a duplicate, this is different behaviour to #869
I believe the issue is related to the fact that the code use a hardcoded constant video framerate (30), while the video uses a variable one. I use a custom background of 1.5h of me doing Minecraft parkour, so I'm not sure about the YouTube video. If you use MediaInfo you can see:
$ mediainfo --Output=$'Video;Video: %Duration% ms\\n\nAudio;Audio: %Duration% ms' temp.mp4
Video: 54700 ms
Audio: 52244 ms
EDIT
I tried using a constant framerate/bitrate, but to no avail. Hence, I created a small bash script (I'm using linux, but it should be easy to translate it to python code):
#!/bin/bash
echo "Processing: '$1'"
video_ms=$(mediainfo --Output=$'Video;%Duration%' "$1")
# The +150 avoids a final video that seems to cut off the audio at the end
audio_ms=$(echo $(( $(mediainfo --Output=$'Audio;%Duration%' "$1")+150 )))
# Someone smarter than me: https://stackoverflow.com/a/24253318/9373031
video_s=$(echo $(( ($video_ms+999)/1000 )))
audio_s=$(echo $(( ($audio_ms+999)/1000 )))
if [ $audio_s -ge 61 ]; then
echo "Audio duration: $audio_s"
elif [ $audio_s -le $video_s ]; then
t=$(echo "$(echo $audio_ms)ms")
ffmpeg -i "$1" -t $t -c copy "chopped/$1"
fi
and calling it at the end of make_final_video with os.system(f'cd results && ./chopper.sh "{subreddit}/{filename}"')
I will try to look deeper in this bug, but I pretty much never used python and ffmpeg (only WebDev, Node.js and C, sorry), so I probably won't be able to debug properly what ffmpeg is doing under the hood...
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.
Issue closed due to being stale. Please reopen if issue persists in latest version.