wudududu / extract-video-ppt

extract the ppt in the video
MIT License
336 stars 32 forks source link

Invalid value for parameter "new_x" #2

Closed venturi123 closed 2 years ago

venturi123 commented 2 years ago

Hi @wudududu,

I met an error on Win10 by using evp .\ .\1.mp4. It did extract complete figures but did not generate a PDF file as expected.

Here is the traceback about this error.

process:100%
Traceback (most recent call last):
  File "c:\users\wangq\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\wangq\miniconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\wangq\miniconda3\Scripts\evp.exe\__main__.py", line 7, in <module>
  File "c:\users\wangq\miniconda3\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\wangq\miniconda3\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "c:\users\wangq\miniconda3\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\wangq\miniconda3\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "c:\users\wangq\miniconda3\lib\site-packages\video2ppt\video2ppt.py", line 55, in main
    exportPdf()
  File "c:\users\wangq\miniconda3\lib\site-packages\video2ppt\video2ppt.py", line 154, in exportPdf
    images2pdf(pdfPath, imagePaths, CV_CAP_PROP_FRAME_WIDTH, CV_CAP_PROP_FRAME_HEIGHT)
  File "c:\users\wangq\miniconda3\lib\site-packages\video2ppt\images2pdf.py", line 12, in images2pdf
    pdf.cell(400, titleH, os.path.basename(image), 1, 1, 'C')
  File "c:\users\wangq\miniconda3\lib\site-packages\fpdf\fpdf.py", line 265, in wrapper
    return fn(self, *args, **kwargs)
  File "c:\users\wangq\miniconda3\lib\site-packages\fpdf\fpdf.py", line 2270, in cell
    raise ValueError(
ValueError: Invalid value for parameter "new_x" (1),must be instance of Enum XPos
wudududu commented 2 years ago

After testing the demo.mp4 can work on win10. Maybe you can upload the 1.mp4.

venturi123 commented 2 years ago

Thanks for your rapid reply,

I've sent this video to your QQ e-mail.

Please check it.

LXF-DX3906 commented 2 years ago

I had the same problem. You can fix this by changing line 12 in "c:\users\wangq\miniconda3\lib\site-packages\video2ppt\images2pdf.py". instead of

pdf.cell(400, titleH, os.path.basename(image), 1, 1, 'C')

use

pdf.cell(400, titleH, os.path.basename(image), 1, ln=1, align='C')

or First, add this right below your import statement:

from fpdf.enums import XPos, YPos

and change line 12 to

pdf.cell(400, titleH, os.path.basename(image), 1, new_x=XPos.LMARGIN, new_y=YPos.NEXT, align='C')

I found that the problem was due to API changes in the FPDF library. Snipaste_2022-04-22_10-46-53.png

venturi123 commented 2 years ago

Yes, that's where the problem lies. It's work now!

wudududu commented 2 years ago

@LXF-DX3906 Thanks for your suggestion. @venturi123 The problem has been fixed in the latest version.