diff --git a/pom.xml b/pom.xml
index e94fa1a..6edc349 100644
--- a/pom.xml
+++ b/pom.xml
@@ -192,6 +192,13 @@
jcl-over-slf4j
1.5.10
+
+ commons-io
+ commons-io
+ 1.4
+ jar
+ compile
+
diff --git a/src/main/java/org/forkalsrud/album/exif/Dimension.java b/src/main/java/org/forkalsrud/album/exif/Dimension.java
index 2b9e83e..511da78 100644
--- a/src/main/java/org/forkalsrud/album/exif/Dimension.java
+++ b/src/main/java/org/forkalsrud/album/exif/Dimension.java
@@ -32,6 +32,10 @@ public class Dimension {
}
+ public Dimension(String width, String height) {
+ this(Integer.parseInt(width), Integer.parseInt(height));
+ }
+
public Dimension doubled() {
return new Dimension(w * 2, h * 2);
diff --git a/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java b/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java
index fa77b8d..5173e5c 100644
--- a/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java
+++ b/src/main/java/org/forkalsrud/album/exif/DirectoryMetadataGenerator.java
@@ -9,6 +9,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -17,6 +18,7 @@ import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
+import org.apache.commons.io.IOUtils;
import org.forkalsrud.album.db.DirectoryProps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -94,6 +96,12 @@ public class DirectoryMetadataGenerator {
props.setProperty("dir." + name, "present");
}
+ /**
+ *
+ * @param f the jpeg file
+ * @return a map with the following keys: orientation dimensions captureDate comment etag
+ * @throws IOException
+ */
private Map generateThumbnailProperties(File f) throws IOException {
HashMap props = new HashMap();
@@ -159,6 +167,38 @@ public class DirectoryMetadataGenerator {
return props;
}
+ /**
+ *
+ * @param f the jpeg file
+ * @return a map with the following keys: orientation dimensions captureDate comment etag
+ * @throws IOException
+ */
+ private Map generateVideoProperties(File f) throws IOException {
+ Map props = new HashMap();
+ ProcessBuilder pb = new ProcessBuilder().command(
+ "mplayer", "-vo", "null", "-ao", "null", "-frames", "0", "-identify", f.getAbsolutePath());
+ pb.redirectErrorStream(false);
+ Process p = pb.start();
+ p.getOutputStream().close();
+ List lines = IOUtils.readLines(p.getInputStream());
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
+ String width = "", height = "";
+ for (String line : lines) {
+ int pos = line.indexOf('=');
+ if (pos >= 0) {
+ String name = line.substring(0, pos);
+ String value = line.substring(pos + 1);
+ if (name.equals("ID_VIDEO_WIDTH")) width = value;
+ if (name.equals("ID_VIDEO_HEIGHT")) height = value;
+ }
+ }
+ props.put("orientation", "1");
+ props.put("dimensions", new Dimension(width, height).toString());
+ props.put("captureDate", sdf.format(new Date(f.lastModified())));
+ props.put("etag", Integer.toHexString(f.getName().hashCode() + Long.valueOf(f.lastModified()).hashCode()));
+ return props;
+ }
+
private Date getExifDate(Directory exifDirectory, int tagName) throws MetadataException {
String dateStr = (String)exifDirectory.getObject(tagName);