BrokenPipeError: -Errno- 32 Сломанная труба - PullRequest
1 голос
/ 31 января 2020

Я получаю BrokenPipeError: [Errno 32] Ошибка сломанной трубы. Я не знаю, что я сделал не так

Я добавил shell=True, потому что у меня была другая ошибка: FileNotFoundError: [WinError 2]

from collections import Iterable
import io
import re
import subprocess

import cv2


    def ocr(img):
        ok, buf = cv2.imencode(".bmp", img)
        if not ok:
            raise Exception("Cannot encode image")

        args = ["/usr/bin/tesseract", "stdin", "stdout", "-l", subtitles_lang]
        p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, shell=True)

        p.stdin.write(buf)
        p.stdin.close()

Консоль показывает это

Aligning videos on 5 frames...
pos_diff_sec=0.0
Writing eng subtitles to subtitles.srt...
00:00:02,293 (3.10) - 00:00:03,837 (7.40) Traceback (most recent call last):
  File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 264, in <module>
    extract_subs(f, softsub_video, hardsub_video, pos_diff_sec)
  File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 229, in extract_subs
    text = ocr(sub_frame)
  File "C:/Users/simon/Documents/meltsub-master/meltsub-master/meltsub.py", line 115, in ocr
    p.stdin.write(buf)
BrokenPipeError: [Errno 32] Broken pipe

Process finished with exit code 1

Я могу выложить больше кода при необходимости

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...