mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
require mediastat for video processing, increase muxq
This commit is contained in:
parent
7fcc1ec4bf
commit
2683dddb4c
3 changed files with 20 additions and 43 deletions
|
@ -7,11 +7,12 @@ RUN apt-get update; \
|
|||
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \
|
||||
wget -qO - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \
|
||||
apt-get update; \
|
||||
apt-get -qq -y install inotify-tools postgresql-client build-essential git ffmpeg nodejs libmagic-dev libpng-dev gifsicle optipng libjpeg-progs librsvg2-bin; \
|
||||
apt-get -qq -y install inotify-tools postgresql-client build-essential git ffmpeg libavformat-dev libavcodec-dev nodejs libmagic-dev libpng-dev gifsicle optipng libjpeg-progs librsvg2-bin; \
|
||||
cd /tmp; \
|
||||
git clone https://github.com/derpibooru/cli_intensities; \
|
||||
cd cli_intensities; \
|
||||
make install; \
|
||||
git clone https://github.com/derpibooru/mediatools; \
|
||||
(cd cli_intensities && make install); \
|
||||
(cd mediatools && make install); \
|
||||
mix local.hex --force; \
|
||||
mix local.rebar --force
|
||||
|
||||
|
|
|
@ -1,57 +1,29 @@
|
|||
defmodule Philomena.Analyzers.Webm do
|
||||
def analyze(file) do
|
||||
stats = stats(file)
|
||||
|
||||
%{
|
||||
extension: "webm",
|
||||
mime_type: "video/webm",
|
||||
animated?: true,
|
||||
duration: duration(file),
|
||||
dimensions: dimensions(file)
|
||||
duration: stats.duration,
|
||||
dimensions: stats.dimensions
|
||||
}
|
||||
end
|
||||
|
||||
defp duration(file) do
|
||||
with {output, 0} <-
|
||||
System.cmd("ffprobe", [
|
||||
"-i",
|
||||
file,
|
||||
"-show_entries",
|
||||
"format=duration",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-of",
|
||||
"csv=p=0"
|
||||
]),
|
||||
{duration, _} <- Float.parse(output) do
|
||||
duration
|
||||
else
|
||||
_ ->
|
||||
0.0
|
||||
end
|
||||
end
|
||||
|
||||
defp dimensions(file) do
|
||||
System.cmd("ffprobe", [
|
||||
"-i",
|
||||
file,
|
||||
"-show_entries",
|
||||
"stream=width,height",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-of",
|
||||
"csv=p=0"
|
||||
])
|
||||
|> case do
|
||||
defp stats(file) do
|
||||
case System.cmd("mediastat", [file]) do
|
||||
{output, 0} ->
|
||||
[width, height] =
|
||||
[_size, _frames, width, height, num, den] =
|
||||
output
|
||||
|> String.trim()
|
||||
|> String.split(",")
|
||||
|> String.split(" ")
|
||||
|> Enum.map(&String.to_integer/1)
|
||||
|
||||
{width, height}
|
||||
%{dimensions: {width, height}, duration: num / den}
|
||||
|
||||
_error ->
|
||||
{0, 0}
|
||||
_ ->
|
||||
%{dimensions: {0, 0}, duration: 0.0}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,6 +112,8 @@ defmodule Philomena.Processors.Webm do
|
|||
scale_filter,
|
||||
"-threads",
|
||||
"1",
|
||||
"-max_muxing_queue_size",
|
||||
"512",
|
||||
webm
|
||||
])
|
||||
|
||||
|
@ -138,6 +140,8 @@ defmodule Philomena.Processors.Webm do
|
|||
scale_filter,
|
||||
"-threads",
|
||||
"1",
|
||||
"-max_muxing_queue_size",
|
||||
"512",
|
||||
mp4
|
||||
])
|
||||
|
||||
|
@ -148,7 +152,7 @@ defmodule Philomena.Processors.Webm do
|
|||
gif = Briefly.create!(extname: ".gif")
|
||||
scale_filter = "scale=w=#{width}:h=#{height}:force_original_aspect_ratio=decrease"
|
||||
palette_filter = "paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle"
|
||||
rate_filter = "fps=1/#{duration / 10},settb=1/2,setpts=N"
|
||||
rate_filter = "setpts=N/TB/2"
|
||||
filter_graph = "[0:v] #{scale_filter},#{rate_filter} [x]; [x][1:v] #{palette_filter}"
|
||||
|
||||
{_output, 0} =
|
||||
|
|
Loading…
Reference in a new issue