Page 4 of 4

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: May 18th, 2009, 11:41 am
by doubledrat
bnb wrote: 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.
your fix didn't work because the FFMPEG is done on all files in the directory BEFORE it does the tagging.  doing something like this should work though

Code: Select all

for /R "%dirname%" %%f in (*.avi) do call :mpegit "%%f"
.
.
.
GOTO :EOF

:mpegit
ffmpeg.exe -y -i %1 -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"
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"
.
.

to better fix the problem, a check to see if the file exists and then adjusting the filename to append a numeric would be neater but I don't have time to show you that.  Just bailing out as you've tried should now work.

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: May 19th, 2009, 5:52 pm
by forrestgump
Cool work! I got it working with slight adjustments.

However, ultimately it would be nice that it fetches metadata automatically from the web from various resources.
There's a java API/CLI program which allows you to do that! it's called tv-and-movies-meta-data-fetcher
What it basically does. It retrieves metadata such as authors, title, description etc from various web resources such as tv.com. That kind of information can in turn be used to tag with Atomic Parsley!

Killer combination FFMPEG + TV-AND-MOVIES-META-DATA-FETCHER  + ATOMIC PARSLEY

I have little programming experience. I had an ICT background but shifted to business study... Perhaps anyone else dares to take the challenge?

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: November 4th, 2009, 12:28 am
by substyle
Sorry to dig this thread up again, just was hoping someone could give me an easy fix to a problem I'm having. I think it should be easy anyway...

I have my sabnzbd tv sorting to sort this way:

Series Name/Season #/## - Episode Name

## is the episode number, so 4x05 would be Series/Season 4/05 - Name.avi

sabnzbd sorts the episodes just fine this way, but the converted file is still named the default newzbin standard. What do I need to add to get the file named the way I want?

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: November 4th, 2009, 7:14 am
by doubledrat
substyle wrote: Sorry to dig this thread up again, just was hoping someone could give me an easy fix to a problem I'm having. I think it should be easy anyway...

I have my sabnzbd tv sorting to sort this way:

Series Name/Season #/## - Episode Name

## is the episode number, so 4x05 would be Series/Season 4/05 - Name.avi

sabnzbd sorts the episodes just fine this way, but the converted file is still named the default newzbin standard. What do I need to add to get the file named the way I want?
depends on what you want to call it.  A postproc job which will rename any .avi, ,mkv etc files to be the same as the download name is very easy as the download name is passed as a parameter to the PP job.

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: November 4th, 2009, 12:02 pm
by substyle
really? i am a little confused I guess...

here is what I have put together from this thread:

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"

echo Removing Originals
cd\iphone
del /S /Q *.avi
del /S /Q *.mkv
del /S /Q *.wmv
I want the episodes renamed to ## - Episode Name (ie no 4x05 stuff, just "05 - Episode Name.mp4")
the code I have is still naming the converted episode "Series Name - 4x05 - Episode Name.mp4" - so I think the name parameter is still set to what newzbin had the report named as, not what my tv sorting sabnzbd settings are. I'm guessing I need to have something that manually strips out the series name, season # and all of that other good stuff, I'm just not sure how to do that and afraid that it could cause problems with legit episodes (such as a number in the episode name?). There has to be an easy way to do it

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: November 4th, 2009, 1:21 pm
by doubledrat
to split out the component parts you could do

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:"=%

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

then you want the episode and eptitle as your name, so instead of

Code: Select all

"%dirname%\%name%.mp4"
use

Code: Select all

"%dirname%\%episode% - %eptitle%.mp4"

Re: Automatic Media Conversion (Ipod / Iphone)

Posted: November 4th, 2009, 2:41 pm
by substyle
that did exactly what I wanted. thank you.