Link to home
Start Free TrialLog in
Avatar of SpaceCoastLife
SpaceCoastLife

asked on

Exporting MediaInfo to Excel in a meaningful way

Is anyone aware of a technique or 3rd party software that will take the results of a MediaInfo video file and import it into Excel in a usable way? For example, say I have a folder containing 100 video files. I can open that folder using MediaInfo and get the various parameters of each file but way more information than I care about. I'd like to export - or at least end up with only a subset of the fields available like the following:
Movie Name
Video Bitrate
Video Width
Video Height

Audio Format
Audio Bitrate
Channels

I understand MediaInfo has an export feature with file type options but it seems to me all the options export it all.
Avatar of Professor J
Professor J

there is a free code written by John  http://spreadsheetpage.com/index.php/file/mp3_file_lister/

it returns the attributes of  mp3 files, but if you want to extend the file attributes, then here http://www.snb-vba.eu/VBA_Bestanden_en.html  is a reference that you can add from into the existing code to return more attributes  if you scroll down you will see that it a very extended list of file attributes  that you can incorporate in John's code to serve your need.
If this is a one time shot, why not just delete the imported columns in Excel that you don't want?
Hi SpaceCoastLife.

I tend to agree with Wayne's suggestion if you only need to do this once.  Another thing I would be tempted to look into first is whether there are any other similar "media info" utilities around that allow you more control over the output when using the command line or GUI options.
https://mediaarea.net/en/MediaInfo/Support/FAQ#Cmd_Options
Q: Why aren't there more options for the command line?
A: I didn't spend much time coding it, due to less interest from users.


With that said, however, a method can usually be found to modify text-based results output from various applications.

I see that the Command Line Interface output is shown here:
https://mediaarea.net/en/MediaInfo/Screenshots
(click the "CLI Output" button to show the example).

Is that the format that you have somehow managed to load into Excel?

If so, that causes issues with parsing the file and splitting up the attribute names from their values using the : delimiter because some of the values contain : also.

If the example is not the output generated for you, would it be possible to attach an example for us to see and work with?

I am wondering whether Windows Explorer is able to extract and display all of the details you want if you switch to "Details View" and then use the checkboxes to display additional columns (method varies by Windows version).  If so, then I am pretty sure that you would be able to read the metadata and values using VB Script or similar.  I believe that the "Folder.GetDetailsOf" method would allow you to retrieve values from the zero-based column number that is displayed in a Shell view, and I think the following column numbers are applicable to the respective attributes:

File Name = 0 or 155
File Size = 1
File Type = 2
Length = 27
Frame height = 283
Frame Width = 285

I am not expert in VBS or PowerShell, but there are loads of experts here who are.
> take the results of a MediaInfo video file and import it into Excel in a usable way

You may not be aware of it, but MediaInfo has a command line interface (CLI) version. The main download button gets you the GUI, but here's a page that has the CLI download:
https://mediaarea.net/en/MediaInfo/Download/Windows

Here's the Help output from it:
MediaInfo Command line,
MediaInfoLib - v0.7.87
Usage: "MediaInfo [-Options...] FileName1 [Filename2...]"

Options:

--Help, -h          Display this help and exit

--Help-Output       Display help for Output= option

--Help-AnOption     Display help for "AnOption"

--Version           Display MediaInfo version and exit

--Full , -f         Full information Display (all internal tags)

--Output=HTML       Full information Display with HTML tags

--Output=XML        Full information Display with XML tags

--Output=EBUCore    Full information Display with EBUCore compliant XML tags

--Output=...y       Template defined information Display

--Info-Parameters   Display list of Inform= parameters

--Language=raw      Display non-translated unique identifiers (internal text)

--LogFile=...       Save the output in the specified file

--BOM               Byte order mark for UTF-8 output

--Ssl_CertificateFileName=...
                    File name of the SSL certificate.
                    The default format is "PEM" and can be changed
                    with --Ssl_CertificateFormat.

--Ssl_CertificateFormat=...
                    File format of the SSL certificate.
                    Supported formats are "PEM" and "DER"

--Ssl_PrivateKeyFileName=...
                    File name of the SSL private key.
                    The default format is "PEM" and can be changed
                    with --Ssl_PrivateKeyFormat.
                    Note: private key with a password is not supported.

--Ssl_PrivateKeyFormat=...
                    File format of the SSL private key.
                    Supported formats are "PEM" and "DER"

--Ssl_CertificateAuthorityFileName=...
                    File name of the SSL certificate authorities
                    to verify the peer with.

--Ssl_CertificateAuthorityPath=...
                    Path of the SSL certificate authorities
                    to verify the peer with.

--Ssl_CertificateRevocationListFileName=...
                    File name of the SSL certificate revocation list.
                    The format is "PEM"

--Ssl_IgnoreSecurity=...
                    Does not verify the authenticity of the peer's certificate
                    Use it at your own risks

--Ssh_PublicKeyFileName=...
                    File name of the SSH private key.
                    Default is $HOME/.ssh/id_rsa.pub or $HOME/.ssh/id_dsa.pub
                    if the HOME environment variable is set, and just
                    "id_rsa.pub" or "id_dsa.pub" in the current directory
                    if HOME is not set.
                    Note: you need to set both public and private key.

--Ssh_PrivateKeyFileName=...
                    File name of the SSH private key.
                    Default is $HOME/.ssh/id_rsa or $HOME/.ssh/id_dsa
                    if the HOME environment variable is set, and just
                    "id_rsa" or "id_dsa" in the current directory
                    if HOME is not set.
                    Note: you need to set both public and private key.
                    Note: private key with a password is not supported.

