mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
strip and remux uploaded videos, fixes philomena-dev/philomena#104
This commit is contained in:
parent
efa1e6172a
commit
26c1297c16
1 changed files with 28 additions and 4 deletions
|
@ -5,16 +5,18 @@ defmodule Philomena.Processors.Webm do
|
|||
def process(analysis, file, versions) do
|
||||
dimensions = analysis.dimensions
|
||||
duration = analysis.duration
|
||||
preview = preview(duration, file)
|
||||
palette = gif_palette(file, duration)
|
||||
mp4 = scale_mp4_only(file, dimensions, dimensions)
|
||||
stripped = strip(file)
|
||||
preview = preview(duration, stripped)
|
||||
palette = gif_palette(stripped, duration)
|
||||
mp4 = scale_mp4_only(stripped, dimensions, dimensions)
|
||||
|
||||
{:ok, intensities} = Intensities.file(preview)
|
||||
|
||||
scaled =
|
||||
Enum.flat_map(versions, &scale_if_smaller(file, mp4, palette, duration, dimensions, &1))
|
||||
Enum.flat_map(versions, &scale_if_smaller(stripped, mp4, palette, duration, dimensions, &1))
|
||||
|
||||
%{
|
||||
replace_original: stripped,
|
||||
intensities: intensities,
|
||||
thumbnails: scaled ++ [{:copy, preview, "rendered.png"}]
|
||||
}
|
||||
|
@ -35,6 +37,28 @@ defmodule Philomena.Processors.Webm do
|
|||
preview
|
||||
end
|
||||
|
||||
defp strip(file) do
|
||||
stripped = Briefly.create!(extname: ".webm")
|
||||
|
||||
{_output, 0} =
|
||||
System.cmd("ffmpeg", [
|
||||
"-loglevel",
|
||||
"0",
|
||||
"-y",
|
||||
"-i",
|
||||
file,
|
||||
"-map_metadata",
|
||||
"-1",
|
||||
"-c",
|
||||
"copy",
|
||||
"-map",
|
||||
"0",
|
||||
stripped
|
||||
])
|
||||
|
||||
stripped
|
||||
end
|
||||
|
||||
defp scale_if_smaller(_file, mp4, _palette, _duration, _dimensions, {:full, _target_dim}) do
|
||||
[
|
||||
{:symlink_original, "full.webm"},
|
||||
|
|
Loading…
Reference in a new issue