Page 1 of 1

Custom --conflict action to prefer HEVC over AVC

Posted: 28 Mar 2023, 08:37
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?

Re: Overwrite for TV episodes

Posted: 28 Mar 2023, 11:03
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.

Re: Overwrite for TV episodes (Custom Conflict Action)

Posted: 28 Mar 2023, 14:55
by gardinerr2
I dont think i have the expertise to develop this, but im happy to test and review it

Re: Overwrite for TV episodes (Custom Conflict Action)

Posted: 29 Mar 2023, 03:16
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.

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

Posted: 30 Mar 2023, 10:57
by gardinerr2
I use filebot node on Synology, can i use this code on there?

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

Posted: 30 Mar 2023, 11:37
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.

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

Posted: 12 Apr 2023, 09:49
by gardinerr2
Any chance this could be added to node?

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

Posted: 12 Apr 2023, 10:27
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.

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

Posted: 19 Dec 2023, 18:07
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]