I have an coldfusion application. I am converting recorded video from mobile through ffmpeg and coldfusion. Here is the ffmpeg command which i am running.
ffmpegPath -i "inputfile" -vcodec libx264 -acodec aac "OutputFile"
Output file type is mp4. I want to convert my all videos to mp4 with h.264 and ACC sound. So that it will work on all platforms.
I am getting the following error:
java.io.IOException: ffmpeg returned non-zero exit status. Check stdout.
Here is the CF code that i am running.
<cfset resultLog = "path\to\directory\testOuput_result.log">
<cfset errorLog = "path\to\directory\testOuput_error.log">
<cfset results = structNew()>
<cfscript>
try {
runtime = createObject("java", "java.lang.Runtime").getRuntime();
command = 'ffmpegPath -i "inputfile" -vcodec libx264 -acodec aac "OutputFile"';
process = runtime.exec(#command#);
results.errorLogSuccess = processStream(process.getErrorStream(), errorLog);
results.resultLogSuccess = processStream(process.getInputStream(), resultLog);
results.exitCode = process.waitFor();
}
catch(exception e) {
results.status = e;
}
</cfscript>
<cffunction name="processStream" access="public" output="false" returntype="boolean" hint="Returns true if stream was successfully processed">
<cfargument name="in" type="any" required="true" hint="java.io.InputStream object">
<cfargument name="logPath" type="string" required="false" default="" hint="Full path to LogFile">
<cfset var out = "">
<cfset var writer = "">
<cfset var reader = "">
<cfset var buffered = "">
<cfset var line = "">
<cfset var sendToFile = false>
<cfset var errorFound = false>
<cfscript>
if ( len(trim(arguments.logPath)) ) {
out = createObject("java", "java.io.FileOutputStream").init(arguments.logPath);
writer = createObject("java", "java.io.PrintWriter").init(out);
sendToFile = true;
}
reader = createObject("java", "java.io.InputStreamReader").init(arguments.in);
buffered = createObject("java", "java.io.BufferedReader").init(reader);
line = buffered.readLine();
while ( IsDefined("line") ) {
if (sendToFile) {
writer.println(line);
}
line = buffered.readLine();
}
if (sendToFile) {
errorFound = writer.checkError();
writer.flush();
writer.close();
}
</cfscript>
<!--- return true if no errors found. --->
<cfreturn (NOT errorFound)>
</cffunction>
I have also used different ffmpeg.exe but got same error. I have also used ffmpeg-cli-wrapper java wrapper in coldfusion. Still i got the same error. Can any one help me to sort out this issue.