Page 3 of 4

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 28th, 2008, 1:06 pm
by doubledrat
RXP wrote: Well I do, but with Sab's TV sorting option enabled it extracts it to a single folder. I guess I'll just manually add a category for ts files.

And it wasn't your fault, just glad I finally have a solution to joining ts files, been wanting one for like 2 years now!
I get SAB to put each episode in an episode sub directory.  I then move them up one when I've done whatever I need to do to them.  You could do that with

Code: Select all

copy /B "%dirname%\*.ts" "%dirname%\temp.newts" && del /q "%dirname%\*.ts" && move "%dirname%\temp.newts" "%dirname%\..\%name%.ts" 
which will work as long as you are not working at the root of a drive (as there is no higher directory!)

this should also work on a single .ts file, but is a bit wasteful as it will copy it, delete the original etc.

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 28th, 2008, 10:48 pm
by jl0810
doubledrat wrote: [

Code: Select all

 && del %%f
Ok - quick question then - this all works perfectly, but if I wanted to delete the entire directory, instead of just a single file, would this command work? : del "%dirname%"  or do I need to do something different?    I used your idea earlier around just writing the converted file directly to the proper converted directory, so now I just want to delete the entire directory that housed the source file (and other ancillary files)

thanks again

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 29th, 2008, 7:10 am
by doubledrat
almost  ;)

it's

Code: Select all

rmdir /s/q "%dirname%"

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 29th, 2008, 7:25 am
by pieteckhart
jl0810 wrote: This is a highly useful thread ;D

One quick comment/request - any way to add a simple command to delete the original file once ipod conversion is complete via ffmpeg?

Thanks in advance!
i use this:

Code: Select all

echo Removing Originals
del /S /Q *.avi
del /S /Q *.mkv
del /S /Q *.wmv

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 29th, 2008, 8:22 pm
by jl0810
I have one more question.  The script has taken me on a new journey.  Since I'm using it primarily for TV shows on Itunes (for the Iphone and Apple TV), I've decided that proper itunes tagging is also a requirement.  To address that requirement, I've integrated "atomicparsley" into the mix which allows for proper tagging of the  TV shows (by default Itunes files it as a movie)

Example:

Code: Select all

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
for /R "%dirname%" %%f in (*.avi) do HandBrakeCLI.exe -i "%%f" -o "C:\converted\%name%.m4v"  -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 && AtomicParsley "c:\converted\%name%.m4v" 
However I would love to be able to use attributes of the file or the folder to populate (a) the name of TV show (b) the season # and (c) the show # using atomicparsley - any ideas ?

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 30th, 2008, 7:23 am
by doubledrat
you're in luck - I'd like to do that too, so here's how I did it -

Code: Select all

set AtomicParsley="F:\Program Files\ipodvidconverter\Tools\AtomicParsley\AtomicParsley.exe" 

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%

CALL :tagTVshow "mp4 filename.mp4"

GOTO :EOF

:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"

REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%

REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
 

REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b

REM now tag the file with this information for iTunes
%AtomicParsley% %1 --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%


GOTO :EOF
you can therefore do this

Code: Select all

set AtomicParsley="F:\Program Files\ipodvidconverter\Tools\AtomicParsley\AtomicParsley.exe" 

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%


for /R "%dirname%" %%f in (*.avi) do HandBrakeCLI.exe -i "%%f" -o "C:\converted\%name%.m4v"  -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 && CALL :tagTVshow "c:\converted\%name%.m4v"

GOTO :EOF

:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"

REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%

REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
 

REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b

REM now tag the file with this information for iTunes
%AtomicParsley% %1 --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%


GOTO :EOF
obviously, I've just written this, so it's not had a large amount of testing yet!  buyer beware ;)

PS check out page 1 of this thread for a method to add the results to itunes for you too

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 30th, 2008, 1:56 pm
by jl0810
thanks - this is great-  what expectations does the code have for the file name, file structure and deliminators?    i.e. should I be setting sabnzbd to structure the TV show folder in any particular way?

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 30th, 2008, 3:35 pm
by doubledrat
it uses the nzb name, not the directory, isnt that a set format?

