Add subtitles to video
Hello,
Can i add subtitles to video file, using OpenCV?
Hello,
Can i add subtitles to video file, using OpenCV?
You can sort of do this by using subprocess to spawn FFmpeg to extract an "SRT" stream, then read the set file.
FFmpeg command is something like this:
ffmpeg i MyVideo.mp4 -map 0:1 A.srt if subs are in the 2nd stream or ffmpeg -i MyVideo.mp4 -vn -an -c:s:0 text FirstSubStreamWithOutFontStuff.srt
Asked: 2016-08-26 03:44:37 -0600
Seen: 2,479 times
Last updated: Aug 26 '16
do you mean just printing text on the frames (YES) or embedding subtitles as text in the container (so e.g. vlc will find them ? (NO.)
again, opencv is a computer-vision library. if you need extensive video editing, you'll have to look for something else.
No, i mean embedding subtitles as text in the container
ok. wrong library for your purpose then, i guess.
Ok. Thanks. Do you know what i need to use? Maybe i can ADD extra library?
You can always store the text into separate xml file and use frameIndex as key. Than you have to build a player that reads the frame, reads the text from the file and puttext(frame,text,position...) than imshow("Live",frame) ;)
VLC + .srt subtitles or FFmpeg?
@Eduardo I need .srt. I don`t need to burn text. It is a video "metadata" and will be reused later. But can i keep it in the same video file?
.srt subtitles are only text files, you can look here an example of the structure of the file.
You can embedded subtitles with videos easily using .mkv (Matroska video format) videos.