I have a bash script and a php script that function in concert to trim audio/video files using start/stop times.
<?php // Create datetime objcects $dt1 = new DateTime($argv); $dt2 = new DateTime($argv); // Conver difference to seconds $dt3 = $dt2->format('U') - $dt1->format('U'); // echo $dt3."\n"; $h = (int)($dt3 / 3600); $dt3 %= 3600; $m = (int)($dt3 / 60); $dt3 %= 60; $s = $dt3; // Dump as H:M:S echo $h . ":" . $m . ":" . $s; ?>
#!/bin/bash INFILE=$1 START=$2 STOP=$3 OUTFILE=$4 OFFSET=`php TimeDiff.php "$START" "$STOP"` echo "Disecting $INFILE starting from $START to $STOP (duration $OFFSET)" ffmpeg -ss "$START" -t "$OFFSET" -i "$INFILE" "$OUTFILE"
./chopvideoaudio.sh [input.mp4] [startchop] [stopchop] [output.mp4]
Where [startchop] and [stopchop] are both absolute timestamps from the beginning of the track.
Example command to run this script:
./chopvideoaudio.sh input.mp4 00:01:20 00:01:45 output.mp4
I want a YAD (yet another dialog) script that will open up a dialog box(es) containing an input field to enter a custom file type (e.g. mp3, mp4, avi). Then input fields for the two timestamps, in which I can enter two custom timestamps. After pressing
OK the script will run and extract the section from between the two timestamps.
I would also be interested in a solution using Zenity, but I prefer YAD.