Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merge video with subtitles
#21
Can you check, please, if this option works in your player (I mean if you change color) ...
[Image: vlc-options.png]
Reply
#22
(Jul-04-2022, 12:45 PM)Pavel_47 Wrote: Can you check, please, if this option works in your player (I mean if you change color) ...
No(will not do color change) it will be white(track 2) as in last image or with color an black background(Track 3).
How to get correct color and transparent background as my first image in last last post has we been trough before in Thread.
Reply
#23
Well, taking into account the following shortcomings:
  • changing subtitle color in VLC doesn't work
  • GOOD subtitle file doesn't contain color-specific instructions (i.e. <c.cyan.bg_black>Une femme d'exception a su donner</c>
    <c.cyan.bg_black>une âme à ce havre de paix.</c>)
I guess before embedding subtitles in the video, I should process the .vtt file and embed color-specific instructions in it.
Then embed using python-ffmpeg. As I know, this is the only way to process subtitles in batch mode, although at the moment I don't know how to properly construct the command in order to embed the subtitles, not burn them.
Reply
#24
There are serval was both MKVToolNix(mkvmerge) and Subtitle Edit has command line tools.
Or find a FFmpeg(the mother of all this tools) command that do all in go.
mkvmerge is fast under 20-sec,first did this:
SubtitleEdit /convert "Geo Reportage [101139-013-A].fr.vtt" "ass"
C:\Program Files\Subtitle Edit
λ mkvmerge -o geo_1.mp4 "Geo Reportage [101139-013-A].mp4" "Geo Reportage [101139-013-A].fr.ass"
mkvmerge v68.0.0 ('The Curtain') 64-bit
'Geo Reportage [101139-013-A].mp4': Using the demultiplexer for the format 'QuickTime/MP4'.
'Geo Reportage [101139-013-A].fr.ass': Using the demultiplexer for the format 'SSA/ASS subtitles'.
'Geo Reportage [101139-013-A].mp4' track 0: Using the output module for the format 'AVC/H.264'.
'Geo Reportage [101139-013-A].mp4' track 1: Using the output module for the format 'AAC'.
'Geo Reportage [101139-013-A].fr.ass' track 0: Using the output module for the format 'SSA/ASS text subtitles'.
The file 'geo_1.mp4' has been opened for writing.
'Geo Reportage [101139-013-A].mp4' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 1280/720.
Progress: 100%
The cue entries (the index) are being written...
Multiplexing took 16 seconds. 
All command line tool can be called from Python bye using subprocess module.
Here in 5k player which in my main player on Windows,no border on any size.
[Image: 81PCIG.png]
Reply
#25
(Jul-04-2022, 12:02 PM)snippsat Wrote: There is no problem at all with .ass(Subtitle Edit) and embed with MKVToolNix.
If I understand correctly, you mean that with Subtitle Edit you can change the color of the subtitles, right?
I loaded .ass file in Subtitle Edit, but didn't find how to do it.
Reply
#26
(Jul-06-2022, 01:26 PM)Pavel_47 Wrote: If I understand correctly, you mean that with Subtitle Edit you can change the color of the subtitles, right?
I loaded .ass file in Subtitle Edit, but didn't find how to do it.
Yes,of course that some of the point of this program.
This took me a minute to figure out.i have only used Subtitle Edit to save as .ass before.
Just select all text(Ctrl+a) and can start with right click(Remove all formatting) then is clean text.
Then the same right click and choice Color,eg here i choose yellow and save the .vtt as test.ass
G:\1_youtube\arte_env\Scripts
λ mkvmerge -o geo_new3.mp4 "Geo Reportage [101139-013-A].mp4" "test.ass"
mkvmerge v68.0.0 ('The Curtain') 64-bit
'Geo Reportage [101139-013-A].mp4': Using the demultiplexer for the format 'QuickTime/MP4'.
'test.ass': Using the demultiplexer for the format 'SSA/ASS subtitles'.
'Geo Reportage [101139-013-A].mp4' track 0: Using the output module for the format 'AVC/H.264'.
'Geo Reportage [101139-013-A].mp4' track 1: Using the output module for the format 'AAC'.
'test.ass' track 0: Using the output module for the format 'SSA/ASS text subtitles'.
The file 'geo_new3.mp4' has been opened for writing.
'Geo Reportage [101139-013-A].mp4' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 1280/720.
Progress: 100%
The cue entries (the index) are being written...
Multiplexing took 19 seconds.
Now is all text yellow.
[Image: RbwxPY.png]
Reply
#27
(Jul-06-2022, 01:54 PM)snippsat Wrote: Yes,of course that some of the point of this program.
This took me a minute to figure out.i have only used Subtitle Edit to save as .ass before.
Just select all text(Ctrl+a) and can start with right click(Remove all formatting) then is clean text.

Yes, works !
And mkvtools do the job correctly - when I play the file in VLC, the subtitles are indeed yellow.
Surprisingly, when I embed the same file in mmpeg, the color information isn't taken into consideration and subtitles remain white.
I tried mkvtools from Python, as you suggested.
Without doubts, I made a mistake because there is output file.

import subprocess
input_dir = 'mydir/'
video_file = 'video.mp4'
subtl_file = 'subtitles.ass'
out_file = input_dir+'output_ccc.mp4'

subprocess.run(['mkvmerge', '-o out_file', input_dir+video_file, input_dir+subtl_file])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to 'soft-embedd' subtitles with python-ffmpeg Pavel_47 2 2,115 Jul-04-2022, 12:33 PM
Last Post: Pavel_47

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020