Encoding video using Handbrake on x86 NAS

Share your own product reviews, suggestions, and tips and tricks of using QNAP products. Show off your products.

Re: Encoding video using Handbrake on x86 NAS

Postby marquis » Sat Jun 11, 2011 5:52 pm

Thank you for your notification. I had some trouble with dropbox and forgot to restore this file. It's working again, now.
marquis
Starting out
 
Posts: 32
Joined: Fri Jun 25, 2010 10:09 pm
NAS Model: TS-239 Pro II

Re: Encoding video using Handbrake on x86 NAS

Postby ovcrash » Fri Sep 02, 2011 6:50 am

marquis wrote:OK, it's me again :)

I managed to compile the latest version from handbrake in a virtual machine and it's working now with the export of the $TMPDIR variable. So my /tmp is no longer filled and now I can convert my DVDs 8)

For those of you who would like to upgrade you can find my version here: http://dl.dropbox.com/u/19006011/handbrakecli-0.9.5-rev3980.7z

Enjoy
M.


I downloaded the file, but i can't seem to do anything with it.
How do i install this file on my QNAP ? Any help would be appreciated.

After i unzip de 7z file, i can't seem to untar the file.

Thanks.
ovcrash
New here
 
Posts: 3
Joined: Tue Jul 05, 2011 7:36 am
NAS Model: TS-119P+

Re: Encoding video using Handbrake on x86 NAS

Postby marquis » Wed Oct 26, 2011 11:00 pm

Hi ovcrash,

the file inside the 7z archive is already the final binary. You can copy it to any location you like and call it from there, e.g. ./HandBrakeCLI --help

Regards,
M.
marquis
Starting out
 
Posts: 32
Joined: Fri Jun 25, 2010 10:09 pm
NAS Model: TS-239 Pro II

Re: Encoding video using Handbrake on x86 NAS

Postby psynoz » Sun Nov 20, 2011 2:43 am

I wish someone would do a QPKG with configurable .conf, where you would specify source & dest dir's and something regarding scheduling ;)
psynoz
Starting out
 
Posts: 12
Joined: Fri Mar 12, 2010 1:51 am
NAS Model: TS-509 Pro

Re: Encoding video using Handbrake on x86 NAS

Postby marquis » Tue Nov 22, 2011 9:04 pm

I don't know how to make a QPKG, but I have written a script that is automatically converting my DVDs or BDs in the background. All I have to do is copying the source DVD or BD into a specific directory. The script is started by cron once a day to check for something to convert.

Code: Select all
#!/bin/sh

function config ()
{
  echo "Setting environment"
  # Working directories
  ENCDIR=/share/HDC_DATA/Multimedia/DVD # Source Path to scan for DVDs
  DSTDIR=/share/HDC_DATA/Multimedia/Video # Destination Path to copy encoded files
  DVDBACKUPDIR=/share/Backup/DVD # Destination Path for a Backup of the original DVD
  TEMPD=/share/HDD_DATA/tmp # Destination folder for temp files ** DO NOT SET TO RAM DRIVE **

  # Command line for converting a DVD and BD
  DVD="/opt/bin/nice --adjustment=15 /share/scripts/sbin/handbrake -i ./VIDEO_TS -o $FILENAME --main-feature --markers --large-file --encoder x264 --vb 2500 --two-pass --turbo --aencoder ac3 --drc 2.0 --deinterlace slow --decomb 1:2:6:9:80:16:16 --subtitle scan --native-language deu --native-dub --subtitle-burn --subtitle-forced -x ref=3:mixed-refs:bframes=6:weightb:direct=auto:me=umh:subme=9:analyse=all:8x8dct:trellis=1:no-fast-pskip:psy-rd=1,1"
  BD="/opt/bin/nice --adjustment=15 /share/scripts/sbin/handbrake -i . -o $FILENAME --main-feature --markers --large-file --subtitle scan --native-language deu --native-dub --subtitle-burn --subtitle-forced --encoder x264 -E ac3 -q 20 -v"

  Process_Time_Stamp=`date +"%s"`
  AppName="dvdripper" # token to identify the script in the list of running processes
  Temp_File="$TEMPD/$Process_Time_Stamp"
}

function check_startconditions ()
{
  ### Check if this script is already working. Cancel if another conversion is detected.
  i=$(ps ax | grep "$AppName" | grep -v "grep" | wc -l)
  if [ $i -gt 2 ]; then
    echo "A conversion is already in progress. Please wait until it's finished and try again." | tee $Temp_File.error
   exit 0
  fi
  # Start logfile
  echo "----- Start log -----" | tee $Temp_File.log
}

