Ask Your Question
0

Add subtitles to video

asked 2016-08-26 03:44:37 -0600

Mikl gravatar image

Hello,

Can i add subtitles to video file, using OpenCV?

edit retag flag offensive close merge delete

Comments

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.)

berak gravatar imageberak ( 2016-08-26 03:53:06 -0600 )edit
2

again, opencv is a computer-vision library. if you need extensive video editing, you'll have to look for something else.

berak gravatar imageberak ( 2016-08-26 03:54:23 -0600 )edit

No, i mean embedding subtitles as text in the container

Mikl gravatar imageMikl ( 2016-08-26 06:41:58 -0600 )edit

ok. wrong library for your purpose then, i guess.

berak gravatar imageberak ( 2016-08-26 06:43:53 -0600 )edit

Ok. Thanks. Do you know what i need to use? Maybe i can ADD extra library?

Mikl gravatar imageMikl ( 2016-08-26 07:18:28 -0600 )edit

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) ;)

pklab gravatar imagepklab ( 2016-08-26 10:58:26 -0600 )edit
1

VLC + .srt subtitles or FFmpeg?

Eduardo gravatar imageEduardo ( 2016-08-26 19:25:14 -0600 )edit

@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?

Mikl gravatar imageMikl ( 2016-08-30 02:25:37 -0600 )edit

.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.

Eduardo gravatar imageEduardo ( 2016-08-30 11:48:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-04-22 13:08:12 -0600

McLed gravatar image

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-26 03:44:37 -0600

Seen: 2,483 times

Last updated: Aug 26 '16