I am converting video files to the .flv format using FFMPEG so that I can use LoaderMax (GreenSocks) to play the video files. The issue is that when the video is converted with FFMPEG the metadata is lost so I cannot later on with LoaderMax get the duration or current play time with the code below.
video.getTime();
video.duration();
I could get the duration of the video before converting it with FFMPEG easily enough but this doesn't solve the issue of being able to get the current play time. My goal is to allow the user to click on the seek bar and jump to any point in the video which works but for obvious reasons I need to be able to show the current time and video length.
I'm attempting to now use FFMPEG with something called flvtool2 which should rebuild the metadata?
My code currently for this:
nativeProcessInfo = new NativeProcessStartupInfo();
nativeProcessInfo.executable = File.applicationDirectory.resolvePath(ffmpegPath); //path to ffmpeg (included in project files)
//nativeProcessInfo.executable = File.applicationDirectory.resolvePath(flvtool2Path); //path to flvtool2 (included in project files)
var processArgument:Vector.<String> = new Vector.<String>(); //holds command line arguments for converting video
processArgument.push("-i"); //filename
processArgument.push(filePath);
processArgument.push("-s"); //size
processArgument.push("640x480");
processArgument.push("-b:v"); //bitrate - video
processArgument.push("4800k");
processArgument.push("-b:a"); //bitrate -
processArgument.push("6400k");
processArgument.push("-ar"); //audio sampling frequency
processArgument.push("44100");
processArgument.push("-ac"); //audio channels
processArgument.push("2");
processArgument.push("-ab"); //audio bitrate frequency
processArgument.push("160k");
processArgument.push("-f"); //force
processArgument.push("flv");
processArgument.push("-");
/*processArgument.push("|");
processArgument.push("flvtool2");
processArgument.push("-U");
processArgument.push("stdin");
processArgument.push(filePath);*/
nativeProcessInfo.arguments = processArgument;
if (NativeProcess.isSupported) {
nativeProcess = new NativeProcess();
nativeProcess.start(nativeProcessInfo); //start video buffering
nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, ProgressEventOutputHandler);
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, ProgressEventErrorHandler);
nativeProcess.addEventListener(NativeProcessExitEvent.EXIT, NativeProcessExitHandler);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, standardIOErrorHandler);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, standardIOErrorHandler);
} else {
trace("!NativeProcess.isSupported");
}
I've uploaded an example project to download which should help explain the problem. To use it you will need to point the ActionScript Properties to the location of Greensock to use LoaderMax and have a video somewhere on your computer to test with. The link is: http://www.prospectportal.co.uk/example.zip