Jump to content

batch convert fanart to thumb


Swynol

Recommended Posts

FrostByte

What is the long alpha/num thing after the title?

 

A lot of my text ones work now that didn't before, thanks :)  Still needs some tweaking on others like you mentioned.

Edited by FrostByte
Link to comment
Share on other sites

Happy2Play

What is the long alpha/num thing after the title?

I believe it is the movie id to distinguish between same name movies I reported.

  • Like 1
Link to comment
Share on other sites

chef

What is the long alpha/num thing after the title?

 

A lot of my text ones work now that didn't before, thanks :) Still needs some tweaking on others like you mentioned.

 

It was complicated, you have to split the title into parts and then count the letters in each part to make sure they don't run off the thumb. Then wrap the parts accordingly. Lol!

  • Like 1
Link to comment
Share on other sites

FrostByte

Well, I appreciate your effort.  Even if you can't fix it all there are a bunch it did.  I can only find 2 text ones that don't fit right now

 

55d46d6e193bc_thumb.jpg

  • Like 1
Link to comment
Share on other sites

chef

Well, I appreciate your effort. Even if you can't fix it all there are a bunch it did. I can only find 2 text ones that don't fit right now

 

55d46d6e193bc_thumb.jpg

I'll wrap the fourth word if it exceeds the spacing limit. That'll fix it up.

Link to comment
Share on other sites

Happy2Play

Looks like a little more adjusting.

 

55d7d13bc26f4_text.jpg

 

Really long name :D

Assault at West Point, The Court-Martial of Johnson Whittaker

55d7d1aa9c8eb_long.jpg

Edited by Happy2Play
  • Like 1
Link to comment
Share on other sites

FrostByte

For the two I'm having issues with (2 pics in #105/107) it fixed the space between the words on the one (space after Christmas), but neither one wraps that last word still.  Very close :)

 

Edit: new pics

 

55d7d2f5737c9_thumb.jpg

 

55d7d308bc0bb_Untitled.jpg

 

Edited by FrostByte
  • Like 1
Link to comment
Share on other sites

chef

I think is aligns the text better. It also takes into consideration the "-" in media titles so it can be broken down into manageable string sizes.

 

The only thing I can see happening now, is that the title is so long, that it would run off the bottom of the thumb image, but at least it won't run off the right side.

 

If it does run off the bottom, then it'll have to be coded to move the title up if the lines exceed the bottom. <-- this is going to happen I already know it...

 

https://dl.dropboxusercontent.com/u/46151346/Thumb%20Maker.zip

Edited by chef
  • Like 2
Link to comment
Share on other sites

FrostByte

Well...I think that made it worse in some cases. :)  It seems like it is returning after almost every word now except real small words (the, it's, is, etc).  Movies that use to fit no longer do.  All of them did a return line in places it didn't need to.  A lot more movies run off now because they are too big.

 

55d9d1ec9b835_1.jpg

 

55d9d2160bccd_2.jpg

 

55d9d232b9a80_3.jpg

Link to comment
Share on other sites

chef

Damn! That was unexpected. Back to the drawing board. I am learning to hate graphic text. Lol!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

That sounds great! In most cases that is what this does. The text was only added if a logo wasn't present.

 

One thing we realized while developing this app wa that movies and tv series have different size ratios. The tv series thumbs were smaller.

 

Also somewhere mentions In This thread by ebr is a calculation to keep aspect ratios whilst shrinking the size of logos to position them on the backdrop. Might be useful.

 

Try this app and see if it is something you are interested in. Any input Into functionality is welcome.

Link to comment
Share on other sites

  • 1 month later...

Hi I'm having a few issues with this app.  It seems to work fine for Moves, but it wont save the image for collections.  It fines the collection and lists it, lets me "show thumb" but when I click save nothing, no error, no image...  Are there some setting I need to change to make this happen?  Also, I think I read on a previous post that this can batch run through all the images, but I can't seem to find the any option for this.  Is the app suppose to be installed in emby or just stand a lone?  Can I some how use the scheduler in emby to call this app?  Any help would be appreciated.  

Link to comment
Share on other sites

Nologic

@ chef

 

I'd personally attack this from a different perspective...well tools.

 

I'd use subtitles for the text...namely ASS...since it's text based and can be fairly well stylized.

 

I'd then use FFMpeg to load the ASS file as an overlay...then render the image.

 

I'd do much the same thing with clear art & logo's.

 

Here is some code snippits from one of my app's...granted it's written in AutoIt...but you should be able to read and understand it.


Func _FFWaterMark( $iWidth , $iHeight , $iResolution , $sWaterMark , $sLocation , $sVideoFilter )
	Local $sSomeRandomString , $sContent , $fFactor
	Local $iWaterMarkWidth , $iWaterMarkHeigh , $iWaterMarkX , $iWaterMarkY

	$iWidth  = Int( $iWidth  )
	$iHeight = Int( $iHeight )
	$sSomeRandomString = _RandomString()
	RunWait( @ComSpec & ' /c ffprobe.exe -show_streams "' & $sWaterMark & '" >"' & $sTempFolder & $sSomeRandomString & '.txt"' , @ScriptDir & '\BIN\FFMpeg\' , @SW_HIDE )
	$sContent = FileRead( $sTempFolder & $sSomeRandomString & '.txt' )
	FileDelete( $sTempFolder & $sSomeRandomString & '.txt' )
	$iResolution = Int( $iResolution )
	$fFactor = $iHeight / $iResolution
	$iWaterMarkWidth  = Int( _RegExString( $sContent , '(?s)(?i)(?:.+?width=(\S+))?'  ) * $fFactor )
	$iWaterMarkHeight = Int( _RegExString( $sContent , '(?s)(?i)(?:.+?height=(\S+))?' ) * $fFactor )
	Switch $sLocation
		Case 'Top Left'
			$iWaterMarkX = 0
			$iWaterMarkY = 0

		Case 'Top Center'
			$iWaterMarkX = Int(( $iWidth - $iWaterMarkWidth ) / 2 )
			$iWaterMarkY = 0

		Case 'Top Right'
			$iWaterMarkX = Int( $iWidth - $iWaterMarkWidth )
			$iWaterMarkY = 0

		Case 'Center Left'
			$iWaterMarkX = 0
			$iWaterMarkY = Int(( $iHeight - $iWaterMarkHeight ) / 2 )

		Case 'Center'
			$iWaterMarkX = Int(( $iWidth  - $iWaterMarkWidth  ) / 2 )
			$iWaterMarkY = Int(( $iHeight - $iWaterMarkHeight ) / 2 )

		Case 'Center Right'
			$iWaterMarkX = Int(  $iWidth  - $iWaterMarkWidth  )
			$iWaterMarkY = Int(( $iHeight - $iWaterMarkHeight ) / 2 )

		Case 'Bottom Left'
			$iWaterMarkX = 0
			$iWaterMarkY = Int( $iHeight - $iWaterMarkHeight )

		Case 'Bottom Center'
			$iWaterMarkX = Int(( $iWidth  - $iWaterMarkWidth  ) / 2 )
			$iWaterMarkY = Int(  $iHeight - $iWaterMarkHeight )

		Case 'Bottom Right'
			$iWaterMarkX = Int( $iWidth  - $iWaterMarkWidth  )
			$iWaterMarkY = Int( $iHeight - $iWaterMarkHeight )
	EndSwitch
	If $sVideoFilter = '' Then
		Return ' -vf "' & "movie='" & _FFPathing( $sWaterMark ) & "', scale=" & $iWaterMarkWidth & ':' & $iWaterMarkHeight & '[WaterMark];[In][WaterMark]overlay=' & $iWaterMarkX & ':' & $iWaterMarkY & '[Out]"'
	Else
		Return StringTrimRight( $sVideoFilter , 1 ) & "[Movie];movie='" & _FFPathing( $sWaterMark ) & "', scale=" & $iWaterMarkWidth & ':' & $iWaterMarkHeight & '[WaterMark];[Movie][WaterMark]overlay=' & $iWaterMarkX & ':' & $iWaterMarkY & '[Out]"'
	EndIf
EndFunc

Func _FFSubtitle( $sSubTitle , $sVideoFilter )
	If StringInStr( $sVideoFilter , '[Out]' ) Then
		Return StringReplace( $sVideoFilter , '[Out]' , "[Overlay];[Overlay]ass='" & _FFPathing( $sSubTitle ) & "'[Out]" )
	Else
		Return StringTrimRight( $sVideoFilter , 1 ) & ", ass='" & _FFPathing( $sSubTitle ) & "'" & '"'
	EndIf
EndFunc

Here is a very dumbed down example of doing overlays with images...notice I'm not scaling the watermark to properly fit...nor setting a good location. More importantly pathing in the filter...back slashes must be turned into forward slashes, and colons must be escaped with a backslash.

ffmpeg -i "W:\TV Shows\2 Broke Girls (2011)\fanart.jpg" -vf "movie='W\:/TV Shows/2 Broke Girls (2011)/logo.png'[WaterMark];[In][WaterMark]overlay=0:0[Out]" test.png

You might also want to check into the code here...again it's AutoIt...and it's meant for GUI's rather than Images...but maybe you can gleam some useful info out of it all the same.

 

Also to get a better handle on subtitles you may wish to look at Subtitle Edit & Aegisub.

 

To bad Emby don't have a way of injecting ASS effects...as it could liven up subtitles a lot. Provided some fairly tame ones could be found.

 

This one is certainly out of hand for movies, but fun for karaoke.

https://www.youtube.com/watch?v=NIARCZVTmKM

https://www.youtube.com/watch?v=dZgx8vPKtQQ

Edited by Nologic
  • Like 1
Link to comment
Share on other sites

Hi I'm having a few issues with this app. It seems to work fine for Moves, but it wont save the image for collections. It fines the collection and lists it, lets me "show thumb" but when I click save nothing, no error, no image... Are there some setting I need to change to make this happen? Also, I think I read on a previous post that this can batch run through all the images, but I can't seem to find the any option for this. Is the app suppose to be installed in emby or just stand a lone? Can I some how use the scheduler in emby to call this app? Any help would be appreciated.

This app fell off the table. I'll have to take another look at the code. I remember it was left incomplete. My apologizes. I'll look into completing it.

Link to comment
Share on other sites

Nologic

@ chef

 

I noticed in my example "2 Broke Girls" that the logo.png had a huge transparent border...I'm not sure if you are trimming the transparency in your app...but it might be a good idea to get more reliable output.

 

ImageMagik example.1

convert imagename.png -trim new_name.png

How to not upscale with ffmpeg when trying to downscale examle 1

-filter_complex "scale=iw*min(1\,min(640/iw\,360/ih)):-1"

My code snippit for watermarks is rather simplistic...as I assumed someone spent the time creating a watermark that would look good at a certain resolution...I'm not sure if the ClearArt & Logo images have a certain resolution in mind...other than for the image to just look good.

 

I personally feel logo's should be limited to 25% of the background, with 3-5% of that used for minimum outside margins. Of course the logo should be centered as best as possible within that 25% area.

 

In the instance of my tastes...some ClearArt & Logos might be too small to begin with, to loosely fill such an area...my thoughts in this case would be to resize the background, then apply the overlay...then do the final resize.

 

Another idea for your text based ones...would be to dig through the NFO\XML's and read tag info...then use a font in the ASS file that goes along with it...like say MS Comic San's for Cartoons, or some sort of stencil font for War based shows.

 

Here is a more complete example...of making FFMpeg do all the work. :)

ffmpeg -i "W:\TV Shows\2 Broke Girls (2011)\fanart.jpg" -vf "movie='W\:/TV Shows/2 Broke Girls (2011)/logo-trim.png', scale=iw*min(1\,min((640-10)/iw\,(360-10)/ih)):-1[WaterMark];[In][WaterMark]overlay=W-(w+10):H-(h+10), scale=500:-1[Out]" test.png

YVo0WgC.png?1

 

Not exactly right...but not far off ether.

 

Okay ASS\SSA example

l4rKy3Q.png

ffmpeg -loop 1 -f image2 -i "W:\TV Shows\2 Broke Girls (2011)\fanart.jpg" -vf "ass='W\:/TV Shows/2 Broke Girls (2011)/test.ssa';scale=500:-1" -vframes 1 test2.png

SSA contents

[Script Info]
; This is a Sub Station Alpha v4 script.
Title: 
ScriptType: v4.00
Collisions: Normal
PlayDepth: 0

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,Calibri,60,16777215,65535,65535,-2147483640,0,0,1,2,1,3,10,10,10,0,1

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:00.00,0:00:03.00,Default,NTP,0000,0000,0000,,2 Broke {\c&Hff00ff&}Girls

Anyways food for thought.

Edited by Nologic
  • Like 1
Link to comment
Share on other sites

That should be built into the core! @@Luke check this post out above. It looks great! If fanart doesn't have the image or the other sources. I think it also gives emby an edge that some of the other server programs are missing, even if only of thumb images. I love this.

 

If not the core then a plugin, now that the ffmpeg is coded, it could be easily built into a dll.

  • Like 2
Link to comment
Share on other sites

Nologic

Okay I fussed with Subtitles some more...it took me forever and a day to figure out how to render subtitles to a transparent png via FFMpeg...and sadly the method I came up with left the stroke boarders semi transparent and other minor issues. Like having to remove the drop shadow...well see for your self...had to up the font from 60 to 90.

ffmpeg -y -f lavfi -i color=c=gray:s=1920x1080 -filter_complex "format=pix_fmts=rgba,ass='W\:/TV Shows/2 Broke Girls (2011)/test.ssa'[sub];[sub]colorkey=gray:0.3:0.2" -vframes 1 -pix_fmt rgba -c:v png out.png

Given the results didn't fair well...I decided to take a different approach...I'd strip the stroke & drop shadow from the png and add them back via ImageMagik...this turned out rather well.

ffmpeg -y -f lavfi -i color=c=black:s=1920x1080 -filter_complex "format=pix_fmts=rgba,ass='W\:/TV Shows/2 Broke Girls (2011)/test.ssa'[sub];[sub]colorkey=black:0.3:0.2" -vframes 1 -pix_fmt rgba -c:v png out.png
convert ..\ffmpeg\out.png -bordercolor none -border 2x2 -background black -alpha background -channel A -blur 0x3 -level 0,1% ..\ffmpeg\transparent.png
convert ..\ffmpeg\transparent.png -strokewidth 15 ( -clone 0 -background black -shadow 80x3+0+8 ) -reverse -background none -layers merge +repage ..\ffmpeg\transparent-new.png
convert ..\ffmpeg\transparent-new.png -trim ..\ffmpeg\transparent-trim.png

I then decided to see if I couldn't do the whole bloody thing in ImageMagic. Which turned out well, other than the new bald spot on the top of my head.

convert -alpha on -background transparent -fill white -stroke black -strokewidth 2 -font Calibri -pointsize 240 -density 96 -gravity Center caption:"2 Broke Girls" -channel RGBA -gaussian 0x0.5 png32:temp.png
convert temp.png -channel A -blur 0x2 -level 0,1% png32:temp-stroke.png
convert temp-stroke.png -strokewidth 15 ( -clone 0 -background black -shadow 80x3+0+8 ) -reverse -background none -layers merge +repage png32:temp-shadow.png

So what does rasterizing our text gain us...well we can cheat on some math by just brute force resizing things. :)

 

I'll probably do a few more things...but I think this itch is nearly scratched. :)

 

uTAM8x1.png

 

Well I think text split should happen on ":" except when there are numeric values on ether side of it...so something like "3:10 to Yuma" doesn't get botched.

 

Text should probably also split on "," provided it's over a certain length.

 

Might also want to split on a single quote if, there are 3 or more alphanumeric char prior and one post.

 

I think a length of 22 char should cause a test for text split, and split on the prior white space...provided it's not less than say 16 char in length from the start. If so...then maybe seek to the next white space post the 22 marker.

 

Should a colon be found in a title...the primary title should be twice the size of the secondary title, provided it's ether as long or longer than the secondary. If the length of the secondary is longer then the primary should be scaled to the same pixel width...provided it doesn't raise above the imposed constraints.

Edited by Nologic
  • Like 1
Link to comment
Share on other sites

  • 2 months later...
shorty1483

@@chef Thumb Maker seems not to work anymore. It finds no titles even there are ones without thumbs. Using latest Dev.

 

Gesendet von meinem HTC One M8 mit Tapatalk

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...