renaming preview and effective preview don't match

Support for macOS users
Post Reply
rikk91
Posts: 5
Joined: 01 Apr 2024, 16:06

renaming preview and effective preview don't match

Post by rikk91 »

Hi,

I have written a script to group and collect audio track info, however i found out that renaming preview and effective preview do not match and It's driving me crazy.

below my code

Groovy: Select all

{
	String audioToString(){
		
		def myAudioList = []
		for (int i = 0; i < audio.format.size(); i++) {
		    def track = [:]
		    track.format = audio.format[i].toString().removeAll(/[^A-Z0-9]/)
		    track.channels = audio.channels[i].replaceAll(/\[|]/,'').replace('2', '2.0').replace('6', '5.1')
		    track.language = audio.LanguageString3[i] != null ? audio.LanguageString3[i].lower() : "und"
		    myAudioList << track
		}
		
		def groupedAudio = myAudioList.groupBy { "${it.format} ${it.channels}" }
		
		def result = []
		groupedAudio.each { key, tracks ->
		    def languages = ""
		    tracks.eachWithIndex { track, index ->
		        languages += track.language
		        if (index < tracks.size() - 1) {
		            languages += " "
		        }
		    }
		    result << "${languages} ${key}"
		}
		
		return result.join(" ")
	}
}
and the "correct" preview is
Image


But what it really renames is
Image

as you see the codec changes from AC3 to EAC3 for no apparent reason, the thing is done randomly on other files as well


any help?
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: renaming preview and effective preview don't match

Post by rednoah »

:?: How do you know that EAC3 / AC3 is or is not correct for the file at hand? Please share the MediaInfo properties for the file at hand so that we can have a look.


:idea: If you get different results for MediaInfo Bindings then you likely are testing with different files. Make sure to use Double-Click <Match> ➔ Format Editor to open the Format Editor with the selected File / Movie match at hand. Otherwise you may be testing with a different File / Movie sample and thus get different results.


:!: Note that the format code you posted does nothing. It is merely defining a function which is then never called, thus the code yields no result. Please copy & paste the entire code.
:idea: Please read the FAQ and How to Request Help.
rikk91
Posts: 5
Joined: 01 Apr 2024, 16:06

Re: renaming preview and effective preview don't match

Post by rikk91 »

Properties: Select all


[General]
Count                      : 349
StreamCount                : 1
StreamKind                 : General
StreamKind/String          : General
StreamKindID               : 0
UniqueID                   : 69244035331367313036195428574858477242
UniqueID/String            : 69244035331367313036195428574858477242 (0x3417EA864853E797479C38BA22167EBA)
VideoCount                 : 1
AudioCount                 : 2
TextCount                  : 3
MenuCount                  : 1
Video_Format_List          : HEVC
Video_Format_WithHint_List : HEVC
Video_Codec_List           : HEVC
Audio_Format_List          : AC-3 / AC-3
Audio_Format_WithHint_List : AC-3 / AC-3
Audio_Codec_List           : AC-3 / AC-3
Audio_Language_List        : it / en
Audio_Channels_Total       : 12
Text_Format_List           : ASS / ASS / PGS
Text_Format_WithHint_List  : ASS / ASS / PGS
Text_Codec_List            : ASS / ASS / PGS
Text_Language_List         : it / it / en
Format                     : Matroska
Format/String              : Matroska
Format/Url                 : https://matroska.org/downloads/windows.html
Format/Extensions          : mkv mk3d mka mks
Format_Commercial          : Matroska
Format_Version             : Version 4
FileSize                   : 2278736279
FileSize/String            : 2.12 GiB
FileSize/String1           : 2 GiB
FileSize/String2           : 2.1 GiB
FileSize/String3           : 2.12 GiB
FileSize/String4           : 2.122 GiB
Duration                   : 6143429
Duration/String            : 1h 42mn
Duration/String1           : 1h 42mn 23s 429ms
Duration/String2           : 1h 42mn
Duration/String3           : 01:42:23.429
Duration/String4           : 01:42:22;22
Duration/String5           : 01:42:23.429 (01:42:22;22)
OverallBitRate             : 2967380
OverallBitRate/String      : 2967 Kbps
FrameRate                  : 23.976
FrameRate/String           : 23.976 fps
FrameCount                 : 147246
IsStreamable               : Yes
Title                      : (2020) Onward - Oltre La Magia
Movie                      : (2020) Onward - Oltre La Magia
Encoded_Date               : 2022-02-02 00:04:06 UTC
Encoded_Application        : mkvmerge v61.0.0 ('So') 64-bit
Encoded_Application/String : mkvmerge v61.0.0 ('So') 64-bit
Encoded_Library            : libebml v1.4.2 + libmatroska v1.6.4 / Lavf58.29.100
Encoded_Library/String     : libebml v1.4.2 + libmatroska v1.6.4 / Lavf58.29.100

[Video]
Count                            : 381
StreamCount                      : 1
StreamKind                       : Video
StreamKind/String                : Video
StreamKindID                     : 0
StreamOrder                      : 0
ID                               : 1
ID/String                        : 1
UniqueID                         : 1
Format                           : HEVC
Format/String                    : HEVC
Format/Info                      : High Efficiency Video Coding
Format/Url                       : http://www.itu.int
Format_Commercial                : HEVC
Format_Profile                   : Main@L4@Main
InternetMediaType                : video/H265
CodecID                          : V_MPEGH/ISO/HEVC
Duration                         : 6141386.000000
Duration/String                  : 1h 42mn
Duration/String1                 : 1h 42mn 21s 386ms
Duration/String2                 : 1h 42mn
Duration/String3                 : 01:42:21.386
Duration/String4                 : 01:42:22;22
Duration/String5                 : 01:42:21.386 (01:42:22;22)
BitRate                          : 2182518
BitRate/String                   : 2183 Kbps
Width                            : 1920
Width/String                     : 1920 pixel
Height                           : 804
Height/String                    : 804 pixel
Stored_Height                    : 808
Sampled_Width                    : 1920
Sampled_Height                   : 804
PixelAspectRatio                 : 1.000
DisplayAspectRatio               : 2.388
DisplayAspectRatio/String        : 2.40:1
FrameRate_Mode                   : CFR
FrameRate_Mode/String            : CFR
FrameRate                        : 23.976
FrameRate/String                 : 23.976 (24000/1001) fps
FrameRate_Num                    : 24000
FrameRate_Den                    : 1001
FrameCount                       : 147246
ColorSpace                       : YUV
ChromaSubsampling                : 4:2:0
ChromaSubsampling/String         : 4:2:0
BitDepth                         : 8
BitDepth/String                  : 8 bit
Bits-(Pixel*Frame)               : 0.059
Delay                            : 5
Delay/String                     : 5ms
Delay/String1                    : 5ms
Delay/String2                    : 5ms
Delay/String3                    : 00:00:00.005
Delay/String4                    : 00:00:00;00
Delay/String5                    : 00:00:00.005 (00:00:00;00)
Delay_Source                     : Container
Delay_Source/String              : Container
StreamSize                       : 1675460835
StreamSize/String                : 1.56 GiB (74%)
StreamSize/String1               : 2 GiB
StreamSize/String2               : 1.6 GiB
StreamSize/String3               : 1.56 GiB
StreamSize/String4               : 1.560 GiB
StreamSize/String5               : 1.56 GiB (74%)
StreamSize_Proportion            : 0.73526
Encoded_Library                  : x265 - 3.2.1+1-b5c86a64bbbe:[Windows][GCC 9.2.0][64 bit] 8bit+10bit+12bit
Encoded_Library/String           : x265 3.2.1+1-b5c86a64bbbe:[Windows][GCC 9.2.0][64 bit] 8bit+10bit+12bit
Encoded_Library_Name             : x265
Encoded_Library_Version          : 3.2.1+1-b5c86a64bbbe:[Windows][GCC 9.2.0][64 bit] 8bit+10bit+12bit
Encoded_Library_Settings         : cpuid=1064959 / frame-threads=2 / numa-pools=6 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=1920x804 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=3 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / open-gop / min-keyint=24 / keyint=240 / gop-lookahead=0 / bframes=4 / b-adapt=0 / b-pyramid / bframe-bias=0 / rc-lookahead=15 / lookahead-slices=5 / scenecut=40 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / no-limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=2 / selective-sao=4 / no-early-skip / rskip / fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=21.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=255 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr / no-hdr-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00
Default                          : Yes
Default/String                   : Yes
Forced                           : No
Forced/String                    : No
colour_description_present       : Yes
colour_description_present_Sourc : Stream
colour_range                     : Limited
colour_range_Source              : Stream
colour_primaries                 : BT.709
colour_primaries_Source          : Stream
transfer_characteristics         : BT.709
transfer_characteristics_Source  : Stream
matrix_coefficients              : BT.709
matrix_coefficients_Source       : Stream

