视频文件上传使用moviepy给错误[错误13]许可被拒绝
def upload_video(video):
video_name = "%d&&%s%s" % (int(round(time.time() * 1000)), "uservideo", os.path.splitext(video.name)[1])
image_path = '%s/%s' % (DATA_ROOT, video_name)
full_path = '%s%s' % (BASE_DIR, image_path)
try:
with open(full_path,'wb') as fp:
for chunk in video.chunks():
fp.write(chunk)
os.chmod(full_path, 0666)
except Exception as err:
return image_path
我需要的视频文件
def ajax_videoUpload(request):
video = request.FILES[request.FILES.keys()[0]]
videoPath = upload_video(video)
fullPath = "%s%s" % (BASE_DIR, videoPath)
fileExt = os.path.splitext(videoPath)[1] # file extension
clip = VideoFileClip(fullPath)
fullPath = string.replace(fullPath, fileExt, ".png")
clip.save_frame(fullPath, t = 10.00)
thumbnailPath = string.replace(videoPath, fileExt, ".png")
return HttpResponse(thumbnailPath)
videoFileClip(FULLPATH)<缩略图 - 定错误
Traceback (most recent call last):
File "/opt/djangostack-1.8.3-0/apps/django/lib/python2.7/site-packages/Django-1.8.3-py2.7.egg/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/djangostack-1.8.3-0/apps/django/lib/python2.7/site-packages/Django-1.8.3-py2.7.egg/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/opt/djangostack-1.8.3-0/apps/django/django_projects/tellpin/writingform/views.py", line 392, in ajax_videoUpload
clip = VideoFileClip(fullPath)
File "/opt/djangostack-1.8.3-0/python/lib/python2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 55, in __init__
reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
File "/opt/djangostack-1.8.3-0/python/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
File "/opt/djangostack-1.8.3-0/python/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 237, in ffmpeg_parse_infos
proc = sp.Popen(cmd, **popen_params)
File "/opt/djangostack-1.8.3-0/python/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/opt/djangostack-1.8.3-0/python/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
这段代码很好用,在我本地的 我的本地操作系统win7,python 2.7 但不是在服务器
工作我试图文件权限和目录权限
对不起,我是韩国人,所以我没有良好的英语.....
服务器操作系统的CentOS 6 ,python 2.7.9,django 1.7
您的查看功能有缺陷 –
问题是什么?你到底做了什么来解决这个问题?告诉我们 [你试过的东西](http://whathaveyoutried.com),以及你卡在哪里。 这将帮助我们更好地回答你的问题。 –
我想你的网络服务器没有足够的权限。检出Web服务器的'uid/gid',然后执行'ls -l'来检查您尝试处理的目录的权限。使用'chown'和'chmod'修复... – Aftnix