Closed moi15moi closed 1 year ago
If possible, could you share a clip of the input video?
Sure, here is the video: https://drive.google.com/file/d/1ISJMOGSW9iHOgBaunOLBNezMqpWHWnQy/view?usp=sharing
Oh, I just realised I needed to write the extention.
from pathlib import Path
from ffmpeg import FFmpeg, Progress
def main():
video_path = Path("C:\\XXX\\video.mkv")
ffmpeg = (
FFmpeg()
.input(video_path)
.output(
"pipe:1.ass",
map=["0:4"],
)
)
subtitles = ffmpeg.execute()
if __name__ == "__main__":
main()
I would have another question. How can we use multiple output with pipe?
Currently, it merge the 2 pipe.
from ffmpeg import FFmpeg
def main():
video_path = "video.mkv"
ffmpeg = (
FFmpeg()
.input(video_path)
.output(
"pipe:4.ass",
map=["0:4"],
)
.output(
"pipe:5.ass",
map=["0:5"],
)
)
subtitles = ffmpeg.execute()
print(subtitles)
if __name__ == "__main__":
main()
I am so sorry but currently python-ffmpeg
only supports stdout
which is pipe:1
. I think you can detour this by executing ffmpeg
multiple times.
I think you can detour this by executing
ffmpeg
multiple times.
Sure, but I guess in term of performance, it is a bit faster to extract multiple subtitle in one call than call ffmpeg to extract 1 track at the time.
I saw this example: https://github.com/jonghwanhyeon/python-ffmpeg/blob/main/examples/output-as-bytes-via-stdout.py
I am currently trying to extract the subtitle with stdout:
But, I received this exception:
What can I do to avoid this exception and be able to extract the subtitle into the stdout?