--Ssh_KnownHostsFileName=...
                    File name of the known hosts
                    The format is the OpenSSH file format (libssh2)
                    Default is $HOME/.ssh/known_hosts
                    if the HOME environment variable is set, and just
                    "known_hosts" in the current directory
                    if HOME is not set.

--Ssh_IgnoreSecurity
                    Does not verify the authenticity of the peer
                    (you don't need to accept the key with ssh first)
                    Use it at your own risks

Open in new window

For example, this call will put the output into an HTML file that loads perfectly into Excel:
mediainfo --Output=HTML --Logfile=MIoutput.html InputFile.mp4

Open in new window

It would be a relatively simple matter to write a program/script that would loop through a folder containing hundreds of video files (and even recurse into subfolders) calling the MediaInfo CLI along the way. You may use any scripting/programming language you want, as long as it can call an EXE (I would use AutoHotkey with its RunWait statement, but use whatever you prefer). It would also be a simple matter to have the program look for only the subset of the fields that you want, outputting only those to the final CSV or XLS/XLSX file. Regards, Joe
Aaaah, good.  Thanks Joe.  I didn't really want to install MediaInfo in case it left a bunch of clutter after I uninstalled it, so I wasn't able to test the command line out for myself.  I was only going by the FAQ that bemonaed the limited command line options.  In fact, they seem to be quite comprehensive.  It looks like the programmer left out CSV as an output format for some reason, and it could be deliberate because some of the values may contain commas that would mess up the columns if opened in Excel.

Looping through video and/or audio files in a folder and all sub-folders is easy enough using a standard batch file.  You would use the CALL command to run the program and pause processing, but parsing the results to a usable CSV or tab Delimited format that loads correctly into Excel is something that would have to be experimented with.

I might just bite the bullet and install MediaInfo to tinker with in the next couple of days.

Update:  I downloaded the Command Line version of the program and I immediately see that there is a template for CSV and that the output can be filtered using some of the switches.  It will take me a while to look more carefully at the program and test the output formats.
> there is a template for CSV

I haven't looked into it, but I noticed all these CSV files in the \Plugin\Custom\ folder after unzipping the CLI/64-bit download:

en.Example.csv
en.Example_HTML.csv
Example.csv
Example_HTML.csv
fr.Example.csv
it.Esempio.csv
it.Esempio_HTML.csv
Table by fields, compact (HTML).csv
Table by fields, short (HTML).csv
Table by fields, standard (HTML).csv
Table by fields, verbose (HTML).csv
Table by streams, compact (HTML).csv
Table by streams, short (HTML).csv
Table by streams, standard (HTML).csv
Table by streams, verbose (HTML).csv
XML.csv
zzz_Contrib - Dusil (HTML).csv

Looks interesting! Regards, Joe
Avatar of SpaceCoastLife

ASKER

Probably should have clarified I'm not a programmer so command line stuff is out, Also, this is not a one-time effort. My hope is to come up with a procedure I can use over and over.
> My hope is to come up with a procedure I can use over and over.

Then a program/script is the way to go. Here's the output from a call to the MediaInfo CLI with the --Full option on an MP4 file:
General
Complete name             : c:\temp\test.mp4
Format                    : MPEG-4
Format profile            : Base Media
Codec ID                  : isom (isom/iso2/avc1/mp41)
File size                 : 139 KiB
Duration                  : 7 s 0 ms
Overall bit rate mode     : Variable
Overall bit rate          : 163 kb/s
Writing application       : Lavf56.40.101

Video
ID                        : 1
Format                    : AVC
Format/Info               : Advanced Video Codec
Format profile            : Baseline@L3
Format settings, CABAC    : No
Format settings, ReFrames : 2 frames
Codec ID                  : avc1
Codec ID/Info             : Advanced Video Coding
Duration                  : 7 s 0 ms
Bit rate                  : 85.1 kb/s
Width                     : 1 018 pixels
Height                    : 860 pixels
Display aspect ratio      : 1.184
Frame rate mode           : Constant
Frame rate                : 25.000 FPS
Color space               : YUV
Chroma subsampling        : 4:2:0
Bit depth                 : 8 bits
Scan type                 : Progressive
Bits/(Pixel*Frame)        : 0.004
Stream size               : 72.7 KiB (52%)
Writing library           : x264 core 146 r2555 0c21480
Encoding settings         : cabac=0 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=6 / 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=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=125 / keyint_min=12 / scenecut=40 / intra_refresh=0 / rc_lookahead=30 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

Audio
ID                        : 2
Format                    : AAC
Format/Info               : Advanced Audio Codec
Format profile            : LC
Codec ID                  : 40
Duration                  : 6 s 424 ms
Duration_LastFrame        : -9 ms
Bit rate mode             : Variable
Bit rate                  : 77.9 kb/s
Maximum bit rate          : 96.0 kb/s
Channel(s)                : 2 channels
Channel(s)_Original       : 1 channel
Channel positions         : Front: C
Sampling rate             : 44.1 kHz
Frame rate                : 43.066 FPS (1024 spf)
Compression mode          : Lossy
Stream size               : 61.1 KiB (44%)
Default                   : Yes
Alternate group           : 1

Open in new window

Which of those fields do you want in the Excel spreadsheet?
Field list I'd like to export from MediaInfo to Excel:

2: Complete Name
6: File size
22: Bit rate
23: Width
24: Height
25: Display Aspect ratio
39: Format
46: Bit rate
48: Channels
Thanks everyone for the guidance
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help
You're welcome — happy to help. Regards, Joe