Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"cannot identify image file %r" % #86

Open
jhemmmm opened this issue Jun 12, 2020 · 7 comments
Open

"cannot identify image file %r" % #86

jhemmmm opened this issue Jun 12, 2020 · 7 comments
Labels

Comments

@jhemmmm
Copy link

jhemmmm commented Jun 12, 2020

I have been using vcsi for a long time. And i'd like to fix this issue.

The command "/usr/bin/vcsi /home/402c5ce63718915e685fa897dd5569a8 --grid-horizontal-spacing 0 --grid-vertical-spacing 0 -fast --quality 80 -w 852 -g 4x4 --metadata-position hidden -o /home/402c5ce63718915e685fa897dd5569a8poster_output.jpg" failed.

Exit Code: 1(General error)

Working directory: /home/apivcsi

Output:

Processing /home/402c5ce63718915e685fa897dd5569a8...
Sampling... 1/16
Sampling... 2/16
Sampling... 3/16
Sampling... 4/16
Sampling... 5/16
Sampling... 6/16
Sampling... 7/16
Sampling... 8/16

Error Output:

Traceback (most recent call last):
File "/usr/bin/vcsi", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/vcsi/init.py", line 3, in main
vcsi.vcsi.main()
File "/usr/local/lib/python3.6/site-packages/vcsi/vcsi.py", line 1518, in main
process_file(filename, args)
File "/usr/local/lib/python3.6/site-packages/vcsi/vcsi.py", line 1646, in process_file
selected_frames, temp_frames = select_sharpest_images(media_info, media_capture, args)
File "/usr/local/lib/python3.6/site-packages/vcsi/vcsi.py", line 658, in select_sharpest_images
frame = do_capture(timestamp_tuple, desired_size[0], desired_size[1], suffix, args)
File "/usr/local/lib/python3.6/site-packages/vcsi/vcsi.py", line 618, in do_capture
blurriness = media_capture.compute_blurriness(filename)
File "/usr/local/lib/python3.6/site-packages/vcsi/vcsi.py", line 514, in compute_blurriness
i = Image.open(image_path)
File "/usr/local/lib64/python3.6/site-packages/PIL/Image.py", line 2896, in open
"cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file '/tmp/tmpi_8t0e0v.png'

@derberherbert
Copy link

Had the same issue. The temp file was 0 KB big.
Calling ffmpeg from the command line revealed a broken ffmpeg installation. Reinstalled ffmpeg, confirmed it was executable without error and vcsi worked without errors again.

@jhemmmm
Copy link
Author

jhemmmm commented Jun 15, 2020

Yes, ffmpeg works perfectly. I am using pre-build
https://www.johnvansickle.com/

@amietn amietn added the bug label Oct 15, 2020
@Chaz6
Copy link

Chaz6 commented Jan 9, 2021

I am experiencing this too. This is especially annoying because when I pass a list of files and it stops halfway through (I usually use it like this $ vcsi folder/**/*.mkv so I have to manually remove the file causing the issue, re-run vcsi, then put the file back. That said, thanks for working on vcsi!

@bydioeds
Copy link

bydioeds commented Jun 7, 2022

I just had the same issue, seems like the cause is due to the duration of the file?
Reaching more than 18 samples is the issue in this specific file.

The following commands work fine:

vcsi -t -g 3x3 -w 905 *.mp4
vcsi -t -g 4x4 -w 905 *.mp4
vcsi -t -g 6x3 -w 905 *.mp4
vcsi -t -g 9x2 -w 905 *.mp4

The following throws the error:
vcsi -t -g 7x3 -w 905 *.mp4
vcsi -t -g 5x5 -w 905 *.mp4
vcsi -t -g 1x19 -w 905 *.mp4

Traceback (most recent call last):
  File "/root/x/x/venv/bin/vcsi", line 8, in <module>
    sys.exit(main())
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/__init__.py", line 3, in main
    vcsi.vcsi.main()
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 1634, in main
    process_file_or_ignore(filename, args)
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 1608, in process_file_or_ignore
    process_file(filepath, args)
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 1762, in process_file
    selected_frames, temp_frames = select_sharpest_images(media_info, media_capture, args)
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 738, in select_sharpest_images
    frame = do_capture(timestamp_tuple, desired_size[0], desired_size[1], suffix, args)
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 698, in do_capture
    blurriness = media_capture.compute_blurriness(filename)
  File "/root/x/x/venv/lib/python3.10/site-packages/vcsi/vcsi.py", line 594, in compute_blurriness
    i = Image.open(image_path)
  File "/root/x/x/venv/lib/python3.10/site-packages/PIL/Image.py", line 3123, in open
    raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file '/tmp/tmp__13n2o6.bmp'

Mediainfo of the file:

General
Complete name                            : 2021-04-18_136553763_2086641288.mp4
Format                                   : MPEG-4
Codec ID                                 : M4V  (isom/avc1/mp42)
File size                                : 944 KiB
Duration                                 : 792 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 9 767 kb/s
Encoded date                             : UTC 2021-04-18 20:03:08
Tagged date                              : UTC 2021-04-18 20:03:08

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 3 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 3 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 792 ms
Bit rate mode                            : Constant
Bit rate                                 : 9 585 kb/s
Nominal bit rate                         : 6 000 kb/s
Maximum bit rate                         : 7 596 kb/s
Width                                    : 656 pixels
Height                                   : 1 232 pixels
Display aspect ratio                     : 0.532
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.495
Stream size                              : 927 KiB (98%)
Encoded date                             : UTC 2021-04-18 20:03:08
Tagged date                              : UTC 2021-04-18 20:03:08
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 768 ms
Bit rate mode                            : Variable
Bit rate                                 : 160 kb/s
Maximum bit rate                         : 124 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 15.2 KiB (2%)
Encoded date                             : UTC 2021-04-18 20:03:08
Tagged date                              : UTC 2021-04-18 20:03:08

@user222224
Copy link

I occasionally run into this error as well, it would be nice if vcsi would instead of failing completely just add a placeholder image for the erroneous frames, at least in the case if there's already a couple of frames that were calculated successfully.

A tip for those running into this issue when processing batches of files, you can add the --ignore-errors commandline switch which will cause vcsi to not stop the batch instead it will output a warning and skip to the next file in the batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants
@Chaz6 @amietn @derberherbert @bydioeds @jhemmmm @user222224 and others