falkon.sgorava.xyz/layouts/shortcodes/video.html
Juraj Oravec caffb5abb3
Add basic hugo site
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2022-04-28 09:04:21 +02:00

42 lines
1.1 KiB
HTML

{{ $extensions := .Get "extensions" }}
{{ $src := .Get "src" }}
<video width="480" height="320" controls>
{{ range split $extensions "," }}
<source src="{{ $src }}.{{ . }}">
{{ end }}
<div class="video">
Your browser does not support HTML5 video.
<ul>
{{ range split $extensions "," }}
<li>
<a href="{{ $src }}.{{ . }}">{{ $src }}.{{ . }}</a>
{{ $filename := . | printf "/static%s.%s" $src }}
{{ $stat := os.Stat $filename }}
({{ div $stat.Size 1024 }} kiB)
</li>
{{ end }}
</ul>
</div>
</video>
{{/*
MP4 and Webm formats are preferred.
Convert to MP4:
ffmpeg -i input.mkv -f mp4 -vcodec libx264 -preset fast -profile:v main -acodec aac output.mp4 -hide_banner
Convert to Webm:
ffmpeg -i input.mkv -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
## Usage:
Put the video files into `/static/videos` folder.
Than include this file with its name and available extensions.
{{< video src="/videos/<video-file-name-without-extension>" extensions="<comma_separated_list_of_extensions>" >}}
## Example:
{{< video src="/videos/example" extensions="mp4,webm" >}}
*/}}