function start ()
{
  # Look for DVDs
  # Read directorys on 1st level
  find $ENCDIR -maxdepth 1 -type d -name "*" | while read DIR
  do
    if [ "$DIR" != "$ENCDIR" ]
    then
      if [ -d "$DIR"/VIDEO_TS ]
      then
        echo "$DIR: DVD gefunden" | tee $Temp_File.log
         FILENAME=`echo $DIR.mkv | sed -e "s/\ /_/g"`
      COMMAND="$DVD"
       encode $DIR
     fi
      if [ -d "$DIR"/BDMV ]
      then
        echo "$DIR: BDMV gefunden" | tee $Temp_File.log
      FILENAME=`echo $DIR.mkv | sed -e "s/\ /_/g"`
      COMMAND="$BD"
       encode $DIR
     fi
   fi
  done
}

function encode ()
{
  echo "Input............: $DIR" | tee $Temp_File.log
  echo "Output...........: $FILENAME" | tee $Temp_File.log
  echo "Final destination: $DSTDIR" | tee $Temp_File.log
  echo
  cd "$DIR"

  let i=10
  while [ $i -gt 0 ]
  do
    echo -en "\r\033[KStart conversion in $i seconds"
    sleep 1
   let i=i-1
  done
  echo

  export TMPDIR=$TEMPD
 
  echo "Encoding begins now"  | tee $Temp_File.log
  Result=`$COMMAND`
 
  if [ -f $FILENAME ]
  then
    echo "$FILENAME wurde erfolgreich erzeugt" | tee $Temp_File.log
   mv $FILENAME $DSTDIR/
   echo "$FILENAME moved to $DSTDIR" | tee $Temp_File.log
    mv "$DIR" $DVDBACKUPDIR/
   echo "$DIR moved to $DVDBACKUPDIR" -m  | tee $Temp_File.log
  else
    echo "$FILENAME not found. Something strange happened on the way..." | tee $Temp_File.log
  fi
}

clear
config
check_startconditions $*
start $*
rm "${Temp_File}*"


To adjust the script for your needs all you have to do is editing the variables in the config-function. The script does the following:

1. It looks for directories in the ENCDIR and finds out whether it's a DVD or BD. So create a directory with the name of the movie and copy all the files and directories from the original DVD in that directory.
2. Then it starts the proper command (defined in DVD or BD variables). Here you need to adjust the path where the handbrake binary is saved on your system and maybe some parameters up to your choice.
3. After the conversion is finished, the file is copied to the DSTDIR which is normally your standard directory for your movies.
4. The source directory is copied to the DVDBACKUPDIR. Reason: if the conversation goes wrong you have a copy of the source files and you can do a manual conversation directly from that directory if required. You should delete it, after you checked the converted movie file. To move the directory is mandatory, because otherwise during the next cycle the same DVD would be converted.
5. HandBrake is generating huge temporary files. Therefore you must define a directory on your hard drive for the TEMPD.
6. the script is looking for other running conversations. This is done by checking the list of running proccesses. The AppName variable is used to identify other conversations. This should be the same name as the name of the script on your harddrive.
7. A log file is created where you can look-up the current status.

I have to say that I am not a Linux Pro and not a programmer. The script is working for me and should work for you, but you use it at your own risk.

If you have any recommendations how to improve the script, I would appreciate if you share it with us.

Kind regards,
M.
marquis
Starting out
 
Posts: 32
Joined: Fri Jun 25, 2010 10:09 pm
NAS Model: TS-239 Pro II

Re: Encoding video using Handbrake on x86 NAS

Postby TheWarden » Wed Jun 06, 2012 9:22 pm

I don't suppose someone with the right devel environment setup can compile a QNAP x86 version of HandBrakeCLI 0.9.6?

http://handbrake.fr/index.php?article=13
TheWarden
Starting out
 
Posts: 18
Joined: Wed Jan 12, 2011 11:41 pm
NAS Model: TS-419U

Re: Encoding video using Handbrake on x86 NAS

Postby inter1908 » Thu Dec 06, 2012 5:07 am

Hi,
I can install handbrake on my QNAP TS 219 PII for convert file .ts in MPEG4 without loss the quality?
what's the procedure for install it?
Thanks
inter1908
Starting out
 
Posts: 16
Joined: Thu Aug 23, 2012 5:59 pm
NAS Model: TS-119P+

Previous

Return to Users' Corner

Who is online

Users browsing this forum: No registered users and 2 guests