PixivUtil2: Ugoira FFMPEG permission denied during conversion

Prerequisites

  • [y] Did you read FAQ section in readme.md?
  • [y ] Did you test with the latest releases or commit ?
  • [ y] Did you search for existing issues in Issues?

Description

Unknown Error, please check the log file: (<class ‘PermissionError’>, PermissionError(13, ‘The process cannot access the file because it is being used by another process’), <traceback object at 0x00000162F7FE92C0>)

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’

Highly random, some download fine, others error. Experiencing this error for at least a month.

Steps to Reproduce

Download random ugoira and convert

Expected behavior: [What you expected to happen] Download and convert to gif & webm Actual behavior: [What actually happened] Fatal error Log file: [Attach the pixivutil.log file in the application folder, recommended to delete the old file, reproduce the issue, and upload the newly generated file here] 2022-07-03 13:42:22,945 - PixivUtil20220701 - INFO - ############################################################### 2022-07-03 13:42:22,945 - PixivUtil20220701 - INFO - Starting with argument: [C:\PixivUtil2\PixivUtil2.py]. 2022-07-03 13:42:22,945 - PixivUtil20220701 - INFO - Setting log level to: DEBUG 2022-07-03 13:42:22,945 - PixivUtil20220701 - INFO - No default cookie jar available, creating… 2022-07-03 13:42:23,102 - PixivUtil20220701 - INFO - Using default DB Path: C:\PixivUtil2\db.sqlite 2022-07-03 13:42:23,117 - PixivUtil20220701 - INFO - Using Blacklist Tags: 11 items. 2022-07-03 13:42:23,117 - PixivUtil20220701 - INFO - Using Blacklist Members: 7 members. 2022-07-03 13:42:25,439 - PixivUtil20220701 - INFO - Trying to log in with saved cookie 2022-07-03 13:42:26,615 - PixivUtil20220701 - INFO - Logging in, return url: https://www.pixiv.net/en/ 2022-07-03 13:42:26,631 - PixivUtil20220701 - INFO - Login successful. 2022-07-03 13:42:26,631 - PixivUtil20220701 - INFO - Logged in using cookie 2022-07-03 13:42:26,631 - PixivUtil20220701 - INFO - My User Id: 8870660. 2022-07-03 13:42:26,631 - PixivUtil20220701 - INFO - Premium User: False. 2022-07-03 13:42:26,631 - PixivUtil20220701 - INFO - Locale = /en 2022-07-03 13:42:26,701 - PixivUtil20220701 - INFO - Using Blacklist Tags: 11 items. 2022-07-03 13:42:26,709 - PixivUtil20220701 - INFO - Using Blacklist Members: 7 members. 2022-07-03 13:42:39,797 - PixivUtil20220701 - INFO - Image id mode (2). 2022-07-03 13:42:41,104 - PixivUtil20220701 - DEBUG - Getting image page: 83158226 2022-07-03 13:42:41,470 - PixivUtil20220701 - DEBUG - New UI Mode 2022-07-03 13:42:42,023 - PixivUtil20220701 - DEBUG - using webrpc: https://www.pixiv.net/rpc/get_work.php?id=83158226 2022-07-03 13:42:43,202 - PixivUtil20220701 - DEBUG - Sanitized Filename: C:\01\wirai (10428223)\83158226_ugoira1920x1080 - Maid suit.zip 2022-07-03 13:42:43,203 - PixivUtil20220701 - INFO - Filename : C:\01\wirai (10428223)\83158226_ugoira1920x1080 - Maid suit.zip 2022-07-03 13:42:43,204 - PixivUtil20220701 - INFO - Creating directory: C:\01\wirai (10428223) 2022-07-03 13:42:43,207 - PixivUtil20220701 - INFO - Using Referer: https://www.pixiv.net/artworks/83158226 2022-07-03 13:42:43,787 - PixivUtil20220701 - INFO - Using Referer: https://www.pixiv.net/artworks/83158226 2022-07-03 13:42:55,743 - PixivUtil20220701 - INFO - done. 2022-07-03 13:42:55,744 - PixivUtil20220701 - INFO - Creating ugoira archive => C:\01\wirai (10428223)\83158226_ugoira1920x1080 - Maid suit.ugoira 2022-07-03 13:42:55,751 - PixivUtil20220701 - INFO - Processing ugoira to animated gif… 2022-07-03 13:42:55,908 - PixivUtil20220701 - DEBUG - Procced to change C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg image for a pixel format with 3 components 2022-07-03 13:42:55,908 - PixivUtil20220701 - INFO - [re_encode_image()] running with cmd: ffmpeg -i C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg -pix_fmt gbrpf32be C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139_temp.jpg 2022-07-03 13:42:55,912 - PixivUtil20220701 - DEBUG - Start re_encoding image C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg 2022-07-03 13:42:56,015 - PixivUtil20220701 - ERROR - Error at process_image(): 83158226 2022-07-03 13:42:56,016 - PixivUtil20220701 - ERROR - Traceback (most recent call last): File “C:\PixivUtil2\PixivHelper.py”, line 1053, in convert_ugoira check_image_encoding(d) File “C:\PixivUtil2\PixivHelper.py”, line 1162, in check_image_encoding re_encode_image(re_encode_channel, file) File “C:\PixivUtil2\PixivHelper.py”, line 1193, in re_encode_image raise PixivException(“error”, f"Failed when converting image using {cmd} ==> ffmpeg return exit code={p.returncode}, expected to return 0.", errorCode=PixivException.OTHER_ERROR) PixivException.PixivException: PixivException(9999 error, hasDumpPage=N)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\PixivUtil2\PixivImageHandler.py”, line 336, in process_image PixivDownloadHandler.handle_ugoira(image, filename, config, notifier) File “C:\PixivUtil2\PixivDownloadHandler.py”, line 384, in handle_ugoira PixivHelper.ugoira2gif(ugo_name, File “C:\PixivUtil2\PixivHelper.py”, line 967, in ugoira2gif convert_ugoira(ugoira_file, File “C:\PixivUtil2\PixivHelper.py”, line 1080, in convert_ugoira shutil.rmtree(d) File “C:\Python310\lib\shutil.py”, line 739, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Python310\lib\shutil.py”, line 617, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Python310\lib\shutil.py”, line 615, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’

