diff --git a/changelog.d/qtfaststart.fix b/changelog.d/qtfaststart.fix new file mode 100644 index 000000000..66d2569f2 --- /dev/null +++ b/changelog.d/qtfaststart.fix @@ -0,0 +1 @@ +MediaProxy Preview failures prevented when encountering certain video files diff --git a/lib/pleroma/helpers/qt_fast_start.ex b/lib/pleroma/helpers/qt_fast_start.ex index 5711c7162..919fec84a 100644 --- a/lib/pleroma/helpers/qt_fast_start.ex +++ b/lib/pleroma/helpers/qt_fast_start.ex @@ -40,16 +40,21 @@ defmodule Pleroma.Helpers.QtFastStart do got_mdat, acc ) do - full_size = (size - 8) * 8 - <> = rest + try do + full_size = (size - 8) * 8 + <> = rest - acc = [ - {fourcc, pos, pos + size, size, - <>} - | acc - ] + acc = [ + {fourcc, pos, pos + size, size, + <>} + | acc + ] - fix(rest, pos + size, got_moov || fourcc == "moov", got_mdat || fourcc == "mdat", acc) + fix(rest, pos + size, got_moov || fourcc == "moov", got_mdat || fourcc == "mdat", acc) + rescue + _ -> + :abort + end end defp fix(<<>>, _pos, _, _, acc) do