I’ve been trying to implement a renaming method to handle music videos through Picard. I initially thought it’d be a s simply as using the is_video scripting function, but it proved to be inconsistent. Initially I assumed my problems were early implementation issues, and I just kept trying again every few updates, with no success.
I’m using $if($is_video(),/music Videos/,) at the beginning of my naming script to just determine a different root folder to use, but follow all the rest of the same structure. What I’ve found is a mix of videos that will get flagged correctly and others that miss this flag and get treated like audio files.
What’s caused me concern is that I’ve just found a few plain old MP3 files, with no video tracks confirmed with MediaInfo, in the Music Videos directory. The only thing to note is that they’re MP3s from a DVD-Video source per MusicBrainz metadata.
The link to the original python script referenced here appears dead, [PICARD-1594] Provide $is_video() / $is_audio scripting functions - MetaBrainz JIRA , but what exactly is this function doing under the hood? From all my uses, it appears nearly non-functional.
What could I be doing wrong with the usage of this function? Does this function work? If not, should this be submitted as a bug report?
The detection of video files is mostly file type and extension based. What file format does Picard show for those files in the Info dialog?
For actual MP3 files Picard would not set the video flag.
Looking at the Picard code, there is a hidden metadata variable
~video which indicates that a file is a video or not.
This can be set either from MusicBrainz (where a track metadata is flagged as being a video) or based on the file format (as stated by Philipp @outsidecontext).
Now for a specific album of a specific name by a specific artist (or in Musicbrainz terms - a release group) there can be multiple releases which have different numbers of tracks, or indeed there could be a special release where (say) bonus tracks 13 and 14 are audio tracks, and another special release where bonus tracks 13 and 14 are video tracks.
I am hypothesising that this might well mean that if Picard selects the wrong release, then mp3 files will be flagged as videos. What we need are specific examples of filenames and release-group / release MBIDs so that we can work out what is actually happening here (rather than just guess as I just did).
But I would say that:
When Picard is automatically selecting a release, we should use the file-types to determine whether they are videos and only select from those releases which have matching audio/video profiles. And the choice of alternative releases from the same release group that the user can select with a right click should prioritise (above the line) those that match the audio/video profile (in the same way as we prioritise those with the correct number of tracks and relegate (below the line) those with a different number of tracks.
We should consider under what circumstances we should set the
~video flag based on MusicBrainz metadata and tweak the Picard code accordingly. My own suggestion would be to use the filetype to set the flag if a file is associated with the track, and to use the metabrainz flag only if there is no file associated with the track. (This would mean careful coding to set/clear the flag as files are associated / dissociated with the track and retaining the original musicbrainz flag in a separate location to use when a file is dissociated. Also we would have to decide what logic to use in the abnormal situation that more than one file is associated with a track.)
P.S. I appreciate that the OP was using $is_video in a file-naming-script for testing purposes, however I would like to remind everyone that track-specific metadata / functions (like
%~video%) should NOT be used in the directory portion of a file-naming-script without fully understanding the implications because it will result in files being spread across multiple directories. By counter-example, it is ok to use this in the file-name part of a script to rename the file to include e.g. “[Video]” towards the end of the filename.
P.P.S. It would be a non-trivial enhancement, but I would suggest that we might want to enhance the file-naming-script editor to recognise the use of track-specific metadata or functions in the directory part and pop-up a flag / message to warn the user of this.