2022-07-03 13:42:56,018 - PixivUtil20220701 - ERROR - Exception: (<class ‘PermissionError’>, PermissionError(13, ‘The process cannot access the file because it is being used by another process’), <traceback object at 0x00000162F7FF2AC0>) 2022-07-03 13:42:56,019 - PixivUtil20220701 - ERROR - Traceback (most recent call last): File “C:\PixivUtil2\PixivHelper.py”, line 1053, in convert_ugoira check_image_encoding(d) File “C:\PixivUtil2\PixivHelper.py”, line 1162, in check_image_encoding re_encode_image(re_encode_channel, file) File “C:\PixivUtil2\PixivHelper.py”, line 1193, in re_encode_image raise PixivException(“error”, f"Failed when converting image using {cmd} ==> ffmpeg return exit code={p.returncode}, expected to return 0.", errorCode=PixivException.OTHER_ERROR) PixivException.PixivException: PixivException(9999 error, hasDumpPage=N)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\PixivUtil2\PixivImageHandler.py”, line 336, in process_image PixivDownloadHandler.handle_ugoira(image, filename, config, notifier) File “C:\PixivUtil2\PixivDownloadHandler.py”, line 384, in handle_ugoira PixivHelper.ugoira2gif(ugo_name, File “C:\PixivUtil2\PixivHelper.py”, line 967, in ugoira2gif convert_ugoira(ugoira_file, File “C:\PixivUtil2\PixivHelper.py”, line 1080, in convert_ugoira shutil.rmtree(d) File “C:\Python310\lib\shutil.py”, line 739, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Python310\lib\shutil.py”, line 617, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Python310\lib\shutil.py”, line 615, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’

2022-07-03 13:42:56,019 - PixivUtil20220701 - DEBUG - Sanitized Filename: Error medium page for image 83158226.html 2022-07-03 13:42:56,020 - PixivUtil20220701 - ERROR - Dumping html to: Error medium page for image 83158226.html 2022-07-03 13:42:56,021 - PixivUtil20220701 - ERROR - Traceback (most recent call last): File “C:\PixivUtil2\PixivHelper.py”, line 1053, in convert_ugoira check_image_encoding(d) File “C:\PixivUtil2\PixivHelper.py”, line 1162, in check_image_encoding re_encode_image(re_encode_channel, file) File “C:\PixivUtil2\PixivHelper.py”, line 1193, in re_encode_image raise PixivException(“error”, f"Failed when converting image using {cmd} ==> ffmpeg return exit code={p.returncode}, expected to return 0.", errorCode=PixivException.OTHER_ERROR) PixivException.PixivException: PixivException(9999 error, hasDumpPage=N)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\PixivUtil2\PixivImageHandler.py”, line 336, in process_image PixivDownloadHandler.handle_ugoira(image, filename, config, notifier) File “C:\PixivUtil2\PixivDownloadHandler.py”, line 384, in handle_ugoira PixivHelper.ugoira2gif(ugo_name, File “C:\PixivUtil2\PixivHelper.py”, line 967, in ugoira2gif convert_ugoira(ugoira_file, File “C:\PixivUtil2\PixivHelper.py”, line 1080, in convert_ugoira shutil.rmtree(d) File “C:\Python310\lib\shutil.py”, line 739, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Python310\lib\shutil.py”, line 617, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Python310\lib\shutil.py”, line 615, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’

2022-07-03 13:42:56,036 - PixivUtil20220701 - ERROR - Unknown Error: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’ Traceback (most recent call last): File “C:\PixivUtil2\PixivHelper.py”, line 1053, in convert_ugoira check_image_encoding(d) File “C:\PixivUtil2\PixivHelper.py”, line 1162, in check_image_encoding re_encode_image(re_encode_channel, file) File “C:\PixivUtil2\PixivHelper.py”, line 1193, in re_encode_image raise PixivException(“error”, f"Failed when converting image using {cmd} ==> ffmpeg return exit code={p.returncode}, expected to return 0.", errorCode=PixivException.OTHER_ERROR) PixivException.PixivException: PixivException(9999 error, hasDumpPage=N)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\PixivUtil2\PixivUtil2.py”, line 1725, in main np_is_valid, op_is_valid, selection = main_loop(ewd, op_is_valid, selection, np_is_valid, args, options) File “C:\PixivUtil2\PixivUtil2.py”, line 1399, in main_loop menu_download_by_image_id(op_is_valid, args, options) File “C:\PixivUtil2\PixivUtil2.py”, line 342, in menu_download_by_image_id PixivImageHandler.process_image(sys.modules[name], File “C:\PixivUtil2\PixivImageHandler.py”, line 336, in process_image PixivDownloadHandler.handle_ugoira(image, filename, config, notifier) File “C:\PixivUtil2\PixivDownloadHandler.py”, line 384, in handle_ugoira PixivHelper.ugoira2gif(ugo_name, File “C:\PixivUtil2\PixivHelper.py”, line 967, in ugoira2gif convert_ugoira(ugoira_file, File “C:\PixivUtil2\PixivHelper.py”, line 1080, in convert_ugoira shutil.rmtree(d) File “C:\Python310\lib\shutil.py”, line 739, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Python310\lib\shutil.py”, line 617, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Python310\lib\shutil.py”, line 615, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’ 2022-07-03 13:42:56,039 - PixivUtil20220701 - ERROR - Unknown Error, please check the log file: (<class ‘PermissionError’>, PermissionError(13, ‘The process cannot access the file because it is being used by another process’), <traceback object at 0x00000162F7FE92C0>) 2022-07-03 13:42:56,040 - PixivUtil20220701 - ERROR - Traceback (most recent call last): File “C:\PixivUtil2\PixivHelper.py”, line 1053, in convert_ugoira check_image_encoding(d) File “C:\PixivUtil2\PixivHelper.py”, line 1162, in check_image_encoding re_encode_image(re_encode_channel, file) File “C:\PixivUtil2\PixivHelper.py”, line 1193, in re_encode_image raise PixivException(“error”, f"Failed when converting image using {cmd} ==> ffmpeg return exit code={p.returncode}, expected to return 0.", errorCode=PixivException.OTHER_ERROR) PixivException.PixivException: PixivException(9999 error, hasDumpPage=N)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “C:\PixivUtil2\PixivUtil2.py”, line 1725, in main np_is_valid, op_is_valid, selection = main_loop(ewd, op_is_valid, selection, np_is_valid, args, options) File “C:\PixivUtil2\PixivUtil2.py”, line 1399, in main_loop menu_download_by_image_id(op_is_valid, args, options) File “C:\PixivUtil2\PixivUtil2.py”, line 342, in menu_download_by_image_id PixivImageHandler.process_image(sys.modules[name], File “C:\PixivUtil2\PixivImageHandler.py”, line 336, in process_image PixivDownloadHandler.handle_ugoira(image, filename, config, notifier) File “C:\PixivUtil2\PixivDownloadHandler.py”, line 384, in handle_ugoira PixivHelper.ugoira2gif(ugo_name, File “C:\PixivUtil2\PixivHelper.py”, line 967, in ugoira2gif convert_ugoira(ugoira_file, File “C:\PixivUtil2\PixivHelper.py”, line 1080, in convert_ugoira shutil.rmtree(d) File “C:\Python310\lib\shutil.py”, line 739, in rmtree return _rmtree_unsafe(path, onerror) File “C:\Python310\lib\shutil.py”, line 617, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File “C:\Python310\lib\shutil.py”, line 615, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘C:/Users/1/AppData/Local/Temp/convert_ugoirab7yr3559\000139.jpg’

Versions

You can get this information from executing PixivUtil2.py --help. Latest Commit as of 7/3/2022 1:00PM

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@Toyem was Windows fix tested in a Linux environment?

import os
directory = '/pixiv'
filename = 'image.png'
combined = os.path.join(directory, os.sep, filename)
print(combined)

On linux, this produces /image.png as the output, not /pixiv/image.png

Thanks for tracking it down. I’ve only encountered it a couple more times since this post and it’s quickly fixable from my end with a quick Irfanview reencode, so I’ll just wait for the fix in the next build. My system python is a mess due to other programs so I end up using the exes.