[Audio]
Count                      : 297
StreamCount                : 2
StreamKind                 : Audio
StreamKind/String          : Audio
StreamKindID               : 0
StreamKindPos              : 1
StreamOrder                : 1
ID                         : 2
ID/String                  : 2
UniqueID                   : 2
Format                     : AC-3
Format/String              : AC-3
Format/Info                : Audio Coding 3
Format/Url                 : https://en.wikipedia.org/wiki/AC3
Format_Commercial          : Dolby Digital
Format_Commercial_IfAny    : Dolby Digital
Format_Settings_Endianness : Big
CodecID                    : A_AC3
Duration                   : 6143424.000000
Duration/String            : 1h 42mn
Duration/String1           : 1h 42mn 23s 424ms
Duration/String2           : 1h 42mn
Duration/String3           : 01:42:23.424
Duration/String5           : 01:42:23.424
BitRate_Mode               : CBR
BitRate_Mode/String        : CBR
BitRate                    : 384000
BitRate/String             : 384 Kbps
Channel(s)                 : 6
Channel(s)/String          : 6 channel
ChannelPositions           : Front: L C R, Side: L R, LFE
ChannelPositions/String2   : 3/2/0.1
ChannelLayout              : L R C LFE Ls Rs
SamplesPerFrame            : 1536
SamplingRate               : 48000
SamplingRate/String        : 48.0 KHz
SamplingCount              : 294884352
FrameRate                  : 31.250
FrameRate/String           : 31.250 fps (1536 SPF)
FrameCount                 : 191982
Compression_Mode           : Lossy
Compression_Mode/String    : Lossy
Delay                      : 5
Delay/String               : 5ms
Delay/String1              : 5ms
Delay/String2              : 5ms
Delay/String3              : 00:00:00.005
Delay/String5              : 00:00:00.005
Delay_Source               : Container
Delay_Source/String        : Container
Video_Delay                : 0
Video_Delay/String3        : 00:00:00.000
Video_Delay/String5        : 00:00:00.000
StreamSize                 : 294884352
StreamSize/String          : 281 MiB (13%)
StreamSize/String1         : 281 MiB
StreamSize/String2         : 281 MiB
StreamSize/String3         : 281 MiB
StreamSize/String4         : 281.2 MiB
StreamSize/String5         : 281 MiB (13%)
StreamSize_Proportion      : 0.12941
Title                      : 5.1
Language                   : it
Language/String            : it
Language/String1           : it
Language/String2           : it
Language/String3           : ita
Language/String4           : it
ServiceKind                : CM
ServiceKind/String         : Complete Main
Default                    : Yes
Default/String             : Yes
Forced                     : No
Forced/String              : No
bsid                       : 8
dialnorm                   : -31 dB
acmod                      : 7
lfeon                      : 1
dialnorm_Average           : -31 dB
dialnorm_Minimum           : -31 dB
dialnorm_Maximum           : -31 dB
dialnorm_Count             : 1110

