Skip to content

Commit 720fadb

Browse files
author
Rajendran
committed
Modularized The project. Separate code base into Punahele-Core, Punahele-Adapters, Punahele-Batch; Added separate folders for Kafka, ElasticSearch, Redis configuration files
1 parent c7b97d6 commit 720fadb

30 files changed

+409
-7
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5">
15+
<attributes>
16+
<attribute name="owner.project.facets" value="jst.web"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
20+
<attributes>
21+
<attribute name="maven.pomderived" value="true"/>
22+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="output" path="target/classes"/>
26+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build/
2+
/target/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Punahele - Batch Video Converter</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.validation.validationbuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.m2e.core.maven2Builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
31+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
32+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
33+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
34+
<nature>org.eclipse.jdt.core.javanature</nature>
35+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
36+
</natures>
37+
</projectDescription>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="Punahele-Batch-Video-Converter-0.0.1-SNAPSHOT">
3+
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
4+
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
5+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
6+
<property name="java-output-path" value="/Punahele - Batch Video Converter/build/classes"/>
7+
<property name="context-root" value="Punahele-Batch-Video-Converter"/>
8+
</wb-module>
9+
</project-modules>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<runtime name="Apache Tomcat v8.5"/>
4+
<fixed facet="wst.jsdt.web"/>
5+
<fixed facet="jst.web"/>
6+
<fixed facet="java"/>
7+
<installed facet="java" version="1.8"/>
8+
<installed facet="jst.web" version="3.1"/>
9+
<installed facet="wst.jsdt.web" version="1.0"/>
10+
</faceted-project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
disabled=06target
2+
eclipse.preferences.version=1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.punahele.batch</groupId>
4+
<artifactId>Punahele-Batch-Video-Converter</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
<packaging>war</packaging>
7+
<name>Punahele - Batch Video Converter</name>
8+
<description>Batch Video Converter for punahele</description>
9+
<build>
10+
<sourceDirectory>src</sourceDirectory>
11+
<plugins>
12+
<plugin>
13+
<artifactId>maven-compiler-plugin</artifactId>
14+
<version>3.7.0</version>
15+
<configuration>
16+
<source>1.8</source>
17+
<target>1.8</target>
18+
</configuration>
19+
</plugin>
20+
<plugin>
21+
<artifactId>maven-war-plugin</artifactId>
22+
<version>3.0.0</version>
23+
<configuration>
24+
<warSourceDirectory>WebContent</warSourceDirectory>
25+
</configuration>
26+
</plugin>
27+
</plugins>
28+
</build>
29+
<dependencies>
30+
<!-- https://mvnrepository.com/artifact/org.jcodec/jcodec -->
31+
<dependency>
32+
<groupId>org.jcodec</groupId>
33+
<artifactId>jcodec</artifactId>
34+
<version>0.2.2</version>
35+
</dependency>
36+
<!-- https://mvnrepository.com/artifact/org.jcodec/jcodec-javase -->
37+
<dependency>
38+
<groupId>org.jcodec</groupId>
39+
<artifactId>jcodec-javase</artifactId>
40+
<version>0.2.2</version>
41+
</dependency>
42+
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
43+
<dependency>
44+
<groupId>com.google.guava</groupId>
45+
<artifactId>guava</artifactId>
46+
<version>15.0-rc1</version>
47+
</dependency>
48+
</dependencies>
49+
</project>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package com.punahele.utilities.video;
2+
3+
import java.awt.image.BufferedImage;
4+
import java.io.BufferedWriter;
5+
import java.io.File;
6+
import java.io.FileWriter;
7+
import java.io.IOException;
8+
import java.io.RandomAccessFile;
9+
import java.nio.channels.FileChannel;
10+
import java.nio.channels.WritableByteChannel;
11+
import java.util.Arrays;
12+
import java.util.Collections;
13+
import java.util.Comparator;
14+
import java.util.List;
15+
import java.util.function.Consumer;
16+
17+
import javax.imageio.ImageIO;
18+
19+
import org.jcodec.api.JCodecException;
20+
import org.jcodec.api.awt.AWTFrameGrab;
21+
import org.jcodec.common.io.FileChannelWrapper;
22+
import org.jcodec.common.io.NIOUtils;
23+
24+
import com.google.common.io.Closer;
25+
26+
public class VideoToFramesConverter {
27+
public void convertVideoToFrame(String fileName) throws IOException, JCodecException {
28+
// Get some logic to convert videos to frames.
29+
// Once that is done, write all the frames to a single file
30+
// Create another file that will contain the frame number and its start position
31+
// Try JCodec to convert videos to frames
32+
FileChannelWrapper in = null;
33+
try {
34+
in = NIOUtils.readableChannel(new File(fileName));
35+
AWTFrameGrab fg = AWTFrameGrab.createAWTFrameGrab(in);
36+
String parts[] = fileName.split("\\.");
37+
new File(parts[0]).mkdir();
38+
for (int i = 0; i < 2000; i++) {
39+
BufferedImage frame = fg.getFrame();
40+
File file = new File(parts[0]+"\\Frame" + i + ".jpeg");
41+
file.createNewFile();
42+
ImageIO.write(frame, "jpeg", file);
43+
}
44+
mergeImagesToFile(parts[0], parts[0]+"\\BigFinal.jpeg");
45+
} finally {
46+
NIOUtils.closeQuietly(in);
47+
}
48+
}
49+
50+
public void mergeImagesToFile(String folderName, String finalFilename) throws IOException {
51+
StringBuilder positions = new StringBuilder();
52+
File videoFolder = new File(folderName);
53+
//File[] frames = videoFolder.listFiles();
54+
55+
List<File> frames = Arrays.asList(videoFolder.listFiles());
56+
Collections.sort(frames, new Comparator<File>() {
57+
@Override
58+
public int compare(File f1, File f2) {
59+
int num1 = Integer.parseInt(f1.getName().substring(5, f1.getName().indexOf(".")));
60+
int num2 = Integer.parseInt(f2.getName().substring(5, f2.getName().indexOf(".")));
61+
return num1 - num2;
62+
}
63+
});
64+
65+
66+
final Closer closer = Closer.create();
67+
68+
//Sort the frames and then merge..VVI
69+
final RandomAccessFile outFile;
70+
final FileChannel outChannel;
71+
72+
try {
73+
outFile = closer.register(new RandomAccessFile(finalFilename, "rw"));
74+
outChannel = closer.register(outFile.getChannel());
75+
long pieceNumber = -1; long frameStartPosition = 0;
76+
for (final File frame: frames) {
77+
doWrite(outChannel, frame);
78+
positions.append(++pieceNumber+"-"+frameStartPosition+","+frame.length()+"\n");
79+
frameStartPosition = frameStartPosition + frame.length();
80+
}
81+
} finally {
82+
BufferedWriter writer = new BufferedWriter(new FileWriter(folderName+"\\Positions.txt"));
83+
writer.write(positions.toString());
84+
writer.close();
85+
closer.close();
86+
}
87+
}
88+
89+
private static void doWrite(final WritableByteChannel channel, final File file)
90+
throws IOException
91+
{
92+
final Closer closer = Closer.create();
93+
94+
final RandomAccessFile inFile;
95+
final FileChannel inChannel;
96+
97+
try {
98+
inFile = closer.register(new RandomAccessFile(file, "r"));
99+
inChannel = closer.register(inFile.getChannel());
100+
inChannel.transferTo(0, inChannel.size(), channel);
101+
} finally {
102+
closer.close();
103+
}
104+
}
105+
106+
public static void main(String[] args) throws IOException, JCodecException {
107+
new VideoToFramesConverter().convertVideoToFrame("C:\\Videos\\OneRepublic - Feel Again.mp4");
108+
//new VideoToFramesConverter().mergeImagesToFile("C:\\Videos\\OneRepublic - Feel Again\\Gen\\TextMerge", "C:\\Videos\\OneRepublic - Feel Again\\Gen\\TextMerge\\fin.txt");
109+
File videoFolder = new File("C:\\Videos\\OneRepublic - Feel Again");
110+
List<File> frames = Arrays.asList(videoFolder.listFiles());
111+
Collections.sort(frames, new Comparator<File>() {
112+
@Override
113+
public int compare(File o1, File o2) {
114+
int num1 = Integer.parseInt(o1.getName().substring(5, o1.getName().indexOf(".")));
115+
int num2 = Integer.parseInt(o2.getName().substring(5, o2.getName().indexOf(".")));
116+
return num1 - num2;
117+
}
118+
});
119+
frames.forEach(new Consumer<File>() {
120+
121+
@Override
122+
public void accept(File t) {
123+
System.out.println(t.getName());
124+
}
125+
});
126+
}
127+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin/
2+
/target/

Punahele - External Adapters/.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Punahele - External Adapters</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

Punahele - External Adapters/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.punahele.adapters</groupId>
7+
<artifactId>Punahele-External_Adapters</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<name>Punahele - External Adapters</name>
10+
<description>External Adapters (Kafka, Redis, ElasticSearch) for Punahele</description>
11+
12+
<!-- Output to jar format -->
13+
<packaging>jar</packaging>
14+
<url>http://maven.apache.org</url>
15+
16+
<build>
17+
<finalName>PunaheleAdapters</finalName>
18+
<sourceDirectory>src</sourceDirectory>
19+
<plugins>
20+
<!-- Set a JDK compiler level -->
21+
<plugin>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>maven-compiler-plugin</artifactId>
24+
<version>2.3.2</version>
25+
<configuration>
26+
<source>1.8</source>
27+
<target>1.8</target>
28+
</configuration>
29+
</plugin>
30+
</plugins>
31+
</build>
32+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.punahele.adapters.elasticsearch;
2+
3+
public class ElasticSearchAdaper {
4+
5+
}

0 commit comments

Comments
 (0)