Feature Request: MultiCD MediaInfo summary support
Feature Request: MultiCD MediaInfo summary support
Say you need the combined (summary) "Duration" not just the part 1 e.g. cd1
(same with "FileSize", "OverallBitRate" and "BitRate")
Use:
rename of folder / filename
or
what I need it for... in the movie.nfo
(same with "FileSize", "OverallBitRate" and "BitRate")
Use:
rename of folder / filename
or
what I need it for... in the movie.nfo
Re: Feature Request: MultiCD MediaInfo summary support
Update 1:
Show complete duration in minutes (only tested in GUI):
FileSize in MB:
just change ['Duration'] --> ['FileSize']
durationinMS.sum())/60000) --> durationinMS.sum())/1000/1000 (why not 1024?)
OverallBitRate in Kbps:
['OverallBitRate']
(durationinMS.sum())/1000)/durationinMS.size()
Video BitRate in Kbps:
values()[1]['BitRate']
(durationinMS.sum()/1000)/durationinMS.size()
btw (MediaInfo):
General = values()[0]
Video = values()[1]
Audio = values()[2]
Show complete duration in minutes (only tested in GUI):
Code: Select all
{
package net.filebot.mediainfo;
def durationinMS = [];
def videoFiles = [];
def files = folder.listFiles();
files.each{if (it.isVideo()) {durationinMS += new BigDecimal(MediaInfo.snapshot(it).values()[0]['Duration'].join('')) }};
def durationinMINsum = Math.round((durationinMS.sum())/60000);
durationinMINsum
}
just change ['Duration'] --> ['FileSize']
durationinMS.sum())/60000) --> durationinMS.sum())/1000/1000 (why not 1024?)
OverallBitRate in Kbps:
['OverallBitRate']
(durationinMS.sum())/1000)/durationinMS.size()
Video BitRate in Kbps:
values()[1]['BitRate']
(durationinMS.sum()/1000)/durationinMS.size()
btw (MediaInfo):
General = values()[0]
Video = values()[1]
Audio = values()[2]
Re: Feature Request: MultiCD MediaInfo summary support
Since we're talking about the format, I'd use the {model} binding for this on 
Sum {minutes} is easy:
Sum {megabytes} is tricky because it'll yield String values:
No convenient avg function in Groovy... oh well...

