From d684a873fce8ed3e19d514839afbf831162c2ed8 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Fri, 26 Aug 2022 01:54:48 +0200 Subject: webm videos reactivated --- html.rb | 4 ++-- pictures.py | 5 +++-- video-metadata.rb | 26 ++++++++++++++++++-------- 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 += "

" html += lines.join("
") 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 -- cgit v1.2.3