Exemplo n.º 1
0
def deleteCorrespondingFileOfAProject(projectID: int) -> None:
    filePath = getFilePathByProjectID(projectID)
    if disk.exists(filePath):
        disk.removeAFile(filePath)

    outputPath = filePath + ".output.mp4"
    if disk.exists(outputPath):
        disk.removeAFile(outputPath)
Exemplo n.º 2
0
async def upload_file(projectID: int, file: UploadFile = File(...)):
    print(globalStore.tempFolder)
    print(file)

    if (myDatabase.checkIfProjectExistByID(projectID) is False):
        return {"error": "Project ID not exist"}

    filePath = getFilePathByProjectID(projectID)

    contents = await file.read()
    contents_bytes_io = disk.convertBytesToBytesIO(contents)
    disk.save_bytesio_to_file(contents_bytes_io, filePath)

    query = myDatabase.projects.update().where(
        myDatabase.projects.c.id == projectID).values(input=filePath)
    await myDatabase.database.execute(query)

    return {"message": "success"}
Exemplo n.º 3
0
async def async_func(project_id: int, job: str):
    project = await myDatabase.getAProjectByID(project_id)
    inputPath = project.input
    outputPath = getFilePathByProjectID(project_id) + ".output.mp4"

    await myDatabase.setStatusOfAProject(project_id, 1)

    try:
        if (job == "speedupSilence"):
            video.speedup_silence_parts_in_video(inputPath,
                                                 outputPath,
                                                 21,
                                                 speed=30)
        elif (job == "removeSilence"):
            video.remove_silence_parts_from_video(inputPath, outputPath, 35,
                                                  1.7)
    except Exception as e:
        await myDatabase.setStatusOfAProject(project_id, -1)
        raise e

    await myDatabase.updateOutputOfAProject(project_id, outputPath)
    await myDatabase.setStatusOfAProject(project_id, 2)
Exemplo n.º 4
0
async def getSilenceData(projectID: int, targetDB: int):
    filePath = getFilePathByProjectID(projectID)
    data = video._get_voice_and_silence_parts(filePath, top_db=targetDB)
    # print(data)
    return {"data": data}
Exemplo n.º 5
0
async def getAudioVolumeData(projectID: int):
    filePath = getFilePathByProjectID(projectID)
    audioData = audioAnalyzer.get_audio_loudness_per_x_millisecond(filePath, 500)
    audioData /= np.max(np.abs(audioData), axis=0)
    audioData = 1 - (-audioData)
    return {"data": audioData.tolist()}