Hi, All.
I do (and have been doing) a lot of video editing (for YT) over the last few years and made some tools that have made my job a Whole lot easier: GTK_Clipper and GTK_ClipAndCropper.
I hope they make your life easier too.
The gist of it is you can right-click on any video file and clip a/o crop it. outputting the file (so named) to the directory of the original file.
note: GTK_Clipper uses the ffmpeg options "-vcodec copy" and "-acodec copy" so is very fast.
GTK_ClipAndCropper uses the ffmpeg "-filter:v 'crop'" option so must re-encode the video and thus does take a while.
Hope they work well for you.
And I normally don't make changes to the things I post. Because they are designed to do 1 or maybe 2 jobs, completely and entirely effectively and Nothing else. No bells, no whistles, and not even any air.
![Smile :-)](./images/smilies/icon_smile.gif)
[for those who do not know how to use gtk files: In a window, right-click>New>Shell Script. This will create a new shell script. Open the script in a text editor and copy and paste the code below into the script. Save. it is now a runnable shell script.]
NOTE: you will get an ffmpeg "Invalid duration specification for ss: -i" error if you run the script NOT as a right click. It takes the file parameter from the right-click action. Also, I have not put error handling code in here, leaving that for anyone interested in doing it. So unexpected entries will have unexpected results.
Well, here goes, THE INSTRUCTIONS: The code/gtk files are both at the bottom.
-----------------------------
-----------------------------
GTK_CLIPPER
Author: Scott Vanya
License: GPL3
Purpose: to enable the right-click and then clip of video files
Dependencies: newer version of ffmpeg and (I am using this one so don't know how it works on others) gtkdialog version 0.7.21
Where the options are as follows:
Start in xx:yy:zz.aa time format
End in xx:yy:zz.aa time format
Suffix A suffix (to add to the output filename), ex. "test1", "clip5" etc.
Setup:
Place the shell script (or better yet a link to it) in "Rox SendTo" Folders subfolders at "/root/.config/rox.sourceforge.net/SendTo":
.video_dv
.video_mp4
.video_mpeg
.video_ogg
.video_quicktime
.video_webm
.video_x-flv
.video_x-matroska
.video_x-msvideo
.video_x-ms-wmv
Then for any of those file types you can right click, enter your parameters, click ENTER.
A terminal will open in which ffmpeg will run and begin outputing the file with the following filename pattern:
original_filename from start_time to end_time.$extension
-----------------------------
GTK_ClipAndCropper
Author: Scott Vanya
License: GPL3
Purpose: to enable the right-click and then clip and cropping of video files
Dependencies: newer version of ffmpeg
Where the options are as follows:
Start in xx:yy:zz.aa time format
End in xx:yy:zz.aa time format
OffsetX X coordinate of top left corner as counted from top-left corner of the video
OffsetY Y coordinate of top left corner as counted from top-left corner of the video
Width width in pixels of the output file
Height height in pixels of the output file
Suffix A suffix (to add to the output filename), ex. "test1", "clip5" etc.
Setup:
Place the shell script (or better yet a link to it) in "Rox SendTo" Folders subfolders at "/root/.config/rox.sourceforge.net/SendTo":
.video_dv
.video_mp4
.video_mpeg
.video_ogg
.video_quicktime
.video_webm
.video_x-flv
.video_x-matroska
.video_x-msvideo
.video_x-ms-wmv
Then for any of those file types you can right click, enter your parameters, click ENTER.
A terminal will open in which ffmpeg will run and begin outputing the file with the following filename pattern:
$name $SUFFIX from xx_yy_zz.aa to ii_jj_kk.bb - X=OffsetX,Y=OffsetY,W=Width,H=Height.$extension"
GTK_CLIPPER
Code: Select all
#! /bin/bash
#Title: GTK_Cipper
#Author: Scott Vanya
#License: GPL3
#Purpose: to enable the right-click and then clip of video files
#Dependencies: newer version of ffmpeg
#Where the options are as follows:
#Start in xx:yy:zz.aa time format
#End in xx:yy:zz.aa time format
#Suffix A suffix (to add to the output filename), ex. "test1", "clip5" etc.
#Setup:
#Place the shell script (or better yet a link to it) in "Rox SendTo" Folders subfolders at "/root/.config/rox.sourceforge.net/SendTo":
#.video_dv
#.video_mp4
#.video_mpeg
#.video_ogg
#.video_quicktime
#.video_webm
#.video_x-flv
#.video_x-matroska
#.video_x-msvideo
#.video_x-ms-wmv
#Then for any of those file types you can right click, enter your parameters, click ENTER.
#A terminal will open in which ffmpeg will run and begin outputing the file with the following filename pattern:
#original_filename from start_time to end_time.$extension
export currentfile="$@"
export dir="$PWD"
extension="${@##*.}"
echo "$extension"
fbname=$(basename "$@" .$extension)
name0=$(echo "$fbname" | sed 's/:/ /g')
name=$(echo "$name0" | sed 's/,/ /g')
path=$(echo ${currentfile##*/})
export DIR=$(dirname "$currentfile")
export name="$name"
export extension="$extension"
export MAIN_DIALOG='
<vbox>
<frame Player>
<text>
<label>Clip this file...</label>
</text>
<hbox>
<text><label>Enter START time (xx:yy:zz format)</label></text>
<entry accept="text">
<variable>START</variable>
</entry>
</hbox>
<hbox>
<text><label>Enter END time (xx:yy:zz format)</label></text>
<entry accept="text">
<variable>END</variable>
</entry>
</hbox>
<hbox>
<text>
<label>Enter title/suffix:</label>
</text>
<entry accept="text">
<variable>SUFFIX</variable>
</entry>
</hbox>
</frame>
<hbox>
<button use-stock="true" label="gtk-ok">
<variable>OKBUTTON</variable>
<action>duration=`date1=$(date -d "$START" +"%s");date2=$(date -d "$END" +"%s"); echo $(($date2-$date1))`;rxvt -hold -e ffmpeg -ss $START -i "$currentfile" -t "$duration" -vcodec copy -acodec copy "$DIR/$name from `echo $START | sed 's/:/_/g'` to `echo $END | sed 's/:/_/g'`-$SUFFIX.$extension"</action>
</button>
<button cancel></button>
</hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG
GTK_CipAndCropper
Code: Select all
#! /bin/bash
#Title: GTK_CipAndCropper
#Author: Scott Vanya
#License: GPL3
#Purpose: to enable the right-click and then clip and cropping of video files
#Dependencies: newer version of ffmpeg
#Where the options are as follows:
#Start in xx:yy:zz.aa time format
#End in xx:yy:zz.aa time format
#OffsetX X coordinate of top left corner as counted from top-left corner of the video
#OffsetY Y coordinate of top left corner as counted from top-left corner of the video
#Width width in pixels of the output file
#Height height in pixels of the output file
#Suffix A suffix (to add to the output filename), ex. "test1", "clip5" etc.
#Setup:
#Place the shell script (or better yet a link to it) in "Rox SendTo" Folders subfolders at "/root/.config/rox.sourceforge.net/SendTo":
#.video_dv
#.video_mp4
#.video_mpeg
#.video_ogg
#.video_quicktime
#.video_webm
#.video_x-flv
#.video_x-matroska
#.video_x-msvideo
#.video_x-ms-wmv
#Then for any of those file types you can right click, enter your parameters, click ENTER.
#A terminal will open in which ffmpeg will run and begin outputing the file with the following filename pattern:
#$name $SUFFIX from xx_yy_zz.aa to ii_jj_kk.bb - X=OffsetX,Y=OffsetY,W=Width,H=Height.$extension"
export currentfile="$@"
export dir="$PWD"
extension="${@##*.}"
echo "$extension"
fbname=$(basename "$@" .$extension)
name0=$(echo "$fbname" | sed 's/:/ /g')
name=$(echo "$name0" | sed 's/,/ /g')
path=$(echo ${currentfile##*/})
export DIR=$(dirname "$currentfile")
export name="$name"
export extension="$extension"
export MAIN_DIALOG='
<vbox>
<frame Player>
<text>
<label>Clip this file...</label>
</text>
<hbox>
<text><label>Enter START time (xx:yy:zz format)</label></text>
<entry accept="text">
<variable>START</variable>
</entry>
</hbox>
<hbox>
<text><label>Enter END time (xx:yy:zz format)</label></text>
<entry accept="text">
<variable>END</variable>
</entry>
</hbox>
<hbox>
<vbox>
<hbox>
<text><label>Offset X</label></text>
<entry accept="text">
<variable>x</variable>
</entry>
</hbox>
<hbox>
<text><label>Offset Y</label></text>
<entry accept="text">
<variable>y</variable>
</entry>
</hbox>
</vbox>
<vbox>
<hbox>
<text><label>Width</label></text>
<entry accept="text">
<variable>out_w</variable>
</entry>
</hbox>
<hbox>
<text><label>Height</label></text>
<entry accept="text">
<variable>out_h</variable>
</entry>
</hbox>
</vbox>
</hbox>
<hbox>
<text>
<label>Enter title/suffix:</label>
</text>
<entry accept="text">
<variable>SUFFIX</variable>
</entry>
</hbox>
</frame>
<hbox>
<button use-stock="true" label="gtk-ok">
<variable>OKBUTTON</variable>
<action>duration=`date1=$(date -d "$START" +"%s");date2=$(date -d "$END" +"%s"); echo $(($date2-$date1))`;rxvt -hold -e ffmpeg -ss $START -i "$currentfile" -t "$duration" -crf 0 -filter:v "crop=$out_w:$out_h:$x:$y" -acodec copy "$DIR/$name $SUFFIX from `echo $START | sed 's/:/_/g'` to `echo $END | sed 's/:/_/g'` - X=$x,Y=$y,W=$out_w,H=$out_h.$extension"</action>
</button>
<button cancel></button>
</hbox>
</vbox>
'
gtkdialog --program=MAIN_DIALOG