forked from 0x2620/pandora
use ffmpeg to merge mp4 files, support clip extraction from multiple parts
This commit is contained in:
parent
3204bc68f6
commit
959ffaba25
2 changed files with 27 additions and 10 deletions
|
|
@ -1022,7 +1022,6 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
path = stream.media.path
|
||||
|
||||
# server side cutting
|
||||
# FIXME: this needs to join segments if needed
|
||||
t = request.GET.get('t')
|
||||
if t:
|
||||
def parse_timestamp(s):
|
||||
|
|
@ -1031,8 +1030,19 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
return float(s)
|
||||
t = list(map(parse_timestamp, t.split(',')))
|
||||
ext = '.%s' % format
|
||||
duration = stream.info['duration']
|
||||
|
||||
# multipart request beyond first part, merge parts and chop that
|
||||
if not index and streams.count() > 1 and stream.info['duration'] < t[1]:
|
||||
video = NamedTemporaryFile(suffix=ext)
|
||||
r = item.merge_streams(video.name, resolution, format)
|
||||
if not r:
|
||||
return HttpResponseForbidden()
|
||||
path = video.name
|
||||
duration = sum(item.json['durations'])
|
||||
|
||||
content_type = mimetypes.guess_type(path)[0]
|
||||
if len(t) == 2 and t[1] > t[0] and stream.info['duration'] >= t[1]:
|
||||
if len(t) == 2 and t[1] > t[0] and duration >= t[1]:
|
||||
response = HttpResponse(extract.chop(path, t[0], t[1]), content_type=content_type)
|
||||
filename = u"Clip of %s - %s-%s - %s %s%s" % (
|
||||
item.get('title'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue