from subprocess import Popen, PIPE
import re
def getvideodetails(filepath):
cmd = 'ffmpeg -i %s" % filepath'
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
di = p.communicate()
for line in di:
if line.rfind("Video") > 0:
resolution = re.findall("(\d+x\d+)", line)[0]
return resolution
getvideodetails("путь к видео")
jQuery.ajax({
type: 'POST',
url: 'add_new_rec/'+prot_id+'/'+id_q+'/',
async: true,
cache: false,
processData: false,
contentType: false,
enctype: 'multipart/form-data',
data: {csrfmiddlewaretoken: getCookie('csrftoken'), 'r_text':text, 'file':my_file},
success: function (data) {
}
});
model.field = request.FILES['my_file']
model.save()