Browse Source

FT810 video conversion script

James Bowman 2 years ago
parent
commit
312860beb5
2 changed files with 47 additions and 0 deletions
  1. 1 0
      squeeze
  2. 46 0
      video-convert

+ 1 - 0
squeeze

@@ -0,0 +1 @@
+jpegtran -optimize -copy none -perfect "$1" > "${1%.jpg}o.jpg"

+ 46 - 0
video-convert

@@ -0,0 +1,46 @@
+set -e
+
+TMP=tmp
+
+tput clear
+
+FPS=`ffprobe "$1" 2>&1 | sed -n 's/.* \([0-9.]*\) fps.*/\1/p'`
+
+SIZE="w=240:h=136"
+SIZE="w=336:h=192"
+SIZE="w=480:h=272"
+
+if true
+then
+  mkdir -p $TMP
+  rm -rf $TMP/*
+  ffmpeg -y -i "$1" -q 1 \
+    -vf scale=${SIZE}:force_original_aspect_ratio=decrease \
+    $TMP/master.mkv
+fi
+
+# 1800 - Arduino starves
+# 
+
+for SP in 1500
+do
+  if false
+  then
+    ffmpeg -y -i $TMP/master.mkv -b:v 600k -bufsize 64k -maxrate 600k -c:v mjpeg out.avi
+  else
+    ffmpeg -y -r 30 -i $TMP/master.mkv \
+    -c:v mjpeg \
+    -b:v ${SP}k -bufsize 1024k -maxrate 1800k \
+    $TMP/%05d.jpg
+
+    ls $TMP/?????.jpg  | xargs -P 8 -n 1 ./squeeze
+
+    ffmpeg -y -i $TMP/%05do.jpg -c:v copy out.avi
+  fi
+
+  python avirate.py $FPS out.avi
+  cp out.avi out-$SP.avi
+done
+
+# ls -lh out.avi
+mplayer out.avi