I am trying to write TextClip into a video with moviepy. It has always been working, yet after I reinstalled ffmpeg, it doesn't work anymore (I am not sure whether it has caused it, but I mentioned it in case it does). Some of the TextClip objects are pure spaces.
I got the following error message:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\video\VideoClip.py", line 1137, in __init__
subprocess_call(cmd, logger=None)
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\tools.py", line 54, in subprocess_call
raise IOError(err.decode('utf8'))
OSError: magick.exe: no images for write '-write' 'PNG32:C:\Users\USER\AppData\Local\Temp\tmpmnf0fkb5.png' at CLI arg 14 # error/operation.c/CLINoImageOperator/4893.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "media_main_user.py", line 79, in <module>
insert_audio_and_subtitles(input_clip,'output.mp4','text.mp3',subtitles,fontsize=subtitles_font_size,
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 318, in insert_audio_and_subtitles
annotated_clips = [annotate(video.subclip(from_t, to_t), txt) for (from_t, to_t), txt in subtitles]
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 318, in <listcomp>
annotated_clips = [annotate(video.subclip(from_t, to_t), txt) for (from_t, to_t), txt in subtitles]
File "D:\UserData\Desktop\Project\影片剪輯\關鍵字版本\make_media.py", line 311, in annotate
txtclip = TextClip(txt, fontsize=fontsize, font=font, color=txt_color)
File "C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\moviepy\video\VideoClip.py", line 1146, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
magick.exe: no images for write '-write' 'PNG32:C:\Users\USER\AppData\Local\Temp\tmpmnf0fkb5.png' at CLI arg 14 # error/operation.c/CLINoImageOperator/4893.
.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
I have tried to solve the problems multiple ways, like checking the config-default.py file in moviepy installation directory, and the path for ImageMagick it's pointing to is not wrong. I tried to reinstall ImageMagick, it is also of no use. And I tried to edit the policy.xml file in ImageMagick directory from none to read|write, but it also doesn't work. Can anyone suggest other possible solutions?
In /etc/ImageMagick-6/policy.xml try to comment out the following line altogether:
<policy domain="path" rights="none" pattern="#*" />
Like so:
<!-- <policy domain="path" rights="none" pattern="#*" /> -->
Related
I'm using MoviePy which requires ImageMagick, but when I run my code I receive the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 1262, in __init__
subprocess_call(cmd, logger=None)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/tools.py", line 43, in subprocess_call
raise IOError(err.decode("utf8"))
OSError: convert: label expected `#/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmpejmzojaq.txt' # error/annotate.c/GetMultilineTypeMetrics/797.
convert: no images defined `PNG32:/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmp9y2p9b0s.png' # error/convert.c/ConvertImageCommand/3342.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hypnoticocelot/Downloads/python/tikgenrewrite/tikgen.py", line 366, in <module>
tikgen()
File "/Users/hypnoticocelot/Downloads/python/tikgenrewrite/tikgen.py", line 360, in tikgen
subText = TextClip(subText, font=fontFile, fontsize=75, color=fontColor, stroke_color=strokeColor, stroke_width=3).set_position(("center", 650)).set_duration(mainVideo.duration)
File "<decorator-gen-84>", line 2, in __init__
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 1272, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
convert: label expected `#/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmpejmzojaq.txt' # error/annotate.c/GetMultilineTypeMetrics/797.
convert: no images defined `PNG32:/var/folders/tw/25c_f4h57bs5hslr5vm1fns80000gq/T/tmp9y2p9b0s.png' # error/convert.c/ConvertImageCommand/3342.
.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary. Check the documentation.
I thought ImageMagick might not have been installed, but running brew install ImageMagick, I'm already on the latest version and fully updated. I'm using a Mac, so I'm not sure if for some reason the path to the ImageMagick binary is somehow incorrect? But I don't see any way to fix this.
The solution I found was that my TextClip element wasn’t playing nice when the text in the clip was set to "". An if statement checking if it was empty or not fixed it easily.
I need to extract a single file (~10kB) from many very large RAR files (>1Gb). The code below shows a basic implementation of how I'm doing this.
from rarfile import RarFile
rar_file='D:\\File.rar'
file_of_interest='Folder 1/Subfolder 2/File.dat'
output_folder='D:/Output'
rardata = RarFile(rar_file)
rardata.extract(file_of_interest, output_folder)
rardata.close()
However, the extract instruction is returning the following error: rarfile.BadRarFile: Failed the read enough data: req=16384 got=52
When I open the file using WinRAR, I can extract the file successfully, so I'm sure the file isn't corrupted.
I've found some similar questions, but not a definite answer that worked for me.
Can someone help me to solve this error?
Additional info:
Windows 10 build 1909
Spyder 5.0.0
Python 3.8.1
Complete traceback of the error:
Traceback (most recent call last):
File "D:\Test\teste_rar_2.py", line 27, in <module>
rardata.extract(file_of_interest, output_folder)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 826, in extract
return self._extract_one(inf, path, pwd, True)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 912, in _extract_one
return self._make_file(info, dstfn, pwd, set_attrs)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 927, in _make_file
shutil.copyfileobj(src, dst)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\shutil.py", line 79, in copyfileobj
buf = fsrc.read(length)
File "C:\Users\bernard.kusel\AppData\Local\Continuum\anaconda3\lib\site-packages\rarfile.py", line 2197, in read
raise BadRarFile("Failed the read enough data: req=%d got=%d" % (orig, len(data)))
BadRarFile: Failed the read enough data: req=16384 got=52
I've got some data I need to load using ytree which can be done via:
import ytree
a = ytree.load('ctrees.h5')
However, doing this gives the following error:
OSError: file does not exist: ctrees.h5.
With traceback:
Traceback (most recent call last):
File "C:\Users\Documents\untitled1.py", line 3, in <module>
a = ytree.load('ctrees.h5')
File "C:\Users\anaconda3\lib\site-packages\ytree\data_structures\arbor.py", line 1089, in load
raise IOError("file does not exist: %s." % filename)
OSError: file does not exist: ctrees.h5.
The same happens if I try a = ytree.load("ctrees.h5"). I can see that the file exists, I have changed the working directory to the correct one and my script is saved in the same directory. I also tried specifying the full path to the file with no joy.
I'm using Python 3.7 and ytree 2.3 on Windows 10
Any help appreciated.
EDIT (RESOLVED):
Fixed the issue by specifying path at top of script and reading file as:
PATH='C:\\path\\to\\file\\directory\\'
a = ytree.load(PATH + "ctrees.h5")
I am using the moviepy module for python from here https://github.com/Zulko/moviepy
I had successfully installed moviepy and necessary modules with it. But when I am trying to run the first example of adding Text clip in the video, I am getting error.
Here is my code and my output.
Code:
from moviepy.editor import *
clip = VideoFileClip("video1.mp4").subclip(50, 60)
txt_clip = TextClip("My Holidays 2013", fontsize=70, color='white')
txt_clip = txt_clip.set_pos('center').set_duration(10)
video = CompositeVideoClip([clip, txt_clip])
video.write_videofile("output.mp4")
**NOTE:
Imagemagic is installed correctly as when i type convert in the
terminal i get the version name. Also i can perfectly run the other
examples were there isn't a use of TextClip
I am using ubuntu 16.04 with python3
.**
Output:
[MoviePy] This command returned an error !Traceback (most recent call last):
File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/video/VideoClip.py", line 1220, in __init__
subprocess_call(cmd, verbose=False )
File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/tools.py", line 49, in subprocess_call
raise IOError(err.decode('utf8'))
OSError: convert: not authorized `#/tmp/tmpfa42vkjy.txt' # error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmpevkkuuf5.png' # error/convert.c/ConvertImageCommand/3210.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vega6-x3/python/hello.py", line 10, in <module>
txt_clip = TextClip("My Holidays 2013", fontsize=70, color='white')
File "/home/vega6-x3/.local/lib/python3.5/site-packages/moviepy/video/VideoClip.py", line 1229, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
convert: not authorized `#/tmp/tmpfa42vkjy.txt' # error/property.c/InterpretImageProperties/3405.
convert: no images defined `PNG32:/tmp/tmpevkkuuf5.png' # error/convert.c/ConvertImageCommand/3210.
.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or.that the path you specified is incorrect
Please let me know what wrong i am doing. I am pretty new to python, so not sure what i had done wrong. From what little i can get, it seems to me as a permission issue but exactly sure about this.
Thanks
Adi
Looks like the txt format is disabled on the system (due to security issues).
You can re-enable it by commenting out the line below in policy.xml
<policy domain="coder" rights="none" pattern="TEXT" />
But I wouldn't recommend this on a system the accepts files from the public!
I am starting with Microsoft Azure SDK for Python (https://github.com/Azure/azure-sdk-for-python), but I have problems.
I am using Scientific Linux and I have installed the SDK for Python 3.4 following the next steps:
(instead of the SDK directory)
python setup.py install
after that I created a simple script just to test the connection:
from azure.storage import BlobService
blob_service = BlobService(account_name='thename', account_key='Mxxxxxxx3w==' )
blob_service.create_container('testcontainer')
for i in blob_service.list_containers():
print(i.name)
following this documentation:
http://blogs.msdn.com/b/tconte/archive/2013/04/17/how-to-interact-with-windows-azure-blob-storage-from-linux-using-python.aspx
http://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#large-blobs
but is not working, I always receive the same error:
python3 test.py
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 143, in _perform_request
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 132, in _perform_request_worker
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/http/httpclient.py", line 247, in perform_request
azure.http.HTTPError: The value for one of the HTTP headers is not in the correct format.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 21, in <module>
blob_service.create_container('testcontainer')
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 192, in create_container
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 905, in _dont_fail_on_exist
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 189, in create_container
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 150, in _perform_request
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/__init__.py", line 889, in _storage_error_handler
File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 929, in _general_error_handler
azure.WindowsAzureError: Unknown error (The value for one of the HTTP headers is not in the correct format.)
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
RequestId:b37c5584-0001-002b-24b8-c2c245000000
Time:2014-11-19T14:54:38.9378626Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>2012-02-12</HeaderValue></Error>
Thanks in advance and best regards.
I have this exact same issue. I believe it's a library bug, but the author/s haven't had their say yet.
It looks like the response states the version, but it's actually giving you the header that's wrong. Its value should be "2014-02-14", you can do the fix shown in https://github.com/Azure/azure-sdk-for-python/pull/289 .
Hopefully this will be fixed and nobody will ever read this answer. Cheers!