summary refs log tree commit diff
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2022-08-26 01:54:48 +0200
committerpdp8 <pdp8@pdp8.info>2022-08-26 01:54:48 +0200
commitd684a873fce8ed3e19d514839afbf831162c2ed8 (patch)
treeb2a01d612ddf4dcc62d7b37552ec2302ad3cdd88
parentf7e3fbebc0b481ce0ac76506b8a017a9a63bec11 (diff)
webm videos reactivated
-rwxr-xr-xhtml.rb4
-rwxr-xr-xpictures.py5
-rwxr-xr-xvideo-metadata.rb26
3 files changed, 23 insertions, 12 deletions
diff --git a/html.rb b/html.rb
index f543a2b..c4a7a5d 100755
--- a/html.rb
+++ b/html.rb
@@ -88,8 +88,8 @@ def video_html
     poster = File.join("/videos", File.basename(dir), "poster.png")
 
     html += "<video controls poster='#{poster}'>
-        <source src='#{mp4}' type='video/mpeg'>
-        <a href='#{mp4}'>#{mp4}</a>
+        <source src='#{webm}' type='video/webm'>
+        <source src='#{mp4}' type='video/mp4'>
         </video><p>
         "
     html += lines.join("<br>")
diff --git a/pictures.py b/pictures.py
index b9f3095..dc93119 100755
--- a/pictures.py
+++ b/pictures.py
@@ -22,8 +22,8 @@ favs = subprocess.check_output(cmd, shell=True, text=True).splitlines()
 distances = {}
 for fav in favs:
     basename = os.path.basename(fav)
-    """
-    out = os.path.join("/home/ch/pub/pictures/", basename)
+    # out = os.path.join("/home/ch/pub/pictures/", basename)
+    out = os.path.join("/srv/www/pdp8-test/pictures/", basename)
     cmd = "convert '" + fav + "' -strip -resize 1024x '" + out + "'"
     os.system(cmd)
     cmd = (
@@ -49,3 +49,4 @@ for fav in favs:
 with open("/home/ch/pub/distances.js", "w") as f:
     s = "distances = " + json.dumps(distances)
     print(s, file=f)
+    """
diff --git a/video-metadata.rb b/video-metadata.rb
index 654ce0c..be9e079 100755
--- a/video-metadata.rb
+++ b/video-metadata.rb
@@ -1,21 +1,31 @@
 #!/usr/bin/env ruby
 require 'json'
 
-Dir[File.join(ARGV[0], "videos", "*", "*.mp4")].each do |video|
-  # tmp = File.join("/tmp", File.basename(video))
-  tmp = video + "~"
-  print `cp #{video} #{tmp}`
+Dir[File.join(ARGV[0], "videos", "*", "*.mp4")].each do |mp4|
+  # tmp = File.join("/tmp", File.basename(mp4))
+  tmp = mp4 + "~"
+  print `cp #{mp4} #{tmp}`
   meta = {
-    "title" => File.basename(video, ".mp4").gsub("_", " "),
-    "date" => video.split("/")[-2].split("_")[0],
+    "title" => File.basename(mp4, ".mp4").gsub("_", " "),
+    "date" => mp4.split("/")[-2].split("_")[0],
     "artist" => "pdp8@pdp8.info",
     "copyright" => "© pdp8@pdp8.info Creative Commons Attribution-ShareAlike 4.0 International License",
   }
+  tmp = mp4 + "~"
+  print `cp #{mp4} #{tmp}`
   cmd = "ffmpeg -i #{tmp} -c copy "
   meta.each do |k, v|
     cmd += "-metadata #{k}=\"#{v}\" "
   end
-  cmd += " #{video}"
-  puts cmd
+  cmd += " #{mp4}"
+  print `#{cmd}`
+  webm = mp4.sub(".mp4", ".webm")
+  tmp = webm + "~"
+  print `cp #{webm} #{tmp}`
+  cmd = "ffmpeg -i #{tmp} -c copy "
+  meta.each do |k, v|
+    cmd += "-metadata #{k}=\"#{v}\" "
+  end
+  cmd += " #{webm}"
   print `#{cmd}`
 end