Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paratechnical/9655b4ef4108501b5a950afbd749aa36 to your computer and use it in GitHub Desktop.
Save paratechnical/9655b4ef4108501b5a950afbd749aa36 to your computer and use it in GitHub Desktop.
Modify mp4 - moov atom at the front of the file (Fast Start)
//add compile 'net.ypresto.qtfaststartjava:qtfaststart:0.1.0' to build.gradle
String videoFileNameWithoutExtension = com.google.common.io.Files.getNameWithoutExtension(path2OutputFile);
File outputFile = new File(path2OutputFile); // Your outputFile file
String pathToParent = outputFile.getParent();
Path noStreamOutputFile = Paths.get(pathToParent, videoFileNameWithoutExtension + "_nostream.mp4");
Files.move(outputFile.toPath(), noStreamOutputFile);
try {
QtFastStart.fastStart(new File(noStreamOutputFile.toString()), outputFile);
} catch (QtFastStart.MalformedFileException ex) {
Logger.getLogger(AudioVideoHelpers.class.getName()).log(Level.SEVERE, null, ex);
} catch (QtFastStart.UnsupportedFileException ex) {
Logger.getLogger(AudioVideoHelpers.class.getName()).log(Level.SEVERE, null, ex);
}
Files.delete(noStreamOutputFile);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment