Custom --conflict action to prefer HEVC over AVC

All your suggestions, requests and ideas for future development
Post Reply
gardinerr2
Posts: 18
Joined: 14 Jan 2018, 15:15

Custom --conflict action to prefer HEVC over AVC

Post by gardinerr2 »

The site i use for TV is now starting to release X265 versions of shows, which are significantly smaller in size, however these are usually a bit behind the main releases. If i set filebot to "Replace if better" it will discard these ffiles, and if i select always overwrite, it will take them, but if a subsequent larger release, say at the end of the series, is release, they'll overwrite again.

Can the replace if better be improved to take into account the format? or is there a way i can prefer HEVC / lower file size?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Overwrite for TV episodes

Post by rednoah »

A.
No, because --conflict auto only works with comparable (i.e. numbers) media properties, e.g. resolution, bitrate, file size, etc.



B.
Yes, because you can write your own Conflict Action and have your own custom code decide what to do about any given pair of files:
viewtopic.php?t=12891

:!: Some coding expertise required. This is an advanced feature that was added in FileBot 5.* so you will not find copy & paste examples yet.

:arrow: I'm happy to support a community effort if someone wants to take the time to develop (and maintain) a "smart conflict action" that takes into account video codec, audio codec, and other non-numeric properties, that can then be shared to (and modified by) end users.
:idea: Please read the FAQ and How to Request Help.
gardinerr2
Posts: 18
Joined: 14 Jan 2018, 15:15

Re: Overwrite for TV episodes (Custom Conflict Action)

Post by gardinerr2 »

I dont think i have the expertise to develop this, but im happy to test and review it
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Overwrite for TV episodes (Custom Conflict Action)

Post by rednoah »

e.g. custom --conflict action that prefers HEVC over AVC:

Code: Select all

--conflict /path/to/VideoCodecOrder.groovy

Code: Select all

{ from, to ->
	def score = { f ->
		['HEVC':20, 'AVC':10][f.mediaCharacteristics.videoCodec] ?: 0
	}
	score(from) > score(to) ? to : null
}

:idea: Note that this code only works for HEVC / AVC and any other video codec is always considered inferior.


:idea: Note that this code does not take file size, bitrate, etc into consideration at all, i.e. a small HEVC file is considered equal to a large HEVC file.


:!: MAKE SURE TO RUN YOUR OWN TESTS WITH SAMPLE FILES BEFORE USING THIS CODE IN PRODUCTION because you may overwrite the wrong file if the code doesn't work as intended.
:idea: Please read the FAQ and How to Request Help.
gardinerr2
Posts: 18
Joined: 14 Jan 2018, 15:15

Re: Custom --conflict action to prefer HEVC over AVC

Post by gardinerr2 »

I use filebot node on Synology, can i use this code on there?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom --conflict action to prefer HEVC over AVC

Post by rednoah »

Sorry, no. The FileBot Node WebUI uses a combo box with fixed values, so you can't pass along custom Groovy code as --conflict option value.
:idea: Please read the FAQ and How to Request Help.
gardinerr2
Posts: 18
Joined: 14 Jan 2018, 15:15

Re: Custom --conflict action to prefer HEVC over AVC

Post by gardinerr2 »

Any chance this could be added to node?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Custom --conflict action to prefer HEVC over AVC

Post by rednoah »

Future versions of FileBot Node will make the combobox editable, so that you can specify inline Groovy code or a file path. However, a new version of FileBot Node will not be released anytime soon since we don't have any major changes or features that would warrant a new release.
:idea: Please read the FAQ and How to Request Help.
gardinerr2
Posts: 18
Joined: 14 Jan 2018, 15:15

Re: Custom --conflict action to prefer HEVC over AVC

Post by gardinerr2 »

I've now tested the code you placed above, and it worked perfectly. I used the code that Node put in the window, and put it in a scheduled task in Synology, with the added conflict bit, and worked a treat

Code: Select all

[VideoCodecOrder.groovy] Delete [/volume2/video/TV Shows/For All Mankind/Season 04/For All Mankind - S04E04 - House Divided.mkv]
[MOVE] from [/volume2/video/Downloads/For.All.Mankind.S04E04.1080p.x265.mkv] to [/volume2/video/TV Shows/For All Mankind/Season 04/For All Mankind - S04E04 - House Divided.mkv]
Post Reply