Results 1 to 5 of 5

Thread: Command line 'trimming' a sound file?

  1. #1
    Join Date
    Jan 2008
    Beans
    69

    Command line 'trimming' a sound file?

    I have lots of audio podcasts that all have the same introduction, which is tiresome to listen to each time. Is there a way I can delete the first 30 seconds (say) on each file using a command line with a regex input? I can do it on individual files with audacity or other GUI editor, but with many files it would be very tedious.

    I'd welcome suggestions, please.

    Jim

  2. #2
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Command line 'trimming' a sound file?

    There are a number of tools, though I would use ffmpeg.

    Code:
    ffmpeg -i input.mp3 -ss 30 -c copy output.mp3
    ## or (faster, but less accurate):
    ffmpeg -ss 30 -i input.mp3 -c copy output.mp3
    ## or (lossy re-encode, takes longer, but the most accurate splitting):
    ffmpeg -i input.mp3 -ss 30 -c libmp3lame -q:a 3 output.mp3
    avconv, which is in the repositories, uses the same options. This does require creating a separate file for the output - but you can always delete the original when you're done, and that's pretty trivial to work into a script.

    To do every mp3 file in a directory:

    Code:
    for f in *.mp3; do ffmpeg -i "$f" -ss 30 -c copy "trim-$f"; done
    ##  for recursiveness, use find:
    find . -type f -name "*.mp3" -exec ffmpeg -i '{}' -ss 30 -c copy trim-'{}' \;

  3. #3
    Join Date
    Jan 2008
    Beans
    69

    Re: Command line 'trimming' a sound file?

    Thanks a lot 'evilsoup' - it looks like just the thing I need. I'll be off now to give it a try.
    .
    .
    Yup - tried it and it worked a treat. (I used avconf because I got 'spooked' by the warning that ffmpeg is now deprecated!)

    Thanks again 'evilsoup'.
    Last edited by jimford; March 30th, 2013 at 03:25 PM.

  4. #4
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    8,587
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Command line 'trimming' a sound file?

    Don't forget sox, the swiss army knife of audio files.

    Code:
    sudo apt-get install sox
    man sox
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

  5. #5
    Join Date
    Dec 2006
    Beans
    7,111

    Re: Command line 'trimming' a sound file?

    Quote Originally Posted by jimford View Post
    (I used avconf because I got 'spooked' by the warning that ffmpeg is now deprecated!)
    FFmpeg is most definitely not deprecated, that misleading message is part of a nasty war between the avconv developers and the FFmpeg project.
    You think that's air you're breathing now?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •