apm1467 / videocr

Extract hardcoded subtitles from videos using machine learning
MIT License
506 stars 117 forks source link

404 error by using the example code #46

Open languagemaniac opened 1 year ago

languagemaniac commented 1 year ago

Hi, I'm using the example code but changed eng for jpn, like this:

from videocr import get_subtitles

if __name__ == '__main__':  # This check is mandatory for Windows.
    print(get_subtitles('video.mp4', lang='chi_sim+jpn', sim_threshold=70, conf_threshold=65))

However, I'm getting this result:

Traceback (most recent call last):
  File "/media/user/hdd/test.py", line 6, in <module>
    print(get_subtitles('video.mp4', lang='chi_sim+jpn', sim_threshold=70, conf_threshold=65))
  File "/home/user/.local/lib/python3.10/site-packages/videocr/api.py", line 8, in get_subtitles
    utils.download_lang_data(lang)
  File "/home/user/.local/lib/python3.10/site-packages/videocr/utils.py", line 21, in download_lang_data
    with urlopen(url) as res, open(filepath, 'w+b') as f:
  File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
  File "/usr/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

I manually downloaded chi_sim.traineddata and jpn.traineddata and placed them on tessdata folder, but still getting this error.

I'm using Linux mint 21

alexposito commented 1 year ago

I just had the same problem. Here is explained how to fix it ;)

languagemaniac commented 1 year ago

I just had the same problem. Here is explained how to fix it ;)

Thanks! Will try