mirror of
https://github.com/thewesker/Video-Archive-Discord-Bot.git
synced 2025-12-20 04:11:05 -05:00
Fix handling for videos with no duration from youtubedl
This commit is contained in:
@@ -23,6 +23,7 @@ def download(videoUrl):
|
|||||||
# Just a video
|
# Just a video
|
||||||
video = result
|
video = result
|
||||||
|
|
||||||
|
if('duration' in video):
|
||||||
response['duration'] = video['duration']
|
response['duration'] = video['duration']
|
||||||
response['fileName'] = video['id'] + ".mp4"
|
response['fileName'] = video['id'] + ".mp4"
|
||||||
|
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -60,8 +60,12 @@ async def on_message(message):
|
|||||||
await message.channel.send(compressionMessage)
|
await message.channel.send(compressionMessage)
|
||||||
print("Duration = " + str(duration))
|
print("Duration = " + str(duration))
|
||||||
# Give us 7MB files with VBR encoding to allow for some overhead
|
# Give us 7MB files with VBR encoding to allow for some overhead
|
||||||
|
bitrateKilobits = 0
|
||||||
|
if(duration != 0):
|
||||||
bitrateKilobits = (7000 * 8)/duration
|
bitrateKilobits = (7000 * 8)/duration
|
||||||
bitrateKilobits = round(bitrateKilobits)
|
bitrateKilobits = round(bitrateKilobits)
|
||||||
|
else:
|
||||||
|
bitrateKilobits = 800
|
||||||
print("Calced bitrate = " + str(bitrateKilobits))
|
print("Calced bitrate = " + str(bitrateKilobits))
|
||||||
ffmpeg.input(fileName).output("small_" + fileName, **{'b:v': str(bitrateKilobits) + 'k', 'threads': '4'}).run()
|
ffmpeg.input(fileName).output("small_" + fileName, **{'b:v': str(bitrateKilobits) + 'k', 'threads': '4'}).run()
|
||||||
with open("small_" + fileName, 'rb') as fp:
|
with open("small_" + fileName, 'rb') as fp:
|
||||||
|
|||||||
Reference in New Issue
Block a user