GithubHelp home page GithubHelp logo

ass to srt issue about pysubs2 HOT 9 CLOSED

tkarabela avatar tkarabela commented on May 24, 2024
ass to srt issue

from pysubs2.

Comments (9)

josscmorera avatar josscmorera commented on May 24, 2024 1

Works great thank a lot, all good for now so I proceed to close this issue. :)

from pysubs2.

tkarabela avatar tkarabela commented on May 24, 2024

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.

josscmorera avatar josscmorera commented on May 24, 2024

would it be possible to force-delete the lines that gives out only 1 letter?

from pysubs2.

tkarabela avatar tkarabela commented on May 24, 2024

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.

josscmorera avatar josscmorera commented on May 24, 2024

that would be really awesome :)

from pysubs2.

tkarabela avatar tkarabela commented on May 24, 2024

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.

josscmorera avatar josscmorera commented on May 24, 2024

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.

tkarabela avatar tkarabela commented on May 24, 2024

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.

toprak avatar toprak commented on May 24, 2024

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.