Combing Multiple AVI Movies

Come up with a useful post-processing script? Share it here!
Post Reply
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Combing Multiple AVI Movies

Post by markus101 »

I found a script on these forums from Rascalli, I modified it to add WMV moving as well as renaming movies and combining 2-CD movie releases.

The original script is here: http://forums.sabnzbd.org/index.php?topic=61.0

Here s my update version, it could be better edited (removing the if category == Movie), but it works and works well, so it stays for now at least.

Here is my version of the script: http://pastebin.com/f4d8b33ee

Its using mencoder, which comes with mplayer. I'm using a very small version of Slackware 12.1 that has been designed specifically for NAS Storage, it goes by the name of unRAID, available at http://www.lime-technology.com. It basically does RAID 5, but you can add disks, increase disk sizes 1 by 1, with the only restriction being that the parity drive has to be the largest drive in the system (other data drives can be the same size, just not bigger) - Okay enough on unRAID.

Specially for unRAID I needed the following packages (many are for X, which isn't installed in unRAID):

ffmpeg-20081102-i486-1gds.tgz
mplayer-1.0rc2try4-i486-1kjz.tgz
twolame-0.3.12-i486-1kjz.tgz
faac-1.26-i486-1gds.tgz
x264-20081031-i486-1gds.tgz
xvidcore-1.1.3-i486-3gds.tgz
lame-3.98.2-i486-1kjz.tgz
libpng-1.2.27-i486-1.tgz
libjpeg-6b-i486-5.tgz
libungif-4.1.4-i486-4.tgz
alsa-lib-1.0.15-i486-1.tgz
cdparanoia-III10pre0-i486-1.tgz
freetype-2.3.5-i486-1.tgz
fontconfig-2.4.2-i486-2.tgz
lzo-2.02-i486-1.tgz
libmad-0.15.1b-i486-3.tgz
speex-1.2rc1-i486-2kjz.tgz
libtheora-1.0beta2-i486-1.tgz
libogg-1.1.3-i486-2.tgz
libmpcdec-1.2.6-i486-2gds.tgz
faad2-2.6.1-i486-2gds.tgz
a52dec-0.7.4-i486-2gds.tgz
libvorbis-1.2.0-i486-1.tgz
libdv-1.0.0-i486-2gds.tgz
libX11-1.1.1-i486-4.tgz
libxcb-1.0-i486-2.tgz
libXau-1.0.3-i486-1.tgz
libXdmcp-1.0.2-i486-1.tgz
ibdc1394-2.0.2-i486-1gds.tgz
libXext-1.0.4-i486-1.tgz
libraw1394-2.0.0-i486-1gds.tgz

The first two are ffmpeg and mplayer (which has mencoder), followed by some codecs and then a bunch of other required files, and a few more codecs, full blown systems will likely have most of the required files, so it may be less installing for you.

To Install packages use the following, repeat for each package:
installpkg ffmpeg-20081102-i486-1gds.tgz
installpkg mplayer-1.0rc2try4-i486-1kjz.tgz

I also needed to symlink some files as some of the packages I downloaded had new versions and complained I was missing them, this is what I had to symlink:

Code: Select all

ln -s /usr/lib/libx264.so.65 /usr/lib/libx264.so.59
ln -s /usr/lib/libx264.so.65 /usr/lib/libx264.so.54
ln -s /usr/lib/libavformat.so.52 /usr/lib/libavformat.so.51
ln -s /usr/lib/libavcodec.so.52 /usr/lib/libavcodec.so.51 
Hopefully the above gets you started, if not all the way completed with mplayer/ffmpeg.
If you just want to do one off combining with mencoder, this is all you need is the following line:

Code: Select all

mencoder -forceidx -ovc copy -oac copy -o /mnt/user/completed/output.avi /mnt/user/completed/input1.avi /mnt/user/completed/input2.avi
To get the packages for unRAID (Slackware 12.1) I used the following sites: http://www.linuxpackages.net, http://packages.slackware.it and finally http://slackware-current.net

My next plan was to get a script working for remuxing mkv files into mp4 files playable on the 360...so far It hasn't worked on unRAID, something with mplayer is fishy, it runs with no arguments without a complaint, but when I try running it to tell which source is video or audio it bombs and outputs all the lib files in /usr/lib - maybe one day I'll figure that out.

Once thing I notice is that the 360 reports the length of the movies wrong when I combine the AVI's, not a big deal for me, but I guess it could be a show stopper for some.

Enjoy you single file AVI's for those tough to find 1-CD releases.

-Markus

EDIT: Added how to install packages
Last edited by markus101 on February 4th, 2009, 11:45 am, edited 1 time in total.
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
pinion
Newbie
Newbie
Posts: 17
Joined: January 26th, 2009, 2:21 am

Re: Combing Multiple AVI Movies

Post by pinion »

That's awesome!  Thanks.  Some of the packages weren't available under FreeBSD, at least not in the standard place.  I think I got what's important to start the conversion though.  It puts a log file with the name of the movie with these contents

Code: Select all

nice: /root/sabscripts/joindiscs.py: Permission denied
  I made sure that I told SABnzbd to chmod the files to 775 afterward. When I try to just run the script it says

Code: Select all

  File "/root/sabscripts/joindiscs.py", line 5
    CATEGORY_NAME=`echo $1 | awk -F [/] '{print $(NF-1)}'`
                        ^
SyntaxError: invalid syntax
  Which I'm sure has something to do with the script not being able to be run like that.  Is there a way I can run the script on the files after they've been downloaded so I know if it gets going correctly or not?  And now I'm not even sure mencoder is installed because I can't run it but mplayer is definitely there.
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Combing Multiple AVI Movies

Post by markus101 »

It's actually a BASH Shell script, I see you're running a python file (though it looks like you're not actually running python on it)... Shouldn't be an issue.

I run the following to run it for testing.

Code: Select all

/boot/SABnzbd/scripts/movies.sh "/mnt/user/Movies/This Movie" msgid_testing
Where "This Movie" is a folder that has the two AVI files for combing.
The msgid_testing isn't needed with in the script, but you need two arguments, which I believe was used for renaming based on Newzbin names - I guess I could just pull it, whoops.

Looks like you would run:

Code: Select all

/root/sabscripts/joindiscs.py "/path/to/movie/This Movie" msgid_testing
You should just be able to type

Code: Select all

mencoder
at a shell prompt and get a similar error message to this one:

Code: Select all

No file given

Exiting... (error parsing command line)
The $1 is the first command line parameter given to the script (usually comes from SAB), which is the full path to the Movie...
http://sabnzbd.wikidot.com/user-scripts - Shows the other command line parameters that SAB passes to Post-processing scripts.

Hope this helps a bit.

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Combing Multiple AVI Movies

Post by markus101 »

Okay, got a bit fed up with garbage organization in the script and having to change the log file location in 20 different locations...anyways, here is an updated script, nothing functionally has changed, except now it only looks for $1 as it was the only one being used.

http://pastebin.com/f69161ee2

Log output should be a bit cleaner, as should the editing of variables... Enjoy.

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Combing Multiple AVI Movies

Post by markus101 »

Added some more logic, mostly for cases where there was no avi files found and it renamed the folder to Movie Name.avi, which just won't do.

http://pastebin.com/f14e1839b

Enjoy,

Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
Post Reply