Terminal Apps

Beginner's Guide
After Installing Openbox
Alternatives & Galternative
Wallpaper Changer
Arachnophilia HTML
Araneae HTML Editor
FastStone Image Editor
Image Magick
MyStuff Menu
Openbox Menu
Openbox Dock
Openbox Dynamical Menu
Openbox Themes
PhotoFiltre Editor
Poor Mans Radio Player
Terminal Apps
Wbar Dock

There are a variety of terminal apps in or available to Linux distributions that have a small imprint and offer the user a broad range of operations. Rather than wasting space on a heavy geometrical application with a huge collection of tools, most of which are never used, why not just apply a lightweight terminal app, which is probably already installed, for just the specific operations that you use? The openbox window manager and the little app xdotool allow terminal command processes to be easily incorporated for the most part into the Openbox Root-menu, or if Obmenu-generator is used, into the obmenu schema.pl file. The ensuing structure is light-weight and can be designed to do exactly what the user wants, and no more. Here, we will show how to add two simple categories, one for editing audio using sox, and one for editing video using ffmpeg. Lxlinux already has sections discussing similar applications in Radio Streaming, Pmrp, Photo Editing, Image Magick and PDF Editing, Poppler-utils (PDF Utilities).

Video Editing Using Ffmpeg

file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
What are the 3 video edits most needed by amateur users? The answer is probably trimming, concatenating and format changing. Concatenate means to join the end of one video to the begining of a second one to create a combination video. Any number of videos can be concatenated in one simple step provided they are of the same stream type (same formats, time base, frame rate, frame size, containers, etc). First, create a text file listing the names of the videos in the order they are to be joined as illustrated in the chart on the right. Name it input.txt, and put it and all the videos to be joined in the same directory. Launch from this directory the following command, replacing output.mp4 by the name that you want and the common stream type of the inputs:

ffmpeg -f concat -i input.txt -codec copy output.mp4 .

Changing the format of a video is fairly complicated and really depends upon the end useage desired. To change the video container while freezing the audio and video codecs (for example, .mkv to .mp4), the command is

ffmpeg -i imput.mkv -vcodec copy -acodec copy imput.mp4 .

Audio-video quality is generally not improved by increasing the bit-rate, so keeping these parameters the same is generally the way to go. An excellent, simple introduction for using ffmpeg to make additional video format changes is in the Linux Journal.

You have a video with several different compositions. How do you cut the video to have separate videos for each composition? The ffmpeg command for this task has the following form:

ffmpeg -i input -ss ??:??:??.? -c copy -t ??:??:??.? output .

Here, input is the name of the video (for example, Beethoven.mp4), output is your chosen name for the cut (for example, Beethoven-sonata.mp4) and ??:??:??.? are relevant times in hours:minutes:seconds. The first time in the command is the starting time of the cut; the second time is the length or extent of the cut. Best quality is generally obtained by making the least (none) changes in the format. Thus,

ffmpeg -i Beethoven.mp4 -ss 00:13:26.0 -c copy -t 00:34:01.5 Beethoven-sonata.mp4 .

would create a new video named Beethoven-sonata.mp4 with length 34 minutes and 1.5 seconds identical (equal in quality) to the part of Beethoven.mp4 between 13 minutes, 26 seconds and 47 minutes, 27.5 seconds. The command should be issued from the directory containing Beethoven.mp4, which is where Beethoven-sonata.mp4 will appear.

x-terminal-emulator &
sleep 1
xdotool type "ffmpeg -i input -ss ??:??:??.???(start) -c copy -t ??:??:??.???(length) output" &

Most users are not professionals at these tasks, so it is helpful to have some gimmick for remembering the exact commands, which is basically what a GUI is. One can easily achieve this same end without the heavy weight of a geometrical structured GUI by using a simple text statement and file for each command. To illustrate with the ffmpeg trim command, copy and paste the text in the box on the left to a text file, name it something like ffmpeg-trim, put it in /usr/local/bin and make it executable. Next, put an appropriate entry with exec=ffmpeg-trim in the menu of your choice. In the case of Obmenu-generator the entries for a ffmpeg category in schema.pl could be as shown in the chart on the left, which produces the menu pictured on the right. Of course, the user has to modify this chart to reflect his text editor (for input.txt) and icons.

{begin_cat => ['Ffmpeg', '/usr/share/icons/fbpanel/ffmpeg.png']},
        {item => ['ffmpeg-trim', 'Trim Video', '/usr/share/icons/fbpanel/ffmpeg2.png']},
        {item => ['ffmpeg-concat', 'Concat Videos', '/usr/share/icons/fbpanel/ffmpeg2.png']},
        {item => ['ffmpeg-format', 'Format Video', '/usr/share/icons/fbpanel/ffmpeg2.png']},
        {item => ['bl-text-editor ~/bin/input.txt', 'Concat Input.txt', '/usr/share/icons/fbpanel/ffmpeg2.png']},
{end_cat => undef},
Ffmpeg Category in Schema.pl
Submenus for Ffmpeg & Sox

To carry out an action, click the appropriate menu item (see image on the right) to launch a terminal with the command skeleton as shown above already entered. Simply complete the command for your situation and click the enter key. The terminal launches from the home directory, so the commands are set-up to have all the pertinent files and the result file in your home directory. If you have the video files stored in another directory or want the resulting video to appear in another directory, then edit the command to paths to the pertinent videos rather than just names.

Audio Editing Using Sox

Sox is a terminal app that is easy to use for simple tasks. The image above-right shows a submenu programmed with 5 sox applications. The commands for these 5 tasks are the following, respectively:

  • Concatenate:    sox input1 input2 output    Combines end of input1 to start of input2;
  • Record:    rec -c 2 ~/Music/$(shuf -i 1-10000 -n 1).flac    Records audio from sound card and saves it as ~/Music/n.flac, where n is a random integer between 1 and 10,000;
  • Translate:    sox input.1 output.2    Changes audio format from "1" to "2";
  • Trim:    sox input output trim start-sec length-sec    "Start-sec" is starting time in seconds, "length-sec" is the duration of the cut in seconds;
  • Volume:    sox -v n imput output    Choose "n" to be an integer, n=4 is usually a good choice for a modest volume increase.
  • The sox submenu category is constructed the same way as described for the ffmpeg category above. The Record button can be made to start recording immediately upon clicking it (without messing with adjusting the terminal entry) by adding the following 2 lines to the launcher script /usr/local/bin/sox-record:

            sleep 1
            xdotool key "Return" &