Added Videocut exception. Managed video duration error.

This commit is contained in:
Christian P. MOMON 2019-12-29 18:38:28 +01:00
parent ac99b395f8
commit a908675b02
2 changed files with 83 additions and 1 deletions

View file

@ -0,0 +1,72 @@
/**
* Copyright (C) 2019 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* This file is part of Videocut.
*
* Videocut is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Videocut is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Videocut. If not, see <http://www.gnu.org/licenses/>
*/
package fr.devinsy.videocut;
/**
* The Class JugaException.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class VideoCutException extends Exception
{
private static final long serialVersionUID = 5920490740327255439L;
/**
* Instantiates a new Juga exception.
*/
public VideoCutException()
{
super();
}
/**
* Instantiates a new Juga exception.
*
* @param message
* the message
*/
public VideoCutException(final String message)
{
super(message);
}
/**
* Instantiates a new Juga exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public VideoCutException(final String message, final Throwable cause)
{
super(message, cause);
}
/**
* Instantiates a new Juga exception.
*
* @param cause
* the cause
*/
public VideoCutException(final Throwable cause)
{
super(cause);
}
}

View file

@ -19,6 +19,7 @@
package fr.devinsy.videocut; package fr.devinsy.videocut;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import fr.devinsy.util.cmdexec.CmdExec; import fr.devinsy.util.cmdexec.CmdExec;
import fr.devinsy.util.cmdexec.CmdExecException; import fr.devinsy.util.cmdexec.CmdExecException;
@ -144,6 +145,7 @@ public class VideoCutUtils
* @return the double * @return the double
* @throws CmdExecException * @throws CmdExecException
* the cmd exec exception * the cmd exec exception
* @throws VideoCutException
*/ */
public static double videoDuration(final String videoFileName) throws CmdExecException public static double videoDuration(final String videoFileName) throws CmdExecException
{ {
@ -157,7 +159,15 @@ public class VideoCutUtils
System.out.println("log=[" + log + "]"); System.out.println("log=[" + log + "]");
result = Double.parseDouble(log); if (StringUtils.isBlank(log))
{
result = 0;
}
else
{
result = Double.parseDouble(log);
}
System.out.println("ret=[" + result + "]"); System.out.println("ret=[" + result + "]");
// //