MediaArea / MediaInfo

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://MediaArea.net/MediaInfo
BSD 2-Clause "Simplified" License
1.39k stars 160 forks source link

Wrong file format detection when using full path #543

Open rurQ opened 3 years ago

rurQ commented 3 years ago

In a directory of JPEGs with incremental filenames (imgXXXX.jpg) accesing them directly by filename name gives proper results. However if a filename is given with its full path it is detected as a video. The outcome is an empty result with specific output i.e. --Output=Image;%Width%x%Height%. It might be treated as a sequence of files, because of the reported file size in this case is much larger and MediaInfo also shows CompleteName_Last property. Issue found on Win 7 SP1 x64 and XP SP3. Puting doublequotes in the file path doesn't help.

C:\a\b>MediaInfo.exe img0005.jpg
General
Complete name                            : img0005.jpg
Format                                   : JPEG
File size                                : 34.7 KiB

Image
Format                                   : JPEG
Width                                    : 655 pixels
Height                                   : 500 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 34.7 KiB (100%)

C:\a\b>MediaInfo.exe c:\a\b\img0005.jpg
General
Complete name                            : c:\a\b\img0005.jpg
CompleteName_Last                        : c:\a\b\img0077.jpg
Format                                   : JPEG
File size                                : 4.72 MiB

Video
Format                                   : JPEG
Width                                    : 655 pixels
Height                                   : 500 pixels
Display aspect ratio                     : 4:3
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 4.72 MiB (100%)
JeromeMartinez commented 3 years ago

This behavior is on purpose, some of our sponsors using this file naming scheme for video content (this is the reason you see "Video"). With the command line, you can use --File_TestContinuousFileNames=0 for deactivating this behavior.

We wish to find for doing the difference between a sequence of files from a video recorder and a sequence of files from a still picture recorder but didn't implement/found a good solution for catching the difference (maybe when we implement analyze of EXIF metadata in JPEG, if we can catch some specific still image data like recording date/time)

rurQ commented 3 years ago

Hello Jerôme, Interesting, I would have never guessed that, but I do see the point in it. Still it would be good to specify this CLI switch (alongside with other secret ones) in the help file. Sooner or later someone else will get confused as I was. About the JPEG - one can never be sure there's EXIF data in every file. Fortunately most image/video capturing devices implement some metadata. My suggestion to differentiate a video from a still image would be to make some kind of assumption, what would be the expected file size based on its resolution and compression parameters, some kind of a critical file size. I don't know what kind of files are Your sponsors dealing with, but in general still image requires less data than even a short a video of the same resolution. I did a simple check for a 128x128px random RGB noise JPEG image and found it won't get any higher than 48kB for that pixel area on the highest quality setting. Very lame approach, but maybe worth testing ? I appreciate Your help, keep up the good work.

digitensions commented 2 years ago

With the command line, you can use --File_TestContinuousFileNames=0 for deactivating this behavior.

Does this flag also work for MediaConch policy checks when a DPX sequence returns a Video tracktype instead of an Image tracktype? We have some DPX sequence policy failures for the following rules when a client checks the DPX within the sequence, but it passes when the DPX is isolated from the sequence:

rule name="General/ImageCount is 1" value="ImageCount" tracktype="General" occurrence="*" operator="="1
rule name="Total image element file size" value="StreamSize" tracktype="Image" occurrence="*" operator="exists"

Apologies if I should be asking this in MediaConch github. I can run it over there too. Thank you!

JeromeMartinez commented 2 years ago

Does this flag also work for MediaConch policy checks when a DPX sequence returns a Video tracktype instead of an Image tracktype?

Yes. And your policy should pass.