Created
February 23, 2019 13:53
-
-
Save ei-grad/1880e316159019af826b9036cff26a72 to your computer and use it in GitHub Desktop.
Generate index.html to watch video files from current directory in browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in *; do | |
echo "Converting $i..." | |
ffmpeg -nostdin -i $i -c:v h264_nvenc -preset slow -cq 10 -bf 2 -g 150 ${i%.*}.mp4.tmp && \ | |
rm $i && \ | |
mv ${i%.*}.mp4.tmp ${i%.*}.mp4 | |
echo | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from pathlib import Path | |
from urllib.parse import quote | |
index = [] | |
for i in sorted(Path('.').iterdir()): | |
index.append(i) | |
with (i.parent / (i.stem + '.html')).open('w') as f: | |
f.write('<html><body><h1>%s</h1><video width="720" height="400" autoplay controls><source src="%s">' % ( | |
i.stem, quote(i.name) | |
)) | |
with open('index.html', 'w') as f: | |
f.write('<html><body>') | |
for i in index: | |
f.write('<h3><a href="%s">%s</a></h3>' % ( | |
quote(i.name), i.stem)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment