Replaced byte way with timecode way. Added notify-send call.

This commit is contained in:
Christian P. MOMON 2019-12-16 04:15:37 +01:00
parent 91c60ab028
commit 1dc6dedb58
22 changed files with 668 additions and 82 deletions

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/devinsy-utils-0.3.1-sources.zip"/>
<classpathentry kind="lib" path="lib/devinsy-utils-0.3.1.jar" sourcepath="lib/devinsy-utils-0.3.1-sources.zip"/>
<classpathentry kind="lib" path="lib/log4j-1.2.17-source.zip"/>
@ -12,5 +11,11 @@
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/forms-1.3.0.jar"/>
<classpathentry kind="lib" path="lib/miglayout15-swing.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.7.jar" sourcepath="lib/commons-lang3-3.7-sources.jar"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="lib" path="lib/UnitTesting/jcommander-1.48.jar" sourcepath="lib/UnitTesting/jcommander-1.48-sources.jar"/>
<classpathentry kind="lib" path="lib/UnitTesting/testng-6.9.10.jar" sourcepath="lib/UnitTesting/testng-6.9.10-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/commons-io-2.5.jar" sourcepath="lib/commons-io-2.5-src.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -13,5 +18,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

View file

@ -10,15 +10,16 @@ org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
</faceted-project>

View file

@ -1,7 +1,7 @@
# Videocut
Videocut is a hugly hashing cutter for video files.
Videocut is a hashing cutter for video files.
## Author
Christian Pierre MOMON &lt;christian.momon@devinsy.fr&gt;
@ -12,7 +12,7 @@ Videocut is released under the GNU AGPL license.
## Requirements
Videocut requires:
- Java 1.6
- Java 1.8
## Logo
@ -22,4 +22,3 @@ Logo origin:
## Conclusion
Enjoy and use FlatDB4GeoNames. For questions, improvement, issues: christian.momon@devinsy.fr

View file

@ -9,13 +9,11 @@
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${basedir}/bin"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/devinsy-utils-0.3.1-sources.zip"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/commons-io-2.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/commons-lang3-3.7.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/devinsy-utils-0.3.1.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/log4j-1.2.17-source.zip"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/log4j-1.2.17.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/slf4j-api-1.7.5-sources.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/slf4j-api-1.7.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/slf4j-log4j12-1.7.5-sources.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/slf4j-log4j12-1.7.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/forms-1.3.0.jar"/>
<zipfileset excludes="META-INF/*.SF" src="${basedir}/lib/miglayout15-swing.jar"/>

BIN
dist/videocut.jar vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,283 @@
<!--
Copyright (C) 2010 the original author or authors.
See the notice.md file distributed with this work for additional
information regarding copyright ownership.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<packaging>jar</packaging>
<name>JCommander</name>
<version>1.48</version>
<description>A Java framework to parse command line options with annotations.</description>
<url>http://beust.com/jcommander</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:cbeust/jcommander.git</connection>
<developerConnection>scm:git:git@github.com:cbeust/jcommander.git</developerConnection>
<url>git@github.com:cbeust/jcommander.git</url>
</scm>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Staging Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<developers>
<developer>
<name>Cedric Beust</name>
</developer>
</developers>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>3</version>
</parent>
<build>
<plugins>
<!-- Bundle sources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Compilation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Resource handling -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- OSGi manifest creation -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<_versionpolicy>$(@)</_versionpolicy>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
<!-- Add OSGi manifest in JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<!-- Tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<dependencies>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.30</version>
<!--
<version>${project.version}</version>
-->
</dependency>
</dependencies>
</plugin>
<!-- Generating Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<excludePackageNames>*.internal</excludePackageNames>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.felix</groupId>
<artifactId>
maven-bundle-plugin
</artifactId>
<versionRange>
[2.1.0,)
</versionRange>
<goals>
<goal>manifest</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<type>jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>jcommander</artifactId>
<groupId>com.beust</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<profiles>
<!--
Do a license check by running : mvn -P license license:check
UPdate the license check by running : mvn -P license license:format
-->
<profile>
<id>license</id>
<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.7.0</version>
<configuration>
<quiet>false</quiet>
<header>src/main/license/license-header.txt</header>
<includes>
<include>src/**</include>
<include>pom.xml</include>
</includes>
<excludes>
<exclude>**/.git/**</exclude>
<!-- ignore files produced during a build -->
<exclude>**/target/**</exclude>
</excludes>
<useDefaultExcludes>false</useDefaultExcludes>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Signing with gpg -->
<!--
Sign the artifacts by calling
mvn -P sign [..]
-->
<profile>
<id>sign</id>
<build>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<dependencies>
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.15</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0</version>
<classifier>no_aop</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

BIN
lib/commons-io-2.5-src.jar Normal file

Binary file not shown.

BIN
lib/commons-io-2.5.jar Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/commons-lang3-3.7.jar Normal file

Binary file not shown.

View file

@ -60,54 +60,54 @@ public class VideoCutCLI
switch (c)
{
// Start keys.
// Start keys.
case 'a':
data.incStart(-VideoData.HUNDRED_MEGA);
data.incStart(-VideoData.TWO_MINUTES);
break;
case 'z':
data.incStart(VideoData.HUNDRED_MEGA);
data.incStart(VideoData.TWO_MINUTES);
break;
case 'e':
data.incStart(-VideoData.TEN_MEGA);
data.incStart(-VideoData.TEN_SECONDS);
break;
case 'r':
data.incStart(VideoData.TEN_MEGA);
data.incStart(VideoData.TEN_SECONDS);
break;
case 't':
data.incStart(-VideoData.ONE_MEGA);
data.incStart(-VideoData.ONE_SECOND);
break;
case 'y':
data.incStart(VideoData.ONE_MEGA);
data.incStart(VideoData.ONE_SECOND);
break;
// End keys.
case 'q':
data.incEnd(-VideoData.HUNDRED_MEGA);
data.incEnd(-VideoData.TWO_MINUTES);
break;
case 's':
data.incEnd(VideoData.HUNDRED_MEGA);
data.incEnd(VideoData.TWO_MINUTES);
break;
case 'd':
data.incEnd(-VideoData.TEN_MEGA);
data.incEnd(-VideoData.TEN_SECONDS);
break;
case 'f':
data.incEnd(VideoData.TEN_MEGA);
data.incEnd(VideoData.TEN_SECONDS);
break;
case 'g':
data.incEnd(-VideoData.ONE_MEGA);
data.incEnd(-VideoData.ONE_SECOND);
break;
case 'h':
data.incEnd(VideoData.ONE_MEGA);
data.incEnd(VideoData.ONE_SECOND);
break;
// Control keys.

View file

@ -1,5 +1,5 @@
/**
* Copyright (C) 2016-2018 Christian Pierre MOMON <christian.momon@devinsy.fr>
* Copyright (C) 2016-2019 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* This file is part of Videocut.
*
@ -84,87 +84,91 @@ public class VideoCutGUI extends JFrame
//
switch (event.getKeyChar())
{
// Start keys.
// Start keys.
case 'a':
VideoCutGUI.this.data.incStart(-VideoData.HUNDRED_MEGA);
VideoCutGUI.this.data.incStart(-VideoData.TWO_MINUTES);
break;
case 'z':
VideoCutGUI.this.data.incStart(VideoData.HUNDRED_MEGA);
VideoCutGUI.this.data.incStart(VideoData.TWO_MINUTES);
break;
case 'e':
VideoCutGUI.this.data.incStart(-VideoData.TEN_MEGA);
VideoCutGUI.this.data.incStart(-VideoData.TEN_SECONDS);
break;
case 'r':
VideoCutGUI.this.data.incStart(VideoData.TEN_MEGA);
VideoCutGUI.this.data.incStart(VideoData.TEN_SECONDS);
break;
case 't':
VideoCutGUI.this.data.incStart(-VideoData.ONE_MEGA);
VideoCutGUI.this.data.incStart(-VideoData.ONE_SECOND);
break;
case 'y':
VideoCutGUI.this.data.incStart(VideoData.ONE_MEGA);
VideoCutGUI.this.data.incStart(VideoData.ONE_SECOND);
break;
case 'u':
VideoCutGUI.this.data.incStart(-VideoData.ONE_TENTH);
break;
case 'i':
VideoCutGUI.this.data.incStart(VideoData.ONE_TENTH);
break;
// End keys.
case 'q':
VideoCutGUI.this.data.incEnd(-VideoData.HUNDRED_MEGA);
VideoCutGUI.this.data.incEnd(-VideoData.TWO_MINUTES);
break;
case 's':
VideoCutGUI.this.data.incEnd(VideoData.HUNDRED_MEGA);
VideoCutGUI.this.data.incEnd(VideoData.TWO_MINUTES);
break;
case 'd':
VideoCutGUI.this.data.incEnd(-VideoData.TEN_MEGA);
VideoCutGUI.this.data.incEnd(-VideoData.TEN_SECONDS);
break;
case 'f':
VideoCutGUI.this.data.incEnd(VideoData.TEN_MEGA);
VideoCutGUI.this.data.incEnd(VideoData.TEN_SECONDS);
break;
case 'g':
VideoCutGUI.this.data.incEnd(-VideoData.ONE_MEGA);
VideoCutGUI.this.data.incEnd(-VideoData.ONE_SECOND);
break;
case 'h':
VideoCutGUI.this.data.incEnd(VideoData.ONE_MEGA);
VideoCutGUI.this.data.incEnd(VideoData.ONE_SECOND);
break;
case 'j':
VideoCutGUI.this.data.incEnd(-VideoData.ONE_TENTH);
break;
case 'k':
VideoCutGUI.this.data.incEnd(VideoData.ONE_TENTH);
break;
// Control keys.
case 'o':
{
String command = String.format("tail -c +%d %s | mplayer -geometry 1024x768 -", VideoCutGUI.this.data.getStart(), VideoCutGUI.this.data.getEscapedFileName());
System.out.println("command=[" + command + "@]");
String log;
log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
VideoCutUtils.playVideo(VideoCutGUI.this.data.getEscapedFileName(), VideoCutGUI.this.data.getStart());
}
break;
case 'p':
{
String command = String.format("tail -c +%d %s | mplayer -geometry 1024x768 -", VideoCutGUI.this.data.getEnd(), VideoCutGUI.this.data.getEscapedFileName());
String log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
VideoCutUtils.playVideo(VideoCutGUI.this.data.getEscapedFileName(), VideoCutGUI.this.data.getEnd());
}
break;
case 'm':
{
VideoCutGUI.this.txtfldStatus.setText("Making");
String command = String.format("head -c %d %s | tail -c +%d > t", VideoCutGUI.this.data.getEnd(), VideoCutGUI.this.data.getEscapedFileName(),
VideoCutGUI.this.data.getStart());
String log = CmdExec.run("bash", "-c", command);
VideoCutUtils.cut(VideoCutGUI.this.data.getEscapedFileName(), VideoCutGUI.this.data.getStart(), VideoCutGUI.this.data.getEnd());
VideoCutUtils.notify("Cut done.");
VideoCutGUI.this.txtfldStatus.setText("Made");
System.out.println("log=[" + log + "]");
}
break;
@ -202,7 +206,7 @@ public class VideoCutGUI extends JFrame
});
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 700, 400);
setBounds(100, 100, 720, 400);
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
@ -229,12 +233,13 @@ public class VideoCutGUI extends JFrame
this.contentPane = new JPanel();
this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(this.contentPane);
this.contentPane.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));
this.contentPane.setLayout(new FormLayout(
new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, },
new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));
JLabel lblFile = new JLabel("File:");
lblFile.setFocusable(false);
@ -272,10 +277,10 @@ public class VideoCutGUI extends JFrame
JLabel lblCommands = new JLabel("Keyboard actions:");
this.contentPane.add(lblCommands, "4, 10");
JLabel lblStartPointA = new JLabel(" start point: a z (-/+ 100 MB), e r (-/+ 10 MB), t y (-/+ 1 MB)");
JLabel lblStartPointA = new JLabel(" start point: a z (-/+ 2 min), e r (-/+ 10 s), t y (-/+ 1 s), u i (-/+ 0,1 s)");
this.contentPane.add(lblStartPointA, "4, 12");
JLabel lblEndPointQ = new JLabel(" end point: q s (-/+ 100 MB), d f (-/+ 10 MB), g h (-/+ 1 MB)");
JLabel lblEndPointQ = new JLabel(" end point: q s (-/+ 2 min), d f (-/+ 10 s), g h (-/+ 1 s), j k (-/+ 0,1 s)");
this.contentPane.add(lblEndPointQ, "4, 14");
JLabel lblH = new JLabel(" show from start point: o");

View file

@ -0,0 +1,166 @@
/**
* 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;
import org.apache.commons.io.FilenameUtils;
import fr.devinsy.util.cmdexec.CmdExec;
import fr.devinsy.util.cmdexec.CmdExecException;
/**
* The Class VideoCut.
*
* @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/
public class VideoCutUtils
{
/**
* @param videoFileName
* @param startTime
* @param endTime
* @throws CmdExecException
*/
public static void cut(final String videoFileName, final double startTime, final double endTime) throws CmdExecException
{
String targetFileName = "t." + FilenameUtils.getExtension(videoFileName);
String command = String.format("ffmpeg -v quiet -y -i %s -ss %S -t %s -codec copy -map 0 %s ", videoFileName, startTime, endTime - startTime, targetFileName);
String log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
}
/**
* @param videoFileName
* @param start
* @param end
* @throws CmdExecException
*/
public static void cutByByte(final String videoFileName, final long start, final long end) throws CmdExecException
{
String command = String.format("head -c %d %s | tail -c +%d > t", end, videoFileName, start);
String log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
}
/**
* Human time.
*
* @param value
* the source
* @return the string
*/
public static String humanTimeCode(final double value)
{
String result;
double hours = Math.floor(value / (60 * 60));
double minutes = Math.floor((value - hours * 60 * 60) / 60);
double seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);
double micros = (value - Math.floor(value)) * 1000000;
result = String.format("%02.0f:%02.0f:%02.0f.%06.0f", hours, minutes, seconds, micros);
//
return result;
}
/**
* @param text
* @throws CmdExecException
*/
public static void notify(final String text) throws CmdExecException
{
String command = String.format("notify-send -i '/usr/share/icons/gnome/32x32/actions/editcut.png' 'VideoCut' '%s'", text);
System.out.println("command=[" + command + "]");
String log;
log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
}
/**
* @param videoFileName
* @param startByte
* @throws CmdExecException
*/
public static void playVideo(final String videoFileName, final double startByte) throws CmdExecException
{
String command = String.format("ffmpeg -v quiet -i %s -ss %s -vcodec copy -acodec copy -f avi - | mplayer -geometry 1024x768 -", videoFileName, VideoCutUtils.humanTimeCode(startByte));
System.out.println("command=[" + command + "@]");
String log;
log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
}
/**
* Play at byte.
*
* @param videoFileName
* the video file name
* @param startByte
* the start byte
* @throws CmdExecException
* the cmd exec exception
*/
public static void playVideoAtByte(final String videoFileName, final double startByte) throws CmdExecException
{
String command = String.format("tail -c +%d %s | mplayer -geometry 1024x768 -", startByte, videoFileName);
System.out.println("command=[" + command + "@]");
String log;
log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
}
/**
* Video duration.
*
* ffprobe -i foo.m2ts -show_format -v quiet | grep duration | sed s/[^0-9\.]//g
*
* @param videoFile
* the video file
* @return the double
* @throws CmdExecException
* the cmd exec exception
*/
public static double videoDuration(final String videoFileName) throws CmdExecException
{
double result;
String command = String.format("ffprobe -i %s -show_format -v quiet | grep duration | sed s/[^0-9\\.]//g", videoFileName);
System.out.println("command=[" + command + "]");
String log;
log = CmdExec.run("bash", "-c", command);
System.out.println("log=[" + log + "]");
result = Double.parseDouble(log);
System.out.println("ret=[" + result + "]");
//
return result;
}
}

View file

@ -20,6 +20,8 @@ package fr.devinsy.videocut;
import java.io.File;
import fr.devinsy.util.cmdexec.CmdExecException;
/**
* The Class VideoData.
*
@ -27,27 +29,39 @@ import java.io.File;
*/
public class VideoData
{
public static final long ONE_MEGA = 1024 * 1024;
public static final long TEN_MEGA = 10 * 1024 * 1024;
public static final long HUNDRED_MEGA = 100 * 1024 * 1024;
public static final double ONE_TENTH = 0.1;
public static final double ONE_SECOND = 1;
public static final double TEN_SECONDS = 10;
public static final double TWO_MINUTES = 120;
private String escapedFileName;
private File source;
private long start;
private long end;
private double sourceEnd;
private double start;
private double end;
/**
* Instantiates a new video data.
*
* @param source
* the source
* @throws CmdExecException
*/
public VideoData(final File source)
{
this.source = source;
this.escapedFileName = escape(source.getAbsolutePath());
try
{
this.sourceEnd = VideoCutUtils.videoDuration(this.escapedFileName);
}
catch (CmdExecException exception)
{
exception.printStackTrace();
this.sourceEnd = 0;
}
this.start = 0;
this.end = source.length();
this.end = this.sourceEnd;
}
/**
@ -55,7 +69,7 @@ public class VideoData
*
* @return the end
*/
public long getEnd()
public double getEnd()
{
return this.end;
}
@ -85,7 +99,7 @@ public class VideoData
*
* @return the start
*/
public long getStart()
public double getStart()
{
return this.start;
}
@ -96,22 +110,22 @@ public class VideoData
* @param value
* the value
*/
public void incEnd(final long value)
public void incEnd(final double value)
{
this.end += value;
if (this.end < this.start)
{
this.end = this.start + ONE_MEGA;
this.end = this.start + ONE_SECOND;
}
if (this.end < 0)
{
this.end = ONE_MEGA;
this.end = ONE_SECOND;
}
else if (this.end > this.source.length())
else if (this.end > this.sourceEnd)
{
this.end = this.source.length();
this.end = this.sourceEnd;
}
}
@ -121,13 +135,13 @@ public class VideoData
* @param value
* the value
*/
public void incStart(final long value)
public void incStart(final double value)
{
this.start += value;
if (this.start > this.end)
{
this.start = this.end - ONE_MEGA;
this.start = this.end - ONE_SECOND;
}
if (this.start < 0)
@ -136,7 +150,7 @@ public class VideoData
}
else if (this.start > this.source.length())
{
this.start = this.source.length() - ONE_MEGA;
this.start = this.source.length() - ONE_SECOND;
}
}
@ -146,7 +160,7 @@ public class VideoData
* @param end
* the new end
*/
public void setEnd(final long end)
public void setEnd(final double end)
{
this.end = end;
}
@ -168,7 +182,7 @@ public class VideoData
* @param start
* the new start
*/
public void setStart(final long start)
public void setStart(final double start)
{
this.start = start;
}
@ -181,7 +195,8 @@ public class VideoData
{
String result;
result = String.format("[%,dMB ; %,dMB ] %,dMB / %,dMB", this.start / 1024, this.end / 1024, (this.end - this.start) / 1024, this.source.length() / 1024);
result = String.format("[%s ; %s ] %s / %s (-%s)", VideoCutUtils.humanTimeCode(this.start), VideoCutUtils.humanTimeCode(this.end), VideoCutUtils.humanTimeCode(this.end - this.start),
VideoCutUtils.humanTimeCode(this.sourceEnd), VideoCutUtils.humanTimeCode(this.sourceEnd - (this.end - this.start)));
//
return result;

View file

@ -0,0 +1,55 @@
package fr.devinsy.videocut.utils;
import org.testng.Assert;
import org.testng.annotations.Test;
import fr.devinsy.videocut.VideoCutUtils;
/**
*
* @author cpm
*/
public class VideoCutUtilsTest
{
/**
*
*/
@Test
public void aFooTest()
{
Assert.assertTrue(true);
}
/**
* Human time code test.
*/
@Test
public void humanTimeCodeTest()
{
double value = 0.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 5.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 59.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 65.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 3500.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 3700.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 37000.178;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
value = 4167.3041;
System.out.println(String.format("%10s", value) + " -> " + VideoCutUtils.humanTimeCode(value));
Assert.assertTrue(true);
}
}