Comments (9)
Works great thank a lot, all good for now so I proceed to close this issue. :)
from pysubs2.
Hi, I've replicated your result with current release (1.0.0, 7159a89):
python -m pysubs2 --to srt original.ass
and I got the same output as you did (5.srt
).
- In the original ASS file, there are three kinds of lines: (1), (2) and (3), where only (1) should ideally be written to the SRT file.
- (2) is being skipped in the current version, so that's good.
- As for (3), I'm not sure how pysubs should tell the difference between (1) and (3)? Both are dialogue lines with some override tags.
(1) Regular dialogue, possibly with override tags
These are handled OK, tags are stripped.
Dialogue: 0,0:24:06.04,0:24:11.01,Signs,,0,0,0,,{\fnAdobe Garamond Pro\b0\bord4\blur4\c&H060706&\3c&H060706&\fs73\pos(960,654.143)}Warrior
2635
00:24:06,040 --> 00:24:11,010
Warrior
(2) ASS drawing tags, {\p}
These are handled OK, skipped for SRT output (thanks to #31).
Dialogue: 13,0:00:20.65,0:00:20.85,OP-E,,0,0,0,,{\an5\pos(926.695,148.500)\fad(50,50)\bord0\1c&HFFFFFF&\blur2\alpha&H53&\p1}m 0 5 b 0 5 0 0 5 0 5 0 10 0 10 5 10 5 10 10 5 10 5 10 0 10 0 5
(nothing)
(3) Rendered karaoke lines
These are written to the output SRT, which is unfortunate.
Dialogue: 10,0:00:07.24,0:00:10.03,OP-E,,0,0,0,,{\an5\pos(655.758,142.500)\1c&H4E4AFB&\3c&H4E4AFB&\blur2.4\bord2.5\fad(300,300)}I
1
00:00:07,240 --> 00:00:10,030
I
from pysubs2.
would it be possible to force-delete the lines that gives out only 1 letter?
from pysubs2.
would it be possible to force-delete the lines that gives out only 1 letter?
Sure :) I'd make it optional though, so that no visible subtitles are deleted by default. Would adding a new commandline parameter, something like --clean
, work for you? Ie.:
python -m pysubs2 --to srt --clean original.ass
from pysubs2.
that would be really awesome :)
from pysubs2.
I've released version 1.1.0 of the library, which includes --clean
:) You can test it and then we can close the issue.
from pysubs2.
I just tested it and works amazingly, while testing it I found this:
00:25:35,120 --> 00:25:43,810
涙ã�ªã‚“ã�¦è¦‹ã�›ã�ªã�„ã‚“ã�
Not sure if this could be related but let me know if yes or not to close this issue
Thank you
Archive 21.zip
from pysubs2.
Oh, I see. That's not related to --clean
, it's the character encoding. Please try:
python -m pysubs2 --to srt --clean --input-enc utf8 original.ass
That should fix the problem. I will look into this if it could be handled better in the CLI for some future release.
from pysubs2.
@tkarabela it does not work on me as expected on library mode.
it adds karaokes that are only 2 letter
def extract_and_convert_subs(mkv_file, sub_index, untranslated_path):
base_file = mkv_file.with_suffix('')
extracted_sub_file = untranslated_path / f"{base_file.name}.ass"
# Extract the subtitle in its original format
subprocess.run(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-i', str(mkv_file), '-map', f'0:s:{sub_index}', f'{extracted_sub_file}'], check=True)
# Check if the subtitle format is ASS and convert it to SRT if necessary
with open(extracted_sub_file, 'r', encoding='utf-8') as f:
first_line = f.readline()
if first_line.startswith('[Script Info]'):
ass_subs = pysubs2.load(str(extracted_sub_file), encoding="utf-8")
srt_file = untranslated_path / f"{base_file.name}.srt"
ass_subs.remove_miscellaneous_events()
ass_subs.save(str(srt_file), format_='srt', encoding="utf-8")
os.remove(str(extracted_sub_file))
else:
extracted_sub_file.rename(untranslated_path / f"{base_file.name}.srt")
from pysubs2.
Related Issues (20)
- create a new ass subtitle file but not work in player at all HOT 2
- Support timestamps without ms HOT 4
- ssaevent hashable? HOT 2
- text retuen all the content with color and other tag in pysubs2 HOT 2
- [QA] DeprecationWarning while running tests
- Doesn't work in Python 3.11 HOT 3
- Correction ms_to_frames/frames_to_ms/ms_to_str HOT 21
- Possible integration point with openai/whisper output HOT 4
- Support for Graphics section HOT 3
- [QA] DeprecationWarning in tests: 'alignment' attribute should be an Alignment instance
- SRT to ASS conversion cap at 10h timecode HOT 2
- tutorial.rst has a spelling issue in line 60 HOT 1
- [Feature Request] Handle WebVtt cue settings HOT 2
- Error: Framerate must be specified when writing MicroDVD. HOT 1
- ASS to SRT/WebVTT cue ordering HOT 2
- Is there a way to add braces to the SRT file? HOT 4
- microdvd parser should read fps only from first line with {1}{1} prefix HOT 11
- Python inline convert sup to srt HOT 3
- Support for OpenAI Whisper transcription from CLI HOT 2
- remove misc. events problem. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysubs2.