FPS binding reference

Support for Windows users
Post Reply
jerome
Posts: 26
Joined: 25 Feb 2019, 02:21

FPS binding reference

Post by jerome »

I use the GUI interface and I've not made any changes to my preset files in almost a year.
I spent a lot of time researching to create the line below and it was working fine, but only today did I notice that it has stopped working.

Code: Select all

{fps.stripTrailingZeros().toPlainString() + 'fps'}
I tested it as standalone against some files and got the following error, but don't understand what it means.

Code: Select all

[No signature of method: net.filebot.format.FrameRate.stripTrailingZeros() is applicable for argument types: () values: []] Peaky Blinders - 1x01 - Episode 1
My best guess is that it has something to do with the fact that the FPS type was decimal before but is now Framerate.
I then tried just {fps} and got "25 fps", which is good but I use this parameter in the filename and I don't want the space. I tried {fps.space('.')} but that did not work.

Can anyone help me with the code to replace the "space" with a "period" using the FPS binding reference?

Thanks

Code: Select all

FileBot 4.9.4 (r8736)
JNA Native: 6.1.0
MediaInfo: 20.09
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2021-08-02 (r761)
Groovy: 3.0.8
JRE: OpenJDK Runtime Environment 16.0.2
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 12 Core / 4.8 GB Max Memory / 496 MB Used Memory
OS: Windows 10 (amd64)
STORAGE: xxxxxxx
DATA: C:\Users\xxxx\AppData\Roaming\FileBot
Package: MSI
License: FileBot License xxxxx (Valid-Until: 2022-01-17)
User avatar
rednoah
The Source
Posts: 20473
Joined: 16 Nov 2011, 08:59

Re: FPS binding reference

Post by rednoah »

String.space() only works on String type objects, so you need to do this:

Code: Select all

{ fps.toString().space('.') }
:idea: Please read the FAQ and How to Request Help.
jerome
Posts: 26
Joined: 25 Feb 2019, 02:21

Re: FPS binding reference

Post by jerome »

Thanks Rednoah. I actually went with this instead

Code: Select all

{fps.toString().replace(' fps','fps')}
as it yielded what I wanted.

I am now checking which files need to be renamed. In so doing I have discovered that the FPS binding only works if MediaInfo data has Frame Rate Mode equal to "Constant". If Frame Rate Mode equals "Variable" then there is no Frame Rate field data and the following error message occurs.

Code: Select all

[Binding "Video[FrameRate]": undefined]
Not sure if you want to have FPS check that Frame Rate Mode is Constant and if not then Return FPS as "variable fps".
User avatar
rednoah
The Source
Posts: 20473
Joined: 16 Nov 2011, 08:59

Re: FPS binding reference

Post by rednoah »

Please paste the MediaInfo table for one of the files where {fps} is undefined.
viewtopic.php?t=4285
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1219
Joined: 15 May 2014, 16:17

Re: FPS binding reference

Post by kim »

Is your file format = MPEG-TS ?

Code: Select all

86        @Define("fps")
987        public FrameRate getFrameRate() {
988                return FrameRate.parse(getMediaInfo(StreamKind.Video, "FrameRate"));
989        }
https://www.filebot.net/docs/api/src-ht ... l#line.986

you can also use this:

Code: Select all

{fps.value + 'fps'}

Code: Select all

{"${video.FrameRate[0]}fps"}

Code: Select all

{"${video.FrameRate.find()}fps"}

Code: Select all

{fps.value.round() + 'fps'}

Code: Select all

{video.FrameRate[0].toBigDecimal().round() + 'fps'}

Code: Select all

{fps.value.round(2) + 'fps'}

Code: Select all

{fps.properties}
= e.g.

Code: Select all

{value=23.976, numberForma[email protected], unit= fps, class=class net.filebot.format.FrameRate, fractionDigits=3, fraction=true}

Code: Select all

{fps.class}
=

Code: Select all

class net.filebot.format.FrameRate

Code: Select all

{fps.value.class}
=

Code: Select all

class java.lang.Double

Code: Select all

{(fps.value + 'fps').class}
=

Code: Select all

fps class java.lang.String
jerome
Posts: 26
Joined: 25 Feb 2019, 02:21

Re: FPS binding reference

Post by jerome »

Here is a sample 1:

Code: Select all

General
Unique ID                                : 323403346832695497686751794373421446005 (0xF34D380EF170530756078B2A35843375)
Complete name                            : \\Prometheus\movie_#\7th Dawn, The (1964) [SD • 360p • Action • NR]\The.7th.Dawn.1964.360p.DVDRip.AAC.x264.8bit.123min.VARfps.English.tt0057813.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 1.74 GiB
Duration                                 : 2 h 3 min
Overall bit rate                         : 2 014 kb/s
Writing application                      : HandBrake 0.10.1 2015030800
Writing library                          : Lavf55.12.0

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Nominal bit rate                         : 1 850 kb/s
Width                                    : 634 pixels
Height                                   : 382 pixels
Display aspect ratio                     : 5:3
Frame rate mode                          : Variable
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Writing library                          : x264 core 142 r2479 dd79a61
Encoding settings                        : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=300 / keyint_min=30 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=2pass / mbtree=1 / bitrate=1850 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=20000 / vbv_bufsize=25000 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : A_AAC-2
Duration                                 : 2 h 3 min
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Delay relative to video                  : -21 ms
Title                                    : Stereo
Default                                  : Yes
Forced                                   : No