[Audio]
Count                      : 297
StreamCount                : 2
StreamKind                 : Audio
StreamKind/String          : Audio
StreamKindID               : 1
StreamKindPos              : 2
StreamOrder                : 2
ID                         : 3
ID/String                  : 3
UniqueID                   : 3
Format                     : AC-3
Format/String              : AC-3
Format/Info                : Audio Coding 3
Format/Url                 : https://en.wikipedia.org/wiki/AC3
Format_Commercial          : Dolby Digital
Format_Commercial_IfAny    : Dolby Digital
Format_Settings_Endianness : Big
CodecID                    : A_AC3
Duration                   : 6141408.000000
Duration/String            : 1h 42mn
Duration/String1           : 1h 42mn 21s 408ms
Duration/String2           : 1h 42mn
Duration/String3           : 01:42:21.408
Duration/String5           : 01:42:21.408
BitRate_Mode               : CBR
BitRate_Mode/String        : CBR
BitRate                    : 384000
BitRate/String             : 384 Kbps
Channel(s)                 : 6
Channel(s)/String          : 6 channel
ChannelPositions           : Front: L C R, Side: L R, LFE
ChannelPositions/String2   : 3/2/0.1
ChannelLayout              : L R C LFE Ls Rs
SamplesPerFrame            : 1536
SamplingRate               : 48000
SamplingRate/String        : 48.0 KHz
SamplingCount              : 294787584
FrameRate                  : 31.250
FrameRate/String           : 31.250 fps (1536 SPF)
FrameCount                 : 191919
Compression_Mode           : Lossy
Compression_Mode/String    : Lossy
Delay                      : 0
Delay/String3              : 00:00:00.000
Delay/String5              : 00:00:00.000
Delay_Source               : Container
Delay_Source/String        : Container
Video_Delay                : -5
Video_Delay/String         : -5ms
Video_Delay/String1        : -5ms
Video_Delay/String2        : -5ms
Video_Delay/String3        : -00:00:00.005
Video_Delay/String5        : -00:00:00.005
StreamSize                 : 294787584
StreamSize/String          : 281 MiB (13%)
StreamSize/String1         : 281 MiB
StreamSize/String2         : 281 MiB
StreamSize/String3         : 281 MiB
StreamSize/String4         : 281.1 MiB
StreamSize/String5         : 281 MiB (13%)
StreamSize_Proportion      : 0.12936
Title                      : 5.1
Language                   : en
Language/String            : en
Language/String1           : en
Language/String2           : en
Language/String3           : eng
Language/String4           : en
ServiceKind                : CM
ServiceKind/String         : Complete Main
Default                    : No
Default/String             : No
Forced                     : No
Forced/String              : No
bsid                       : 8
dialnorm                   : -31 dB
acmod                      : 7
lfeon                      : 1
dialnorm_Average           : -31 dB
dialnorm_Minimum           : -31 dB
dialnorm_Maximum           : -31 dB
dialnorm_Count             : 1113

[Text]
Count                   : 304
StreamCount             : 3
StreamKind              : Text
StreamKind/String       : Text
StreamKindID            : 0
StreamKindPos           : 1
StreamOrder             : 3
ID                      : 4
ID/String               : 4
UniqueID                : 4
Format                  : ASS
Format/String           : ASS
Format/Url              : http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow
Format_Commercial       : ASS
CodecID                 : S_TEXT/ASS
CodecID/Info            : Advanced Sub Station Alpha
Duration                : 4593016.000000
Duration/String         : 1h 16mn
Duration/String1        : 1h 16mn 33s 16ms
Duration/String2        : 1h 16mn
Duration/String3        : 01:16:33.016
Duration/String5        : 01:16:33.016
BitRate                 : 1
BitRate/String          : 1 bps
FrameRate               : 0.006
FrameRate/String        : 0.006 fps
FrameCount              : 26
ElementCount            : 26
Compression_Mode        : Lossless
Compression_Mode/String : Lossless
StreamSize              : 1072
StreamSize/String       : 1.05 KiB (0%)
StreamSize/String1      : 1 KiB
StreamSize/String2      : 1.0 KiB
StreamSize/String3      : 1.05 KiB
StreamSize/String4      : 1.047 KiB
StreamSize/String5      : 1.05 KiB (0%)
StreamSize_Proportion   : 0.00000
Title                   : Forced ITA
Language                : it
Language/String         : it
Language/String1        : it
Language/String2        : it
Language/String3        : ita
Language/String4        : it
Default                 : Yes
Default/String          : Yes
Forced                  : Yes
Forced/String           : Yes

[Text]
Count                   : 304
StreamCount             : 3
StreamKind              : Text
StreamKind/String       : Text
StreamKindID            : 1
StreamKindPos           : 2
StreamOrder             : 4
ID                      : 5
ID/String               : 5
UniqueID                : 5
Format                  : ASS
Format/String           : ASS
Format/Url              : http://ffdshow.sourceforge.net/tikiwiki/tiki-index.php?page=Getting+ffdshow
Format_Commercial       : ASS
CodecID                 : S_TEXT/ASS
CodecID/Info            : Advanced Sub Station Alpha
Duration                : 6068861.000000
Duration/String         : 1h 41mn
Duration/String1        : 1h 41mn 8s 861ms
Duration/String2        : 1h 41mn
Duration/String3        : 01:41:08.861
Duration/String5        : 01:41:08.861
BitRate                 : 96
BitRate/String          : 96 bps
FrameRate               : 0.229
FrameRate/String        : 0.229 fps
FrameCount              : 1389
ElementCount            : 1389
Compression_Mode        : Lossless
Compression_Mode/String : Lossless
StreamSize              : 73066
StreamSize/String       : 71.4 KiB (0%)
StreamSize/String1      : 71 KiB
StreamSize/String2      : 71 KiB
StreamSize/String3      : 71.4 KiB
StreamSize/String4      : 71.35 KiB
StreamSize/String5      : 71.4 KiB (0%)
StreamSize_Proportion   : 0.00003
Title                   : ITA
Language                : it
Language/String         : it
Language/String1        : it
Language/String2        : it
Language/String3        : ita
Language/String4        : it
Default                 : No
Default/String          : No
Forced                  : No
Forced/String           : No

