Skip to content

Subtitle synchronization with input video files. #93

@qaixerabbas

Description

@qaixerabbas

Hi everyone.

I have transcribed a video using transformers library. Now I have a temporary .txt file for video transcription. I am using pysrt for creating a .srt file for subtitles. I have created a .srt file successfully using following code.

srt_file = pysrt.SubRipFile()
srt_file.append(
    pysrt.SubRipItem(
        index=1,
        text=transcription,
        start=pysrt.SubRipTime(0, 0, 0),
        end=pysrt.SubRipTime(hours=0, minutes=0, seconds=59),
    )
)

and I am saving the resulting file using following line.
srt_file.save("video.srt", encoding="utf-8")

but I am not sure how to synchronize the video with the start and end time. I know that I can play with following two lines

        start=pysrt.SubRipTime(0, 0, 0),
        end=pysrt.SubRipTime(hours=0, minutes=0, seconds=59),

for syncing video with the .srt file. My question is that when my audio file is longer than 25 seconds, I am not able to sync it with the whole video. Is there any external library or code that I can use or any information about how can I sync the resulting .srt file with the input video?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions