Linux Shell Scripts
for
for video/audio file editing
using 'ffmpeg'

SAMPLE CODE for:
- clipping
- cropping
- converting (to mp4)
- changing audio volume
- extracting audio (to mp3)

Home > RefInfo menu >

Computer topics menu (Linux section) >

Handy Commands & Scripts Menu page >

This 'ffmpeg' Movie Editing Scripts (circa 2018-plus) page

! Note !
The scripts here may be touched up or
revised occasionally, if/when I re-visit this page.

Sections Below:

INTRO     CLIP     CROP     CONVERT(to mp4)

CHANGE-AUDIO-VOLUME     EXTRACT-AUDIO

MORE-INFO     BOTTOM-of-PAGE

INTRODUCTION :

Around 2010, I migrated my files (email, web browser bookmarks, documents, photos, etc.) from a Microsoft Windows personal computer to a home-built computer using Linux (Ubuntu 9.10, 'Karmic Koala').

For almost 10 years (to about 2019), I used the Linux-version of the 'ffmpeg' command to do various kinds of processing of 'media' (video and audio) files.

The kinds of processing that I performed at various times were

  • CLIPPING
    (from one time point to another)

  • CROPPING
    (from bottom and/or top and/or left and/or right)

  • CONVERTING
    (for example:
    from '.mpeg' or '.flv' container-format to '.mp4',
    with 'h264' video stream & 'aac' audio stream)

  • CHANGING AUDIO VOLUME
    (down or up)

  • EXTRACTING AUDIO
    (from a movie file, to a '.mp3' file)


Some 'ffmpeg' scripts developed with
an old version of 'ffmpeg', circa 2010:

There are a lot of 'VIDEOtools' (based on the 'ffmpeg' command) in an feNautilusScripts system at 'www.freedomenv.com'.

Those scripts are based on using them in a GUI file manager (originally, Gnome2-Nautilus - later MATE-Caja) in which

  • one selects ONE OR MORE video files to process
    (by navigating to a directory containing video files,
    and highlighting one or more of the video files)

  • then one invokes an appropriate VIDEOtools-script
    by using the 'Scripts' option of the right-click pop-up menu.


These 'ffmpeg' scripts developed with
a newer version of 'ffmpeg', circa 2020:

The scripts ON THIS PAGE are oriented toward a different method of use --- in a Linux terminal window --- processing one file at a time.

The procedure is

  1. copy one of the following scripts into a directory of video files

  2. open a Linux terminal window positioned in that directory of video files

  3. EDIT the script to set an appropriate INPUT FILENAME and OUTPUT FILENAME

      In the terminal window, you can use the 'ls' command to see the filename you want to use as input. Copy and paste that name into the script. You can use a similar name, but slightly different, for the output filename.

  4. Run the script by using the dot-slash technique --- that is, at the command-line prompt, enter (or paste) the string

      ./script-name.sh

    and press the Enter key.

  5. After you see that 'ffmpeg' is done (via the ffmpeg-messages in the terminal window), play the output video file in a video/audio player such as 'totem' or 'ffplay'.

    You can use the 'Open with' option of a GUI file manager, like MATE-Caja, to play the output video file with a GUI media player of your choice.

  6. If the output is not quite what was desired, edit the script to change appropriate 'ffmpeg' parameters and run the script again --- and test the output again.


Version used in developing these ffmpeg-scripts:

Back in the 2010 to 2019 period, I used an 'ffmpeg' version that was available when Ubuntu 9.10 ('Karmic Koala') was released, in October of 2009.

The scripts below were tested using ffmpeg version '3.4.6', which was available after Ubuntu-MATE 18.04 was released, in April of 2018.

Judging from the ffmpeg downloads page and/or the ffmpeg old-downloads page, the '3.4.6' version was released around 2020.

More specifically, a github page shows that the source code of '3.4.6' may have been released around March 2019.

A videohelp.com version-history page gives an idea of the many changes to ffmpeg (from version 0.3, before 2010, to present) --- via ffmpeg 'release notes'.

Release 0.5 of ffmpeg was released around March 2009, according to an lwn.net article. That may have been the relase of ffmpeg that I used on Ubuntu 9.10 for almost a decade (about 2010 to 2019).


How the scripts are presented, below:

The scripts are presented in two ways below:

  • as a link to a text file
    (click on the link and the file shows in a separate browser window)

  • as a scrollable block of text shown in this window
    (implemented by using the HTML 'object' tag)

You can see the comments, in the movie editing scripts below, for some details about the parameters being used in the 'ffmpeg'command in the scripts.

And you can see the exact way that the input and output files are being specified in those commands.


If you want to download any of these scripts for use, you can right-click on the '.txt' file link and choose an option such as 'Save Link Target As ...' in the popup menu that appears from your web browser.

After downloading one of these scripts, you can remove the '.txt' suffix from the file name and leave the '.sh' suffix.

Remember to change the permissions on the script file to make the file 'executable'.

You can use a command like 'chown 755 filename'.

OR, in a GUI file-manager like MATE-Caja, you can right-click on the '.sh' filename and choose the 'Properties' option from the menu that pops up. Then open the 'Permissions' panel and click the checkbutton titled 'Allow executing file as program'.

'ffmpeg' CLIP SCRIPT:

CLIP script link:
00_ffmpeg_mp4_CLIP.sh.txt

Alternative display of the CLIP script:

CLIP: Link to script

'ffmpeg' CROP SCRIPT:

CROP script link:
00_ffmpeg_mp4_CROP.sh.txt

Alternative display of the CROP script:

CROP: Link to script

'ffmpeg' CONVERT-to-mp4 SCRIPT:

CONVERT script link:
00_ffmpeg_CONVERTmovie_to_h264-aac-mp4.sh.txt

Alternative display of the CONVERT-to-mp4 script:

CONVERT: Link to script

'ffmpeg' CHG-AUDIO-VOLUME SCRIPT:

AUDIO-VOL script link:
00_ffmpeg_mp4_CHG_AUDIO_VOLUME.sh.txt

Alternative display of the CHG-AUDIO-VOLUME script:

AUDIO-VOL: Link to script

'ffmpeg' EXTRACT-AUDIO-to-mp3 SCRIPT:

AUDIO-EXTRACT script link:
00_ffmpeg_mp4_EXTRACT_AUDIO_to_mp3.sh.txt

Alternative display of the AUDIO-EXTRACT-to-mp3 script:

AUDIO-EXTRACT: Link to script

FOR MORE INFORMATION:

To find more information on using 'ffmpeg' for video/audio file-editing, you can try WEB SEARCHES on keywords such as the following.

You can also try Wikipedia pages like the following, and following links on those pages for even more information.

You can also try the ffmpeg Wiki at trac.ffmpeg.org/wiki/ for more help on using 'ffmpeg'. For example, see the links to ffmpeg Documentation.

You can also find ffmpeg help at video.stackexchange.com and stackoverflow.com and superuser.com and aksubuntu.com.

Bottom of this
Linux Movie Editing Scripts - using 'ffmpeg' page.

To return to a previously visited web page location, click on the Back button of your web browser a sufficient number of times.

OR, use the History-list option of your web browser.

OR ...

< Go to start of Code samples, above. >

< Go to Top of Page, above. >

Page history:

Page was created 2021 Jun 23.