[Text]
Count                 : 304
StreamCount           : 3
StreamKind            : Text
StreamKind/String     : Text
StreamKindID          : 2
StreamKindPos         : 3
StreamOrder           : 5
ID                    : 6
ID/String             : 6
UniqueID              : 6
Format                : PGS
Format/String         : PGS
Format_Commercial     : PGS
MuxingMode            : zlib
CodecID               : S_HDMV/PGS
CodecID/Info          : Picture based subtitle format used on BDs/HD-DVDs
Duration              : 6067602.000000
Duration/String       : 1h 41mn
Duration/String1      : 1h 41mn 7s 602ms
Duration/String2      : 1h 41mn
Duration/String3      : 01:41:07.602
Duration/String4      : 01:03:37
Duration/String5      : 01:41:07.602 (01:03:37)
BitRate               : 47827
BitRate/String        : 47.8 Kbps
FrameRate             : 0.629
FrameRate/String      : 0.629 fps
FrameCount            : 3814
ElementCount          : 3814
StreamSize            : 36274768
StreamSize/String     : 34.6 MiB (2%)
StreamSize/String1    : 35 MiB
StreamSize/String2    : 35 MiB
StreamSize/String3    : 34.6 MiB
StreamSize/String4    : 34.59 MiB
StreamSize/String5    : 34.6 MiB (2%)
StreamSize_Proportion : 0.01592
Title                 : ENG
Language              : en
Language/String       : en
Language/String1      : en
Language/String2      : en
Language/String3      : eng
Language/String4      : en
Default               : No
Default/String        : No
Forced                : No
Forced/String         : No

[Menu]
Count              : 138
StreamCount        : 1
StreamKind         : Menu
StreamKind/String  : Menu
StreamKindID       : 0
Chapters_Pos_Begin : 101
Chapters_Pos_End   : 138
00:00:00.000       : Prologue
00:02:30.025       : Chaotic House
00:07:06.384       : Dad's Legacy
00:08:14.327       : School Fail
00:12:45.014       : Tape Recorder
00:14:53.726       : The Gift
00:19:21.035       : Conjuring Dad
00:23:46.050       : Off We Go
00:25:34.742       : Mom Finds Note
00:26:11.111       : Loosen Up
00:27:25.435       : Manticore's Tavern
00:30:02.134       : Fallen Idol
00:32:49.134       : The Plan
00:34:43.623       : Mom and Manticore
00:36:40.782       : Bigger Man
00:40:41.981       : Gas Station
00:42:48.733       : The Curse
00:44:02.140       : Sprite Insult
00:45:41.113       : Driving Test
00:47:49.158       : Honesty
00:52:01.368       : Dance Fight
00:55:12.142       : Pawn Shop
00:57:23.941       : Trust Bridge
01:02:23.323       : Change of Plans
01:04:02.964       : Sacrifice
01:07:13.071       : Following Ravens
01:08:49.042       : Underground
01:10:06.160       : To the Skies
01:11:12.268       : Reward
01:13:13.055       : Working Together
01:15:58.721       : Lowest Low
01:17:37.027       : Father Figure
01:20:26.322       : Dragon High
01:25:01.263       : Master Wizard
01:26:59.589       : Meeting Dad
01:30:10.780       : Epilogue
01:32:51.900       : Credits
as you can see the audio should be AC3 not EAC3. If i try to rename only this file it will be renamed correctly.
If i add more files I have the issue described. Seems that it sometimes takes data from the previous film.
Could there be any cached data left that creates this confusion? Is this a code-level error?
rikk91
Posts: 5
Joined: 01 Apr 2024, 16:06

Re: renaming preview and effective preview don't match

Post by rikk91 »