Menu
00:00:00.000                             : :Chapter 1
00:10:00.433                             : :Chapter 2
00:20:00.741                             : :Chapter 3
00:30:00.666                             : :Chapter 4
00:40:00.940                             : :Chapter 5
00:50:00.498                             : :Chapter 6
01:00:00.664                             : :Chapter 7
01:10:00.930                             : :Chapter 8
01:20:00.446                             : :Chapter 9
01:30:00.462                             : :Chapter 10
01:40:00.603                             : :Chapter 11
01:50:00.836                             : :Chapter 12
02:00:00.560                             : :Chapter 13

[b]Here is Sample 2:[/b]
General
Unique ID                                : 165298704858798412458735182148275191209 (0x7C5B5F5F25FB00B8209EC821F98EBDA9)
Complete name                            : \\Prometheus\movie_a\A Man for All Seasons (1966) [SD • 480p • Drama • G]\A.Man.for.All.Seasons.1966.480p.DVD-R.DD.x264.8bit.120min.VARfps.English.tt0060665.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 1.49 GiB
Duration                                 : 2 h 0 min
Overall bit rate                         : 1 774 kb/s
Encoded date                             : UTC 2019-06-30T16:56:12Z
Writing application                      : HandBrake 1.1.0 2018040700
Writing library                          : Lavf57.7.2

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Bit rate                                 : 1 546 kb/s
Width                                    : 708 pixels
Height                                   : 462 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Writing library                          : x264 core 155 r2893 b00bcaf
Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=14 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=20000 / vbv_bufsize=25000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : A_AC3
Duration                                 : 2 h 0 min
Bit rate mode                            : Constant
Bit rate                                 : 192 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Compression mode                         : Lossy
Stream size                              : 165 MiB (11%)
Title                                    : Stereo
Language                                 : English
Service kind                             : Complete Main
Default                                  : Yes
Forced                                   : No

Text #1
ID                                       : 3
Format                                   : VobSub
Codec ID                                 : S_VOBSUB
Codec ID/Info                            : Picture based subtitle format used on DVDs
Language                                 : English
Default                                  : No
Forced                                   : No

Text #2
ID                                       : 4
Format                                   : ASS
Codec ID                                 : S_TEXT/ASS
Codec ID/Info                            : Advanced Sub Station Alpha
Compression mode                         : Lossless
Language                                 : English
Default                                  : No
Forced                                   : No

Menu
00:00:00.000                             : :Chapter 1
00:05:15.757                             : :Chapter 2
00:09:29.677                             : :Chapter 3
00:16:13.981                             : :Chapter 4
00:17:14.008                             : :Chapter 5
00:22:21.782                             : :Chapter 6
00:26:28.796                             : :Chapter 7
00:27:51.512                             : :Chapter 8
00:29:39.219                             : :Chapter 9
00:34:41.788                             : :Chapter 10
00:43:02.455                             : :Chapter 11
00:47:15.508                             : :Chapter 12
00:50:38.077                             : :Chapter 13
00:55:08.680                             : :Chapter 14
00:56:28.694                             : :Chapter 15
00:58:05.324                             : :Chapter 16
01:10:11.716                             : :Chapter 17
01:12:51.576                             : :Chapter 18
01:13:56.474                             : :Chapter 19
01:19:03.781                             : :Chapter 20
01:24:01.712                             : :Chapter 21
01:25:38.809                             : :Chapter 22
01:28:12.996                             : :Chapter 23
01:35:34.537                             : :Chapter 24
01:43:31.814                             : :Chapter 25
01:49:45.287                             : :Chapter 26
01:54:07.282                             : :Chapter 27
01:57:56.011                             : :Chapter 28
kim
Power User
Posts: 1219
Joined: 15 May 2014, 16:17

Re: FPS binding reference

Post by kim »

Looks like you are out of luck

maybe better in a new version of MediaInfo ?

https://mediaarea.net/MediaInfoOnline
(Select the MediaInfo output - MediaInfo XML or JSON)
jerome
Posts: 26
Joined: 25 Feb 2019, 02:21

Re: FPS binding reference

Post by jerome »

Upgraded to newest version of MediaInfo and no change.

I guess I'll have to manually edit these files or recode to a Constant frame rate.

Thanks
User avatar
rednoah
The Source
Posts: 20473
Joined: 16 Nov 2011, 08:59

Re: FPS binding reference

Post by rednoah »

You could do an explicitly check to pick one value or another:

Code: Select all

{ 'CFR' in video.FrameRateMode ? fps : 'variable fps' }
or just try one and default to another in case of failure:

Code: Select all

{ any{fps}{'variable fps'} }


:idea: Note that you will always want to view MediaInfo properties from within FileBot, because that's key and value pairs that your format is going to be using. If you use the MediaInfo application, then you will get a human-readable summary, but you won't actually be able to code from that because you won't know the exact property keys and values.

Image
:idea: Please read the FAQ and How to Request Help.
jerome
Posts: 26
Joined: 25 Feb 2019, 02:21

Re: FPS binding reference

Post by jerome »

I did try something similar to what you suggested for explicit check just to get me over the hump and it works, although I'm not sure if its actually doing what I expect or is technically the correct syntax.

Code: Select all

{video[0].Frame_Rate_Mode =~ "VFR" ? "Vfps" : fps.toString().replace(' fps','fps')}
Your coding is more efficient so I'll switch it up.

Thanks for the help.
Post Reply