Results 1 to 6 of 6

Thread: Handbrake Script

  1. #1
    Join Date
    Sep 2008
    Beans
    18
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Smile Handbrake Script

    Hi All,

    Scripting after some time now... I've recently started watching videos on my iPhone and have come to the realization that theres no really easy way (I mean mostly automatic) of ripping files. I tried Artista Transcoder and Handbrake. They're both good programs but I've got more experience with handbrake so i wrote a little right-click script for nautilus which rips videos into whatever format you want based on the presets.

    to install handbrake from the ppa: (only works for 9.10 & 10.04 check the ppa for a how to on installing in earlier versions)
    Code:
    sudo add-apt-repository ppa:handbrake-ubuntu/ppa && sudo apt-get update && sudo apt-get install handbrake-cli

    Copy the following code into a file and place it into ~/.gnome2/nautilus-scripts folder

    Code:
    #!/bin/bash
    # Right-click video ripper for HandBrakeCLI
    # Owner: 
    #   Anand Kapre
    #   ak@anandkapre.com
    # Licence: GNU GPL
    # Copyright (C) Anand Kapre
    # Dependency:
    #   HandBrakeCLI
    # Created on Tuesday May 4th 2010
    # Tested on Ubuntu 9.04 Jaunty Jackalope, 10.04 Lucid Lynx
    
    # Uncomment the preset of your choice below
    #ripto="Universal"
    #ripto="iPod"
    #ripto="AppleTV"
    #ripto="Normal"
    #ripto="High Profile"
    #ripto="Classic"
    #ripto="AppleTV Legacy"
    #ripto="iPhone Legacy"
    #ripto="iPod Legacy"
    ripto="iPhone & iPod Touch"
    
    folder=$(pwd)
    for arg in "$@"
    do
    pid=$(pidof HandBrakeCLI)
    if [ $pid -gt 0 ] ;
    then
      sleep 5
    else
    gnome-terminal --geometry=75x10 -x HandBrakeCLI --preset "$ripto" -i $folder/"$arg" -o $folder/"$arg".mp4 && sleep 5
    fi
    done
    hope this helps someone...enjoy
    Last edited by darthrax; May 6th, 2010 at 12:32 AM.

  2. #2

    Re: Handbrake Script

    Moved to Multimedia and Video.
    Ubuntu user #7247 :: Linux user #409907
    inconsolation.wordpress.com

  3. #3
    Join Date
    Sep 2006
    Location
    Silicon Valley, CA, USA
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Handbrake Script

    FYI this doesn't work if there are spaces in the path.

    editing: $folder/"$arg" to "$folder"/"$arg" did the trick
    Cordially,
    Jeff Moorse

  4. #4
    Join Date
    Nov 2007
    Beans
    134
    Distro
    Ubuntu 19.04 Disco Dingo

    Re: Handbrake Script

    If you have zenity installed, you can try

    Code:
    ripto=$(zenity  --list  --text "Choose the format to rip to .." --radiolist  --column "Pick" --column "Opinion" TRUE Universal FALSE iPod FALSE AppleTV FALSE Normal FALSE "High Profile" FALSE "Classic" FALSE "AppleTV Legacy" FALSE "iPhone Legacy" FALSE "iPod Legacy" FALSE "iPhone & iPod Touch");
    to give you a nice selection dialog.

    If you want zenity, it's in the repository
    Code:
    sudo apt-get install zenity
    "How did it get so late so soon"
    To the world you may be one person, but to one person you may be the world.

  5. #5
    Join Date
    Sep 2010
    Beans
    2

    Re: Handbrake Script

    Hi thanks a lot for the script!

    little hack for subtitile :

    Code:
    # subtitle
    file_name=$arg
    file_title=`echo $file_name|sed 's/\..\{3\}$//'`
    
    if [ -e ${file_title}.srt ]
    then
    gnome-terminal --geometry=75x10 -x HandBrakeCLI --preset "$ripto" -i $folder/"$arg" -o $folder/"$file_title".mp4 -srt-file ${file_title}.srt --srt-lang fra && sleep 5
    else
    gnome-terminal --geometry=75x10 -x HandBrakeCLI --preset "$ripto" -i $folder/"$arg" -o $folder/"$file_title".mp4 && sleep 5
    fi
    I've add $file_title var to strip out .avi at the end of the ouput (movie.mp4 instead of movie.avi.mp4)
    Last edited by iceman2k3; September 16th, 2010 at 10:37 PM. Reason: little fix + code

  6. #6
    Join Date
    Sep 2007
    Location
    USA
    Beans
    331
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Handbrake Script

    How can this be modified to allow for batch processing? I've got a folder of videos that I'd like converted.

Tags for this Thread

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
  •