kelciour / movies2anki

Convert movies with subtitles to watch them with Anki. Inspired by subs2srs
GNU Affero General Public License v3.0
302 stars 28 forks source link

Problem getting this to work #1

Closed audiofilter closed 8 years ago

audiofilter commented 8 years ago

Using a vagrant linux on a Mac, I'm able to get GUI up and set parameters, but when I hit Go or Preview nothing happens. On Mac itself, I have some QT incompatibilities and can't even get the GUI up. Is there a simple command line way I can use this without QT ? Or how would I modify this to do that?

kelciour commented 8 years ago

Do you have ffmpeg and ffprobe installed? In program's folder there is a file 'log.txt' (it automatically rewrites itself after closing the program). Can you copy it here. Maybe it can help to find the problem.

audiofilter commented 8 years ago

This is log file.

Video file: /vagrant/BridgeOfSpies.mp4 Audio id: 0 English subtitles: /vagrant/Bridge.of.Spies.2015.HDRip.XviD.AC3-EVO.srt Russian subtitles: /vagrant/Bridge.of.Spies.2015.HDRip.XviD.AC3.2.0-EVO SDH.srt English subtitles output: /vagrant/BridgeOfSpies.out.en.srt Russian subtitles output: /vagrant/BridgeOfSpies.out.ru.srt Write output subtitles: False Ignore SDH subtitles: True Output Directory: /vagrant Video width: 480 Video height: 320 Pad start: 0.25 Pad end: 0.25 Gap between phrases: 1.75 Split Long Phrases: False Max length phrases: 60 Mode: Phrases

Deck name: bridge

Loading English subtitles... Traceback (most recent call last): File "/vagrant/movies2anki.py", line 948, in start self.model.create_subtitles() File "/vagrant/movies2anki.py", line 527, in create_subtitles en_subs = self.load_subtitle(self.en_srt, self.is_ignore_sdh_subtitle) File "/vagrant/movies2anki.py", line 445, in load_subtitle return read_subtitles(file_content, is_ignore_SDH) File "/vagrant/movies2anki.py", line 128, in read_subtitles sub_start = srt_time_to_seconds(sub_timecode[0].strip()) File "/vagrant/movies2anki.py", line 81, in srt_time_to_seconds major, minor = (split_time[0].split(':'), split_time[1])

IndexError: list index out of range

Video file: /vagrant/BridgeOfSpies.mp4 Audio id: 0 English subtitles: /vagrant/Bridge.of.Spi

kelciour commented 8 years ago

Thanks. Can you upload 'Bridge.of.Spies.2015.HDRip.XviD.AC3-EVO.srt' here or somewhere?

audiofilter commented 8 years ago

Ah, yes. If I just use 2 english srt files, it appears to work. I think the problem is parsing a unicode srt file of format like below

subtitle.txt

This file processes OK with python package pysubs2

kelciour commented 8 years ago

subtitle.txt is correct. On windows there is no problem.

Try this: Add before line 81: "major, minor = (split_time[0].split(':'), split_time[1])" this line: "print "Time: %s" % repr(time)"

Then open program, add subs, click on "Preview", close program. Copy new log.txt here.

audiofilter commented 8 years ago

new.txt

Sorry, had to re-attach

audiofilter commented 8 years ago

Perhaps, because my video file is shorter than sub-title file is suggesting?

kelciour commented 8 years ago

Log file suddenly ends without error. After last line "Time: u'02:10:51,846" there must be a quote (') and maybe error message. But there is nothing. Strange.

No, i don't think that video length is a problem.

What about these subtitles? Friends.S05E04.The.One.Where.Phoebe.Hates.PBS_track5_eng.txt Just add it as English subtitles, then click on Preview. Is dialog with information about subtitles appeared?

audiofilter commented 8 years ago

With only English subtitles (Friends), I get a pop up box: English subtitles : 344,... from log Time: u'00:22:00,235' Time: u'00:22:02,528' Encoding: utf-8 English subtitles: 344 English sentences: 342 English phrases: 54 Loading Russian subtitles... Encoding: utf-8 Russian subtitles: 0 Syncing Russian subtitles with English phrases... Adding Pad Timings between English phrases... Adding Pad Timings between Russian phrases...

kelciour commented 8 years ago

In comment https://github.com/kelciour/movies2anki/issues/1#issuecomment-186682353 you added file newlog.txt. It appears to be correct. And before

Ah, yes. If I just use 2 english srt files, it appears to work.

What do you mean? tsv file and folder with media files was successful created? So movies2anki is working or not?

audiofilter commented 8 years ago

No, just preview worked. Now I add the other subtitle file and this is the log.txt. I think before I didn't exit the program and so log.txt was incomplete

Time: u'00:22:00,235' Time: u'00:22:02,528' Encoding: utf-8 English subtitles: 344 English sentences: 342 English phrases: 54 Loading Russian subtitles... Time: '\x00' Traceback (most recent call last): File "/vagrant/movies2anki.py", line 924, in preview self.model.create_subtitles() File "/vagrant/movies2anki.py", line 542, in create_subtitles ru_subs = self.load_subtitle(self.ru_srt, self.is_ignore_sdh_subtitle) File "/vagrant/movies2anki.py", line 446, in load_subtitle return read_subtitles(file_content, is_ignore_SDH) File "/vagrant/movies2anki.py", line 129, in read_subtitles sub_start = srt_time_to_seconds(sub_timecode[0].strip()) File "/vagrant/movies2anki.py", line 82, in srt_time_to_seconds major, minor = (split_time[0].split(':'), split_time[1]) IndexError: list index out of range

kelciour commented 8 years ago

Ok. Try open this subtitle file in AegiSub and save it with utf-8 encoding (File->Export) as srt file (just print output name with srt extension).

audiofilter commented 8 years ago

Sorry, previous comment was wrong. With 2 English only subtitles, the tsv file & media directory seemed to work & it was progressing through the encoding (i.e with progress dialog). I cancelled before it finished

kelciour commented 8 years ago

Thanks.

Please, add another line before line 129: "sub_start = srt_time_to_seconds(sub_timecode[0].strip())"

print "Subtitle: %s" % repr(sub)

And upload new log with problem srt file.

audiofilter commented 8 years ago

I don't have AegiSub, but I just noticed that the file was utf-16 and when I try

iconv -t UTF-8 Bridge.of.Spies.2015.HDRip.XviD.AC3-EVO.srt >bridge.fa.srt I get iconv: illegal input sequence at position 0

So i guess the file is messed up somehow

kelciour commented 8 years ago

Yeah, try to change srt encoding to utf-8 because movies2anki support srt files only with encoding utf-8 and cp1251.

audiofilter commented 8 years ago

Ah, I just done "dos2unix" on the srt files and now preview is working (and encoding). Thanks for the help. Perhaps pysub2 is more forgiving.

kelciour commented 8 years ago

Great!

kelciour commented 8 years ago

On Mac itself, I have some QT incompatibilities and can't even get the GUI up.

Maybe I can help? What is the problem? I don't have Mac but maybe somehow i can help =)

audiofilter commented 8 years ago

Thanks. I have parts of both QT4 & QT5 I think. I will try in a virtual python env. However, now that I have a .tsv file + media directory, how do I convert that to anki cards? Thanks Tony

On Feb 20, 2016, at 1:54 PM, Nickolay notifications@github.com wrote:

On Mac itself, I have some QT incompatibilities and can't even get the GUI up.

Maybe I can help? What is the problem? I don't have Mac but maybe somehow i can help =)

— Reply to this email directly or view it on GitHub https://github.com/kelciour/movies2anki/issues/1#issuecomment-186688396.

kelciour commented 8 years ago
  1. Open Anki. Then double click on movies2anki-sample.apkg to import into anki sample deck with movies2anki card template. If double click didn't work then use menu File->Import->
  2. Import tsv file into anki. File-Import and choose tsv file. Then in Import Dialog set Type to movies2anki, create new deck or use existing deck, check that "Fields separated by: tab" and "Import even if existing note has same first field", set checked "Allow HTML in fields". Click "Import".
  3. Move generated media files into collection.media folder in Anki (usually in Documents folder)
  4. Done.

Or check this video -> https://www.youtube.com/watch?v=Uu9oT5z08Is

kelciour commented 8 years ago

Maybe this instruction can be helpful to install Qt and PySide -> http://pyside.readthedocs.org/en/latest/installing/macosx.html