19.08.2013 Views

Vmoox: Cross-platform Video Publishing Solution ... - pace university

Vmoox: Cross-platform Video Publishing Solution ... - pace university

Vmoox: Cross-platform Video Publishing Solution ... - pace university

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VEDA uses ffmpeg in order to transcode flash videos to H.264/AVC videos.<br />

Below is the implementation of generateChapter(final String inputFile-<br />

Name,final Integer from, final Integer duration) method. This method<br />

as input receives the path to the original flash video file, the from and duration of<br />

the transcoding. As output this method returns the path to the new H.264/AVC<br />

video file.<br />

private String generateChapter(final String inputFileName,<br />

final Integer from, final Integer duration) {<br />

ArrayList cmdList = new ArrayList();<br />

cmdList.add(h264Transformation+"./h264_h");<br />

cmdList.add(localMediaPath + inputFileName);<br />

cmdList.add(duration.toString());<br />

cmdList.add(from.toString());<br />

cmdList.add(h264MediaPath + inputFileName.replace(".flv",<br />

"") + "_"<br />

+ from + "_" + duration + "." +<br />

fileOutPutExtension);<br />

Runtime rt = Runtime.getRuntime();<br />

Process proc = rt.exec(cmdList.toArray(new String[0]));<br />

// any error message?<br />

StreamGobbler errorGobbler = new StreamGobbler(proc<br />

.getErrorStream(), "ERROR");<br />

}<br />

// any output?<br />

StreamGobbler outputGobbler = new StreamGobbler(proc<br />

.getInputStream(), "OUTPUT");<br />

errorGobbler.start();<br />

outputGobbler.start();<br />

return inputFileName.replace(".flv", "") + "_" + from + "_"<br />

+ duration;<br />

This method uses Java's RunTime and Process classes in order to execute a<br />

shell script that class the ffmpeg program. Below is the implementation of the<br />

h264_h shell script:<br />

/opt/local/bin/ffmpeg -y -threads 0 -i $1 -vcodec libx264 -s<br />

480x272 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -<br />

- 46 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!