mirror of
https://github.com/Steffo99/bbbdl.git
synced 2024-11-21 23:34:19 +00:00
🧹 Wrap everything in a __name__ == "__main__"
This commit is contained in:
parent
9fad3e894d
commit
0d0843545d
1 changed files with 46 additions and 45 deletions
|
@ -10,9 +10,6 @@ videoSuffix = "/deskshare/deskshare.webm"
|
||||||
audioSuffix = "/video/webcams.mp4"
|
audioSuffix = "/video/webcams.mp4"
|
||||||
# slides = "https://davy04.edunova.it/presentation/17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1601024050226/shapes.svg"
|
# slides = "https://davy04.edunova.it/presentation/17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1601024050226/shapes.svg"
|
||||||
|
|
||||||
os.makedirs("VideoLezioni", exist_ok=True)
|
|
||||||
os.chdir("VideoLezioni")
|
|
||||||
|
|
||||||
# Dictionary containing the id of the saved lessons
|
# Dictionary containing the id of the saved lessons
|
||||||
meetingsID = {
|
meetingsID = {
|
||||||
'021020': '17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1601628738707',
|
'021020': '17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1601628738707',
|
||||||
|
@ -22,59 +19,63 @@ meetingsID = {
|
||||||
'091020': '17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1602232967548',
|
'091020': '17d59e4eb742c498e605406fd441c1a2d7eb4bf0-1602232967548',
|
||||||
}
|
}
|
||||||
|
|
||||||
for (date, meetId) in meetingsID.items():
|
if __name__ == "__main__":
|
||||||
if os.path.exists(f"Gestione{date}joinedWithSlide.mp4"):
|
os.makedirs("VideoLezioni", exist_ok=True)
|
||||||
print("Il video e' gia' stato scaricato")
|
os.chdir("VideoLezioni")
|
||||||
continue
|
|
||||||
|
|
||||||
# Assemblo il comando ffmpeg con i riferimenti web a video e audio della presentazione con id {meetId}
|
for (date, meetId) in meetingsID.items():
|
||||||
downloadAndJoin = f"ffmpeg -i {edunovaLink}{meetId}{videoSuffix} -i {edunovaLink}{meetId}{audioSuffix} -map 0:v -map 1:a -c:v copy -shortest Gestione{date}joined.mp4"
|
if os.path.exists(f"Gestione{date}joinedWithSlide.mp4"):
|
||||||
os.system(downloadAndJoin)
|
print("Il video e' gia' stato scaricato")
|
||||||
svgSlide = urllib.request.urlopen(f"{edunovaLink}{meetId}/shapes.svg").read()
|
continue
|
||||||
|
|
||||||
soup = BeautifulSoup(svgSlide, 'html.parser')
|
# Assemblo il comando ffmpeg con i riferimenti web a video e audio della presentazione con id {meetId}
|
||||||
usefulImg = []
|
downloadAndJoin = f"ffmpeg -i {edunovaLink}{meetId}{videoSuffix} -i {edunovaLink}{meetId}{audioSuffix} -map 0:v -map 1:a -c:v copy -shortest Gestione{date}joined.mp4"
|
||||||
for img in soup.find_all('image'):
|
os.system(downloadAndJoin)
|
||||||
|
svgSlide = urllib.request.urlopen(f"{edunovaLink}{meetId}/shapes.svg").read()
|
||||||
|
|
||||||
start = img.get('in')
|
soup = BeautifulSoup(svgSlide, 'html.parser')
|
||||||
end = img.get('out')
|
usefulImg = []
|
||||||
imgLink = img.get('xlink:href')
|
for img in soup.find_all('image'):
|
||||||
if not imgLink.endswith("deskshare.png"):
|
|
||||||
usefulImg.append([float(start), float(end), imgLink])
|
|
||||||
|
|
||||||
imgSorted = sorted(usefulImg)
|
start = img.get('in')
|
||||||
print(imgSorted)
|
end = img.get('out')
|
||||||
if len(imgSorted) == 0:
|
imgLink = img.get('xlink:href')
|
||||||
os.rename(f"Gestione{date}joined.mp4", f"Gestione{date}joinedWithSlide.mp4")
|
if not imgLink.endswith("deskshare.png"):
|
||||||
continue
|
usefulImg.append([float(start), float(end), imgLink])
|
||||||
|
|
||||||
slideBase = f"{edunovaLink}{meetId}/"
|
imgSorted = sorted(usefulImg)
|
||||||
|
print(imgSorted)
|
||||||
|
if len(imgSorted) == 0:
|
||||||
|
os.rename(f"Gestione{date}joined.mp4", f"Gestione{date}joinedWithSlide.mp4")
|
||||||
|
continue
|
||||||
|
|
||||||
imgLinkList = ''
|
slideBase = f"{edunovaLink}{meetId}/"
|
||||||
imgScaleList = ''
|
|
||||||
for l in imgSorted:
|
|
||||||
imgLinkList += f"-i \"{slideBase}{l[2]}\" "
|
|
||||||
|
|
||||||
for i in range(len(imgSorted)):
|
imgLinkList = ''
|
||||||
imgScaleList += f"[{i + 1}:v] scale=1280:720 [ol{i}]; "
|
imgScaleList = ''
|
||||||
|
for l in imgSorted:
|
||||||
|
imgLinkList += f"-i \"{slideBase}{l[2]}\" "
|
||||||
|
|
||||||
imgOverlayList = f"[0:v] [ol0] overlay=0:0:enable='between(t,{int(imgSorted[0][0])},{int(imgSorted[0][1])})' [olo0]; "
|
for i in range(len(imgSorted)):
|
||||||
|
imgScaleList += f"[{i + 1}:v] scale=1280:720 [ol{i}]; "
|
||||||
|
|
||||||
for i in range(1, len(imgSorted) - 1):
|
imgOverlayList = f"[0:v] [ol0] overlay=0:0:enable='between(t,{int(imgSorted[0][0])},{int(imgSorted[0][1])})' [olo0]; "
|
||||||
imgOverlayList += f"[olo{i - 1}] [ol{i}] overlay=0:0:enable='between(t,{int(imgSorted[i][0])},{int(imgSorted[i][1])})' [olo{i}]; "
|
|
||||||
|
|
||||||
imgOverlayList += f"[olo{len(imgSorted) - 1 - 1}] [ol{len(imgSorted) - 1}] overlay=0:0:enable='between(t,{int(imgSorted[len(imgSorted) - 1][0])},{int(imgSorted[len(imgSorted) - 1][1])})'"
|
for i in range(1, len(imgSorted) - 1):
|
||||||
|
imgOverlayList += f"[olo{i - 1}] [ol{i}] overlay=0:0:enable='between(t,{int(imgSorted[i][0])},{int(imgSorted[i][1])})' [olo{i}]; "
|
||||||
|
|
||||||
# Informazioni di debug sulle immagini e sui momenti nei quali inserirle nel video
|
imgOverlayList += f"[olo{len(imgSorted) - 1 - 1}] [ol{len(imgSorted) - 1}] overlay=0:0:enable='between(t,{int(imgSorted[len(imgSorted) - 1][0])},{int(imgSorted[len(imgSorted) - 1][1])})'"
|
||||||
print(imgLinkList)
|
|
||||||
print(imgScaleList)
|
|
||||||
print(imgOverlayList)
|
|
||||||
|
|
||||||
# Comando di esempio di utilizzo di ffmpeg per incollare diverse immagini in diversi momenti su un video
|
# Informazioni di debug sulle immagini e sui momenti nei quali inserirle nel video
|
||||||
# ffmpeg -i Untitled.mp4 -i slide-1.png -i slide-2.png -filter_complex "[1:v] scale=640:480 [ol]; [2:v] scale=640:480 [ol2]; [0:v] [ol] overlay=0:0:enable='between(t,0,20)' [ol1]; [ol1] [ol2] overlay=0:0:enable='between(t, 30,40)'" -codec:a copy example_marked.mp4
|
print(imgLinkList)
|
||||||
|
print(imgScaleList)
|
||||||
|
print(imgOverlayList)
|
||||||
|
|
||||||
ffmpegCommand = f'ffmpeg -i Gestione{date}joined.mp4 {imgLinkList} -filter_complex "{imgScaleList}{imgOverlayList}" -codec:a copy Gestione{date}joinedWithSlide.mp4'
|
# Comando di esempio di utilizzo di ffmpeg per incollare diverse immagini in diversi momenti su un video
|
||||||
|
# ffmpeg -i Untitled.mp4 -i slide-1.png -i slide-2.png -filter_complex "[1:v] scale=640:480 [ol]; [2:v] scale=640:480 [ol2]; [0:v] [ol] overlay=0:0:enable='between(t,0,20)' [ol1]; [ol1] [ol2] overlay=0:0:enable='between(t, 30,40)'" -codec:a copy example_marked.mp4
|
||||||
|
|
||||||
os.system(ffmpegCommand)
|
ffmpegCommand = f'ffmpeg -i Gestione{date}joined.mp4 {imgLinkList} -filter_complex "{imgScaleList}{imgOverlayList}" -codec:a copy Gestione{date}joinedWithSlide.mp4'
|
||||||
# Rimuovo il file intermedio senza slide
|
|
||||||
os.remove(f"Gestione{date}joined.mp4")
|
os.system(ffmpegCommand)
|
||||||
|
# Rimuovo il file intermedio senza slide
|
||||||
|
os.remove(f"Gestione{date}joined.mp4")
|
||||||
|
|
Loading…
Reference in a new issue