diff options
author | User Jack <jack@garcon.2.localnet.cc> | 2016-01-02 11:49:34 +0000 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2016-01-08 20:38:18 +0100 |
commit | a11dcb6ae177dfce7725d43a37648770d7340062 (patch) | |
tree | d8ac5eedc883427cd5ebf98959b091de01c7657f | |
parent | 7c6120bae3ed4e7cdd015b536a53bb2724967013 (diff) | |
download | flask-mediabrowser-a11dcb6ae177dfce7725d43a37648770d7340062.tar.gz flask-mediabrowser-a11dcb6ae177dfce7725d43a37648770d7340062.zip |
pick video stream not just stream number 0
-rw-r--r-- | mediabrowser/__init__.py | 4 | ||||
-rw-r--r-- | mediabrowser/ffmpeg.py | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/mediabrowser/__init__.py b/mediabrowser/__init__.py index 8766ac2..62aeb48 100644 --- a/mediabrowser/__init__.py +++ b/mediabrowser/__init__.py @@ -154,8 +154,8 @@ def build(root_directory, cache): if client_mtime is not None and mtime <= client_mtime: return Response(status=304) else: - thumbnail_stream = ffmpeg.thumbnail_video(ospath, 90, 50) - r = Response(thumbnail_stream, mimetype="video/webm") + process = ffmpeg.thumbnail_video(ospath, 90, 50) + r = Response(process.stdout, mimetype="video/webm") r.last_modified = mtime return r diff --git a/mediabrowser/ffmpeg.py b/mediabrowser/ffmpeg.py index d8d40f5..fd1782c 100644 --- a/mediabrowser/ffmpeg.py +++ b/mediabrowser/ffmpeg.py @@ -115,8 +115,8 @@ def calculate_splittimes(ospath, chunk_duration): def thumbnail(ospath, width, height): - process = LoggedPopen(shlex.split("ffmpeg -noaccurate_seek -ss 25.0 -i") + [ospath] + - shlex.split("-frames:v 10 -map 0:0" + process = LoggedPopen(shlex.split("ffmpeg -v fatal -noaccurate_seek -ss 25.0 -i") + [ospath] + + shlex.split("-frames:v 10 -map 0:v" " -filter:v 'scale=w=oh*a:h={}, crop=(min(iw\,{})):(min(ih\,{}))'" " -f singlejpeg pipe:".format(height+(height/10), width, height)), stdout=PIPE) @@ -131,7 +131,7 @@ def thumbnail_video(ospath, width, height): for pos in chunk_startpos: command += ["-ss", "{:.6f}".format(pos), "-t", "2", "-i", ospath] - filter = " ".join(map(lambda i: "[{}:0]".format(i), range(len(chunk_startpos)))) + filter = " ".join(map(lambda i: "[{}:v]".format(i), range(len(chunk_startpos)))) filter += " concat=n={}:v=1:a=0 [v1]".format(len(chunk_startpos)) filter += "; [v1] fps=14 [v2]" filter += "; [v2] scale='w=trunc(oh*a/2)*2:h={}' [v3]".format(height + 6) @@ -140,4 +140,4 @@ def thumbnail_video(ospath, width, height): command += shlex.split("-c:v libvpx -deadline realtime -f webm pipe:") encoder = LoggedPopen(command, stdout=PIPE) - return encoder.stdout + return encoder |