FFMPEG is timing out and getting killed before completing process
$10-100 USD
已关闭
已发布超过 7 年前
$10-100 USD
货到付款
I have a script that takes an mp4 file and splits it into another mp4 file. It basically takes a section like 00:22:38 to 00:23:16 and creates a new video from that time segment.
The problem is that for larger files the process stops and gets killed before finishing.
ffmpeg -i "/uploads/files/[login to view URL]" -ss 00:22:38 -t 00:23:16 -async 1 "/uploads/files/[login to view URL]"
problem is [login to view URL]() does not wait and the process is killed without any errors in the log file.
the process actually starts but killed before completion.
This is the script that is called.
@RequestMapping(value = "/videotrim", method = [login to view URL])
public void trimVideo(@RequestParam Long id, @RequestParam("start-time") Integer startTime, @RequestParam("end-time") Integer endTime) {
[login to view URL](getClass().getName()).log([login to view URL], "called");
Document one = [login to view URL](id);
[login to view URL](getClass().getName()).log([login to view URL], "called" + [login to view URL]);
String inputFile = [login to view URL]("%20"," ");
final String movieFile = "/uploads" + inputFile;
final String resultFile = "/uploads/files/" + id + "-" + startTime + "-" + endTime + ".mp4";
//ffmpeg -i [login to view URL] -ss 00:00:03 -t 00:00:08 -async 1 [login to view URL]
Time start = new Time(startTime * 1000);
Time end = new Time(endTime * 1000);
final String startTimeSec = [login to view URL]();
final String endTimeSec = [login to view URL]();
Runnable runnable = new Runnable() {
public void run() {
try {
File file = new File(resultFile);
if (![login to view URL]()) {
final String command = "ffmpeg -i \"" + movieFile + "\" -ss " + startTimeSec + " -t " + endTimeSec + " -async 1 \"" + resultFile + "\"";
[login to view URL](getClass().getName()).log([login to view URL], "running: " + command);
ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-i", movieFile, "-ss", startTimeSec, "-t", endTimeSec, "-async", "1", resultFile);
pb = [login to view URL](true); // equivalent of 2>&1
Process p = [login to view URL]();
[login to view URL]();
file = new File(resultFile);
[login to view URL](true,false);
} else {
[login to view URL](true,false);
}
} catch (Throwable e) {
[login to view URL](getClass().getName()).log([login to view URL], "error while trim video", e);
[login to view URL]();
}
}
};
new Thread(runnable).start();
}
Hello. More 20 years programming experience.
I need more details to set real time and price.
Regards.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hello,
I know how to solve the problem.
I have great experience in performing tasks. I developed media-server, that handled both video and audio, uncluding convertation. I also developed a FFmpeg wrapper for Java.
You do not mention which OS you are running on, but may I assume you're on Windows 7?
I might be wrong, but I think I know where the problem could be and how to fix it.
Thanks!
Luis