the function is called in the section below among other, a brief extraction of the code:

Groovy: Select all

{pulisciNome(n)} ({y}) {setTag()}
 [{vf} {vc.replace('AVC', 'H.264')replace('HEVC', 'H.265')}{any{ ' ' + 
 	hdr.replace('Dolby Vision', 'DV')}{ ' ' + dovi}}{bitdepth > 8 ? ' ' + bitdepth + 'bit' : ''}{ '-' + vs}]
 [{audioToString()}]
{textLanguages.size() > 3 ? ' [MultiSub]' : ' [sub ' + textLanguages.ISO2*.lower().join(' ') + {text.Title.toString().findMatch(/Forced/) ? ' +FN' : null } + ']' }
{setReleaser()}
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: renaming preview and effective preview don't match

Post by rednoah »

Well, I cannot comment on your format code since you did not share your format code. That said, I'd start to debug the issue by using a very simple format, so that we can see the values we're working with.


:arrow: e.g. use this format on your Onward (2020) sample file to see what MediaInfo Bindings we're working with:

Format: Select all

~/{fn}/{media.FileSize}/{media.Title}/{audio.Format}

Based on the media info table above:

Properties: Select all

Audio_Format_List          : AC-3 / AC-3
FileSize                   : 2278736279
Title                      : (2020) Onward - Oltre La Magia
we would expect the following output:

Code: Select all

~/<current filename>/2278736279/(2020) Onward - Oltre La Magia/[AC-3, AC-3]
** if FileBot is indeed somehow using information from the wrong file for some reason then {media.FileSize}/{media.Title} will confirm this and tell us which file is being used
:idea: Please read the FAQ and How to Request Help.
rikk91
Posts: 5
Joined: 01 Apr 2024, 16:06

Re: renaming preview and effective preview don't match

Post by rikk91 »

thank you I have sent to you the complete code via pm, also, I have added your code, but I had to comment some part because the new name it would get very long...

I keep seeing errors:
Image

and again if I click "Edit Format" on the single one, it show the correct values:
Image

but when I rename them I still get the wrong codec
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: renaming preview and effective preview don't match

Post by rednoah »

Alright, so the screenshots above suggest that {media.FileSize}/{media.Title}/{audio.Format} work correctly for each file and yield the correct values. So that's the baseline.


I tried your format and got this error message right away, and then it started yielding values:

Error: Select all

No signature of method: net.filebot.GroovyEngine.audioToString() is applicable for argument types: () values: []
I was then able to reproduce the issue. Your custom format code indeed somehow manages to work with information from the previous file. The Format Editor works because you repeatedly format the same file so the previous file is always also the current file when prototyping.

Turns out you use your audioToString() global function before you create it. So audioToString() doesn't exist yet and fails when your format is evaluated the first time around. Then the second time around, the audioToString() global function that was created in the first round is called, and so on. Each round uses the audioToString() global function that was created in the previous round, and so the function created in the previous round will return values from the previous round. That's my best guess anyway.


tl;dr do not create global functions; they're black magic and don't work like in other languages that you may be familiar with


Just don't use functions at all. As far as I can see, you create global functions just to use them once, so you don't need functions in the first place. If you do need to re-use values, then I recommend using local variables. Maybe this can serve as inspiration.
:idea: Please read the FAQ and How to Request Help.
rikk91
Posts: 5
Joined: 01 Apr 2024, 16:06

Re: renaming preview and effective preview don't match

Post by rikk91 »

Hi rednoah, thanks for the clarification, I had the suspicion it was related to the global function, but I didn't know they were treated differently compared to other languages. It seemed to me to be the best way for code cleanup and I had the intention of calling them multiple times.

Anyway, I rewrote the code by removing any global reference and indeed the problem was solved.

Thanks again for your support.
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: renaming preview and effective preview don't match

Post by rednoah »

At the very least you'll want to define a function before you use it. That said, we don't use global functions in any of our examples, so best not to use them. Not all Groovy features make sense for FileBot Format code.


You can definitely use local variables though, and the value of a local variable can notably be a function / closure. def ensures that all lives in the current {...} block only.


e.g. use variables:

Groovy: Select all

def v = n.upperInitial().lowerTrail()
e.g. use closures:

Groovy: Select all

def fn = { a -> a.upperInitial().lowerTrail() }
def v = fn(n)
:idea: Please read the FAQ and How to Request Help.
Post Reply