Sum {minutes} is easy:
Code: Select all
{model.findAll{ it.n == n }.minutes.sum()}
Code: Select all
{model.findAll{ it.n == n }.megabytes.sum{ it as int }}
Code: Select all
{def r = model.findAll{ it.n == n }.bitrate; r.sum()/r.size()}
Re: Feature Request: MultiCD MediaInfo summary support
got any idea how / where to do this in the movie.nfo ?
1. maybe pass all files from amc to htpc ("fs") ?
2. something with " def mi = tryLogCatch{ movieFile ? MediaInfo.snapshot(movieFile) : null }" ?
3. or can I do it just by doing something under ?
fileinfo {
streamdetails {
mi?.each { kind, streams ->
def section = kind.toString().toLowerCase()
streams.each { s ->
4. all of the above ?
1. maybe pass all files from amc to htpc ("fs") ?
2. something with " def mi = tryLogCatch{ movieFile ? MediaInfo.snapshot(movieFile) : null }" ?
3. or can I do it just by doing something under ?
fileinfo {
streamdetails {
mi?.each { kind, streams ->
def section = kind.toString().toLowerCase()
streams.each { s ->
4. all of the above ?
Re: Feature Request: MultiCD MediaInfo summary support
1.
Yes, the amc/htpc scripts don't accommodate for this use case at all right now.
2.
How you did it in your code sample (find sibling files, accumulate mediainfo data) is probably how you'd do it. Though passing the fileset instead of just the first video file in the amc script is probably a better solution.
Yes, the amc/htpc scripts don't accommodate for this use case at all right now.
2.
How you did it in your code sample (find sibling files, accumulate mediainfo data) is probably how you'd do it. Though passing the fileset instead of just the first video file in the amc script is probably a better solution.
Re: Feature Request: MultiCD MediaInfo summary support
so I pass all files from amc and if I use e.g.
fileset.each{fileSizeINbytes += new BigDecimal(MediaInfo.snapshot(it).values()[0]['FileSize'].join('')) }}
and place e.g.
fileSizeINbytes.each{filesize(it)} in the fileinfo it works, but I don't think its the best way...
I want to use the existing "fileinfo..." part in htpc, but how...
I need to combine them into 1 set before I can use it...
make it unique and get sum... (best if done for all so I don't need to do something for every entry)
if I modify
def mi = tryLogCatch{ movieFile ? MediaInfo.snapshot(movieFile) : null
to e.g. fileset.each{(mi += MediaInfo.snapshot(it) ) }
(making it an Array with maps inside)
and add en extra "each" to "fileinfo..." it works but it writes separate sets in movie.nfo
I have tried and tried diff. things, but no luck
this is to complex for me, I need more to go on pls ?
you can use this as a sample:
def mi = [[General:[[FileName:'PUKKA.cd1', FileSize:731893308, Duration:2900390, OverallBitRate:2018543]],Video:[[Codec:'XVID', Duration:2900690, BitRate:1561146, Width:640, Height:272]],Audio:[[Codec:'AC3', Duration:2900666, BitRate:448000, Channel:6]]], [General:[[FileName:'PUKKA.cd2', FileSize:730903372, Duration:3472303, OverallBitRate:1683332]],Video:[[Codec:'XVID', Duration:3472303, BitRate:1226337, Width:640, Height:272]],Audio:[[Codec:'AC3', Duration:3472374, BitRate:448000, Channel:6]]]];
fileset.each{fileSizeINbytes += new BigDecimal(MediaInfo.snapshot(it).values()[0]['FileSize'].join('')) }}
and place e.g.
fileSizeINbytes.each{filesize(it)} in the fileinfo it works, but I don't think its the best way...
I want to use the existing "fileinfo..." part in htpc, but how...
I need to combine them into 1 set before I can use it...
make it unique and get sum... (best if done for all so I don't need to do something for every entry)
if I modify
def mi = tryLogCatch{ movieFile ? MediaInfo.snapshot(movieFile) : null
to e.g. fileset.each{(mi += MediaInfo.snapshot(it) ) }
(making it an Array with maps inside)
and add en extra "each" to "fileinfo..." it works but it writes separate sets in movie.nfo
I have tried and tried diff. things, but no luck

this is to complex for me, I need more to go on pls ?
you can use this as a sample:
def mi = [[General:[[FileName:'PUKKA.cd1', FileSize:731893308, Duration:2900390, OverallBitRate:2018543]],Video:[[Codec:'XVID', Duration:2900690, BitRate:1561146, Width:640, Height:272]],Audio:[[Codec:'AC3', Duration:2900666, BitRate:448000, Channel:6]]], [General:[[FileName:'PUKKA.cd2', FileSize:730903372, Duration:3472303, OverallBitRate:1683332]],Video:[[Codec:'XVID', Duration:3472303, BitRate:1226337, Width:640, Height:272]],Audio:[[Codec:'AC3', Duration:3472374, BitRate:448000, Channel:6]]]];
Re: Feature Request: MultiCD MediaInfo summary support
It's probably easier if you just calculate your values before you create the XML, and use the existing "mi" variables for everything where you don't need to sum/avg anything.
e.g.
Merging multiple nested maps is probably a lot more tricky. I'd stick to simple solutions.
e.g.
Code: Select all
def value = 'test'
XML{
tag(value)
}
Re: Feature Request: MultiCD MediaInfo summary support
sounds a lot like my first try 
I was hoping there was a smart way to do it
something like:
"def mapOne = [ [ id:1 , firstName : 'Jimmy'], [ id:2 , firstName : 'Robert'] ]
def mapTwo = [ [ id:1 , lastName: 'Page'], [ id:2 , lastName: 'Plant'] ]
def mergedMap = (mapOne + mapTwo).groupBy { it.id }.collect { it.value.collectEntries { it } }"
or
"def map1 = [p1:100, p2:200]
def map2 = [p3:300, p4:400]
def map3 = map1 + map2
println "${map3}" "
or
"assert [ a: true, b: false ] + [ a: false ] == [ a: false, b: false ]
Or left shift:
assert [ a: true, b: false ] << [ a: false ] == [ a: false, b: false ] "
but I can't get it to work...
the problem as I see it is the " += " ( same result = " << ")
fileset.each{(mi += MediaInfo.snapshot(it) ) }
(making it an Array with maps inside)
if I could just merge to a single set (like the org.) ?

I was hoping there was a smart way to do it

something like:
"def mapOne = [ [ id:1 , firstName : 'Jimmy'], [ id:2 , firstName : 'Robert'] ]
def mapTwo = [ [ id:1 , lastName: 'Page'], [ id:2 , lastName: 'Plant'] ]
def mergedMap = (mapOne + mapTwo).groupBy { it.id }.collect { it.value.collectEntries { it } }"
or
"def map1 = [p1:100, p2:200]
def map2 = [p3:300, p4:400]
def map3 = map1 + map2
println "${map3}" "
or
"assert [ a: true, b: false ] + [ a: false ] == [ a: false, b: false ]
Or left shift:
assert [ a: true, b: false ] << [ a: false ] == [ a: false, b: false ] "
but I can't get it to work...
the problem as I see it is the " += " ( same result = " << ")
fileset.each{(mi += MediaInfo.snapshot(it) ) }
(making it an Array with maps inside)
if I could just merge to a single set (like the org.) ?
Re: Feature Request: MultiCD MediaInfo summary support
You probably wanna use the findResults method to convert files to MediaInfo maps.
Re: Feature Request: MultiCD MediaInfo summary support
like this ?
mi = fileset.findResults{MediaInfo.snapshot(it)}
I see no diff.
mi = fileset.findResults{MediaInfo.snapshot(it)}
I see no diff.
Re: Feature Request: MultiCD MediaInfo summary support
Now you have a list of mediainfo maps and you can do whatever you want with it.
e.g.
e.g.
Code: Select all
def mis = fileset.findResults{MediaInfo.snapshot(it)}
def bitrate = mis.findResults{ ** get bitrate ** }.sum()
etc
Re: Feature Request: MultiCD MediaInfo summary support
thx but:
Script2.groovy: 493: expecting '}', found '{' @ line 493, column 31.
def Duration = mi.findResults{ ** get Duration ** }.sum()
same in Gui
Script2.groovy: 493: expecting '}', found '{' @ line 493, column 31.
def Duration = mi.findResults{ ** get Duration ** }.sum()
same in Gui
Re: Feature Request: MultiCD MediaInfo summary support
Sorry, but the ** get bitrate ** is for you to figure out. I don't know that from the back of my head. 

Re: Feature Request: MultiCD MediaInfo summary support
It took way to long to find out, you where talking about:
"It's probably easier if you just calculate your values before you create the XML, and use the existing "mi" variables for everything where you don't need to sum/avg anything."
... and NOT a "smart" way to do it all in the XML
... but there is an e.g. of what I made:
pre XML:
def mis = fileset.findResults{MediaInfo.snapshot(it)}
def fileSizeinBYTES = mis.findResults{new BigDecimal(it.values()[0]['FileSize'].join('')) }
in XML:
(fileSizeinBYTES).each{filesize(it)}
if (fileSizeinBYTES[1] != null) {filesizesum(fileSizeinBYTES.sum())}
btw: "fileset" is "fs" from the AMC
"It's probably easier if you just calculate your values before you create the XML, and use the existing "mi" variables for everything where you don't need to sum/avg anything."
... and NOT a "smart" way to do it all in the XML

... but there is an e.g. of what I made:
pre XML:
def mis = fileset.findResults{MediaInfo.snapshot(it)}
def fileSizeinBYTES = mis.findResults{new BigDecimal(it.values()[0]['FileSize'].join('')) }
in XML:
(fileSizeinBYTES).each{filesize(it)}
if (fileSizeinBYTES[1] != null) {filesizesum(fileSizeinBYTES.sum())}
btw: "fileset" is "fs" from the AMC
Re: Feature Request: MultiCD MediaInfo summary support
amc:
(if almost same filesize the order is a bit random, on first run, after that wrong way from the design...
tested in GUI and No I can't reproduce this on command)
I changed it to just ".sort()" ... now with my, make nfo with every files data, it is always cd1, cd2...
I don't get why use ".sort{ it.length() }.reverse()" (now: only make nfo from the 1 file with highest filesize) ?def movieFile = fs.findAll{ it.isVideo() || it.isDisk() }.sort{ it.length() }.reverse().findResult{ it }
(if almost same filesize the order is a bit random, on first run, after that wrong way from the design...
tested in GUI and No I can't reproduce this on command)
I changed it to just ".sort()" ... now with my, make nfo with every files data, it is always cd1, cd2...
Re: Feature Request: MultiCD MediaInfo summary support
That's probably to deal with samples or trailers and what not. The largest file is the actual movie file, usually.
CD123 multi-part movies are not considered or supported in this aspect, so behaviour might be somewhat random.
CD123 multi-part movies are not considered or supported in this aspect, so behaviour might be somewhat random.