showname - seasxepisode - episode title

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 30th, 2008, 7:10 pm
by jl0810
Well - i think that's the newzbin set format.  Which is great except I don't have a login there and therefore I  just rely on other site to source my nzb via rss. However,  with the folder sorting options in sabnzbd I believe I can adjust either the file name or folder name to be the same as what you have (except my nzb feed doesnt give me episode name either - which isn't a big deal to me)

so in summary, the only difference is that I would need to (a) parse the file (or folder) name rather than the nzb (b) not use episode name (instead just use show name, season number, and episode number)

I was hopin that something as simple as this would work

Change this

Code: Select all

FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
to this

Code: Select all

FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%%f") DO set show="%%a"

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: December 31st, 2008, 5:30 am
by doubledrat
either you can force your filename, or using the directory name, you will need to split off %dirname% - you know the root of the directory, so you should be able to remove that with something like

Code: Select all

SET tvinfo=%dirname:c:\tvshows\=%
  that should remove the preceding directory information

then you need to break the remainder down on subdirectory delimeter \ e.g.

Code: Select all

FOR /F "TOKENS=1-3 DELIMS=\" %%a in ("%tvinfo%") DO set show="%%a"
  %%a is the first thing it finds.  %%b 2nd %%c third etc.  that should be enough for you to do what you want

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: January 17th, 2009, 12:16 pm
by relman
Thanks for this atomicparsley application, the script worked wonders. I have with the help of wget.exe (google it) managed to get it to also grab tv show artwork

Code: Select all

REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"

REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
SET m4vfile="D:\Share\Disk1\-=-iPhone-=-\tvshows\%name%.m4v"

call :ToLowCase

:ToLowCase
setlocal enableextensions
set var_=%show%
set var_=%var_:A=a%
set var_=%var_:B=b%
set var_=%var_:C=c%
set var_=%var_:D=d%
set var_=%var_:E=e%
set var_=%var_:F=f%
set var_=%var_:G=g%
set var_=%var_:H=h%
set var_=%var_:I=i%
set var_=%var_:J=j%
set var_=%var_:K=k%
set var_=%var_:L=l%
set var_=%var_:M=m%
set var_=%var_:N=n%
set var_=%var_:O=o%
set var_=%var_:P=p%
set var_=%var_:Q=q%
set var_=%var_:R=r%
set var_=%var_:S=s%
set var_=%var_:T=t%
set var_=%var_:U=u%
set var_=%var_:V=v%
set var_=%var_:W=w%
set var_=%var_:X=x%
set var_=%var_:Y=y%
set var_=%var_:Z=z%
set var_=%var_:=†%
set var_=%var_:Ž=„%
set var_=%var_:™=”%
set var_=%var_:"=%
set var_=%var_:!=%
set var_=%var_: =_%
endlocal & set shownocaps=%var_%



REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
 

REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b

REM now tag the file with this information for iTunes

Echo ## Episode = %value%
Echo ## Show = %show%
Echo ## Show No caps = %shownocaps%
Echo ## Season = %season%
Echo ## Episode = %episode%
Echo ## SeasonXEp = %seasXep%
Echo ## fileExt = %fileExt%
Echo ## Artwork = %artwork%



SET imagename=%shownocaps%-show.jpg
SET Artworkurl=http://sharetv.org/images/%shownocaps%-show.jpg
SET Imagepath=E:\temp\artwork\%shownocaps%-show.jpg
SET extravalue=--artwork %Imagepath%

IF EXIST "%imagepath%" GOTO Skipimagedownload

CD /d e:\temp\artwork\
e:\temp\artwork\wget.exe "%artworkurl%"

IF NOT EXIST "%imagepath%" SET extravalue=
Del need-%show%.jpg /q /f
IF EXIST soon.jpg ren soon.jpg need-%show%.jpg


:Skipimagedownload

Echo ##
Echo ## Now running Atomic Parsley
Echo ## Running d:\Atomic\AtomicParsley.exe %m4vfile% --overWrite --title "%value%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season% %extravalue%

d:\Atomic\AtomicParsley.exe %m4vfile% --overWrite --title "%value%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season% %extravalue%



Re: Automatic Media Conversion (Ipod / Iphone)

Posted: February 1st, 2009, 4:11 pm
by hodapp
pieteckhart wrote:

Code: Select all

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%

for /R "%dirname%" %%f in (*.avi) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
for /R "%dirname%" %%f in (*.mkv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
for /R "%dirname%" %%f in (*.wmv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
Works like a charm :D
i put ffmpeg.exe inside C:\Windows\System32\ so i can use from anywhere in my system :D
thanks for posting this!
I'm using this script and it works AWESOME... with one exception- any movie split in to two files. On a completed download, sabnzbd goes through the whole par2/unrar process, moves it to the completed directory, then begins encoding part_1.avi as nzb_name.mp4, then when the first file is completed it starts encoding part_2.avi as nzb_name.mp4 again. Naturally this is overwriting the original file, so all I'm left with is an encoded part_2.avi.

Ideally, I'd like it to combine part_1.avi and part_2.avi THEN encode them to nzb_name.mp4... but I'd settle for it just not overwriting the first encoded file.

Any help would be greatly appreciated, this thread has been remarkable so far.

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: March 14th, 2009, 12:51 pm
by Clay
These scripts are fantastic - is there a decent way to figure out naming for stuff like the Daily Show or Colbert Report where it's not sXXeXX?

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: April 21st, 2009, 4:37 pm
by bnb
I just got an iphone finally, and this thread has been great.  I am not very good with scripts, so its taken me hours of reading through this thread and I sort of understand it, but I am having a looping issue on the batch file I made.  Could someone take a look at mine for me?

Code: Select all

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%



for /R "%dirname%" %%f in (*.avi) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"
for /R "%dirname%" %%f in (*.mkv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"
for /R "%dirname%" %%f in (*.wmv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"




:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"

REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%

REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
 

REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b

REM now tag the file with this information for iTunes
%AtomicParsley% "g:\iphone tv\%name%.mp4" --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%

REM don't repeat the exercise
IF EXIST "g:\iphone tv\%name%.mp4" GOTO :EOF

call cscript "c:\program files\sabnzbd\scripts\itunesupdate.js" "g:\iphone tv"
curl.exe --get "http://192.168.1.103/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)"

GOTO :EOF
I just added in:
REM don't repeat the exercise
IF EXIST "g:\iphone tv\%name%.mp4" GOTO :EOF

But I obviously didn't do it right, b/c it is doing the same thing.
It loops at this part:

C:\Program Files\SABnzbd>curl.exe --get "http://192.168.1.103/xbmcCmds/xbmcHttp? ... ary(video)"
This version of C:\Program Files\SABnzbd\curl.exe is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.

C:\Program Files\SABnzbd>GOTO :EOF

C:\Program Files\SABnzbd>ffmpeg.exe -y -i "g:\tv\South Park\Season 13\South Park - S13E05 - Fishsticks.avi" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\South Park - 13x04 - Eat, Pray, Queef.mp4"  && CALL :tagTVshow "g:\iphone tv\South Park - 13x04 - Eat, Pray, Queef.mp4"
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-memalign-hack --enable-postproc --enable-swscale --enable-gpl --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libxvid --enable-libx264 --disable-ffserver --disable-ffplay --enable-avisynth --enable-libdirac --enable-libschroedinger --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-libspeex --enable-libopenjpeg --enable-small --disable-decoder=aac --extra-cflags=-mtune=generic -fno-common -I/usr/local/include --extra-ldflags=-L/usr/local/lib
  libavutil    49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat  52.31. 0 / 52.31. 0
  libavdevice  52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale    0. 7. 1 /  0. 7. 1
  libpostproc  51. 2. 0 / 51. 2. 0
  built on Mar 13 2009 23:50:16, gcc: 4.3.3


And starts ffmpeg again.  It probably has something to do with the GOTO :EOF commands, but I'm not sure how to implement those.
Here is the output:
http://pastebin.com/m4f69a59a
Thanks again.

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: April 22nd, 2009, 3:32 pm
by Clay
Here's what I'm using to convert my Daily Show / Colbert Report stuff.

It expects a format like this: "The Colbert Report - 2009-04-21 - Coach Mike Kryzewski"

It will convert and tag a file, and you can use one of the add-to-itunes script found in this thread to actually add it to your library.

Code: Select all

@ECHO OFF
set AtomicParsley=%PROGRAMFILES%\AtomicParsley\AtomicParsley.exe
set targetDir=D:\iTunesMedia\TV Shows
set handbrake=%PROGRAMFILES%\HandBrake\HandBrakeCLI.exe
set name=%3

SET name=%name:" =%
SET name=%name: "=%
SET name=%name:"=%

set dirname=%1
set dirname=%dirname:"=%

echo Directory: %name%
echo Name: %name%

set file=%targetDir%\%name%.m4v

echo Output File: %file%

rem for /R "%dirname%" %%f in (*.avi) do "%handbrake%" -i "\\%%f" -o "%file%" -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1

for /R "%dirname%" %%f in (*.avi) do "%handbrake%" -i "\\%%f" -o "%file%" --preset="iPhone & iPod Touch" -v 0

FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set year="%%b"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set month="%%c"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set day="%%d"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set guest="%%e"

SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%

SET year=%year:" =%
SET year=%year: "=%
SET year=%year:"=%

SET month=%month:" =%
SET month=%month: "=%
SET month=%month:"=%

SET day=%day:" =%
SET day=%day: "=%
SET day=%day:"=%

SET guest=%guest:" =%
SET guest=%guest: "=%
SET guest=%guest:"=%

set title=%year%-%month%-%day%

echo Show: %show%
echo Title: %title%

"%AtomicParsley%" "%file%" --genre "TV Show" --stik "TV Show" --TVShowName "%show%" --title %title% --description "%guest%" --overWrite