FileFlows icon indicating copy to clipboard operation
FileFlows copied to clipboard

Suggestion: identify file type

Open iamwoz opened this issue 2 years ago • 6 comments

Clarification: Create a DLL to identifiy file types with an enum. Then this could be used by plugins and could be used by the "Music Nodes: Convert to MP3" and detect if it is a video file. If its a video file it could treat this special case and make it less confusing for users needing to use a Video Nodes node vs a Music Nodes node.

eg. [Basic Nodes] Input File (video file) => [Music Nodes] Convert to MP3

music nodes could use this shared library to do if(FileType(file) == Video) extract audio from video file

other plugins etc could also take advantage of this aswell


Would it be possible to have a new block type in Flows that identifies file type? Then depending on match it can route the Flow appropriately (either call another Flow or have the block have as many outputs as required for specified matches?)

On Linux hosts this is obviously easy using the https://man7.org/linux/man-pages/man1/file.1.html command, seems like there's a few different options on Windows (I'm assuming there's a library somewhere).

In the first instance this could be an improvement of the File Extension block which allows more than two outputs (say I want to look for .mkv, .mp4, .avi and route them to different parts of the Flow). Eventually it would be great to not have to trust the file extension but to identify the file as Linux File command does.

iamwoz avatar Jun 06 '22 06:06 iamwoz

Be bit of a mission to come up with something. Needing to be cross-platform, would have to be something I wrote or a c# lib I could find. My day job we have a filetype library that we maintain (not my team), every growing list of files, not a 1 week and done kinda thing.

Quick google there's not a lot out there and just limited file types.

Identifying files isn't that difficult, magic numbers etc to look for, just the billion of file types out there.

Would be best to focus on certain files at first, videos, audio, pictures etc.

I just checked the docker, "file" is an unknown command in it.

So unless you have a few options

  1. install file on the docker images
  2. if you're using LInux and not docker, you're fine
  3. use file extensions for now.

You can just add a "File" flow then do the check and use the goto flow to go to other flows for processing, so that part is fine.

revenz avatar Jun 06 '22 06:06 revenz

Yeah as I was typing the suggestion I was think it was turning into a rabbit hole. Honestly for now I'd be super happy with just an improvement to the File Extension block that had more than two outputs (but again this is probably gonna be a big change for your UI?) ie.

  1. matches .mkv
  2. matches .avi
  3. matches .mp4
  4. doesn't match any

iamwoz avatar Jun 06 '22 07:06 iamwoz

https://forums.fileflows.com/showthread.php?tid=8

hey the script feature is useful!

Although I just saw a bug where the outputs aren't named in the Flow. I'll fix that in 0.7.1

revenz avatar Jun 06 '22 07:06 revenz

if only I had the skills!

iamwoz avatar Jun 06 '22 07:06 iamwoz

Meant it was handy I could share a script like this now :P

revenz avatar Jun 06 '22 08:06 revenz

Leaving this open and will look into making a node that has a ever-growing list of types it can identify. but this is a low priority for now, as the Script got you what you mostly wanted.

revenz avatar Jun 13 '22 03:06 revenz