INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: any support for embedded video tagging?  (Read 2048 times)

Tylor

  • Recent member
  • *
  • Posts: 8
any support for embedded video tagging?
« on: May 22, 2013, 11:00:49 pm »

Hi all,

I searched the forums a bit before posting.  I saw a fewer older posts about this topic, but nothing recent.  Is there any support with MC18 to do embedded video file tagging (vs. the external sidecar)?

I'm still living in a world where I'm managing multiple libraries of files for different purposes ... and trying to get multiple software programs to play nicely.  Currently I've created a separate library of video files which I manage via iTunes expressly to sync w/ my apple devices.  Would be great if I could use MC18 as my metadata manager for this library as well... as updating the metadata in MC18 is really easy.  Just that the metadata for video files isn't portable if it just exists in the database or external sidecar.  Correct me if I'm wrong.

Thanks!

Tylor
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: any support for embedded video tagging?
« Reply #1 on: May 22, 2013, 11:09:36 pm »

Hi all,

I searched the forums a bit before posting.  I saw a fewer older posts about this topic, but nothing recent.  Is there any support with MC18 to do embedded video file tagging (vs. the external sidecar)?

A little.

The standards for in-file tags for video are very loosely designed or non-existent.  MC does try to read tags, where they're available, and assign them to rational spots on import.  I think (I'm reasonably sure) it can do some limited tag writing to MP4 and maybe MKV files, but I'm not sure on the details.

The XML metadata in the Sidecars is, of course, quite portable if you put in a bit of elbow grease (and know a scripting language that can read XML).  But that may not work depending on your needs (and it wouldn't work without a bit of work with iTunes).
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Andyd

  • Recent member
  • *
  • Posts: 45
Re: any support for embedded video tagging?
« Reply #2 on: May 23, 2013, 05:23:29 pm »

I was hoping this was possible myself. But its not sounding too positive.
I have about 800ish music videos that I would like to be tagged like my regular music collection as I use multiple programs as well.
Logged

Tylor

  • Recent member
  • *
  • Posts: 8
Re: any support for embedded video tagging?
« Reply #3 on: May 23, 2013, 06:05:08 pm »

Ya, I guess "portable" wasn't the right phrase. It's more of a matter if other programs can use the data natively.

I can perhaps play w python a bit to see if I can put something together to tag the files myself. Looks like there are a couple of modules out there that can be helpful. Was hoping to avoid another project :)
Logged

Andyd

  • Recent member
  • *
  • Posts: 45
Re: any support for embedded video tagging?
« Reply #4 on: May 23, 2013, 07:15:58 pm »

Ya, I guess "portable" wasn't the right phrase. It's more of a matter if other programs can use the data natively.

I can perhaps play w python a bit to see if I can put something together to tag the files myself. Looks like there are a couple of modules out there that can be helpful. Was hoping to avoid another project :)

Whatever you do, don't use the program 'Tag and Rename'. Although I use this exclusively for tagging my music and it works great. It will display video files as well but if you try to tag them with it, it renders the files unplayable :-(

If you have any luck with the videos please let me know.
Thanks.
Logged

syndromeofadown

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 805
Re: any support for embedded video tagging?
« Reply #5 on: May 23, 2013, 07:36:44 pm »

Quote
Whatever you do, don't use the program 'Tag and Rename'. Although I use this exclusively for tagging my music and it works great. It will display video files as well but if you try to tag them with it, it renders the files unplayable

I use tag and rename regularity to remove all tags from videos. Never had a problem. I run every video i get though it to clean them up.

After they have been cleaned i get MC to add the fields i need (not embedded) by automatically parsing the filename of my intelligently named videos.
Logged

Andyd

  • Recent member
  • *
  • Posts: 45
Re: any support for embedded video tagging?
« Reply #6 on: May 24, 2013, 06:35:26 am »

I use tag and rename regularity to remove all tags from videos. Never had a problem. I run every video i get though it to clean them up.

After they have been cleaned i get MC to add the fields i need (not embedded) by automatically parsing the filename of my intelligently named videos.


You're 'removing'.... I'm talking about trying to embed them with T&R...

And I've noticed some videos that I have acquired (that I have not ripped myself) have tags.
Sooooo, how did they get there in the first place and why can't we do it and make them work with JR?
Logged

Tylor

  • Recent member
  • *
  • Posts: 8
Re: any support for embedded video tagging?
« Reply #7 on: May 29, 2013, 04:53:07 pm »

Any forum rules for posting code?

I have a simple python program that will take a video (mp4) file, parse the sidecar XML, and apply known simple tags (such as Name, Genre, Description, Date, etc.) to the mp4.  Supports cover art as well.  Code uses mutagen (a public third-party module) for tag manipulation, but otherwise standard python modules.

Thought I'd check before I upload.
Logged

Andyd

  • Recent member
  • *
  • Posts: 45
Re: any support for embedded video tagging?
« Reply #8 on: May 30, 2013, 06:17:27 am »

I don't think I have any mp4 videos (except some others I have downloaded from youtube)
Just about all of my music videos are mkv or mpg.... can you do anything with these?

I decided to do a quick test... The Tag and Rename program I mention above that I used tagged an mp4 easily without ruining the file like it did with my mpgs.
Decided to check a couple others ... the mkv or an avi file do not even show up in T&R
And as usual it let's me tag an mpg but renders the file unreadable.... however the damage can be undone by removing the tags.

So it seems anything but mp4 may not be tagable???
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: any support for embedded video tagging?
« Reply #9 on: May 30, 2013, 09:52:18 am »

MKV has tagging support.

The problem isn't so much the container formats (well, except MPG and AVI).  The problem is that there is no clear "ID3-style" system for tagging that is well defined.  So, if MC set them, it is likely that only MC could read them properly (and it could cause compatability problems with other players, conceivably).

I'd like to see improvements here too from MC, and I don't know what it can already do very clearly.

A comment from one of the JRiver folks would be helpful...
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Andyd

  • Recent member
  • *
  • Posts: 45
Re: any support for embedded video tagging?
« Reply #10 on: May 30, 2013, 12:55:12 pm »

Just a quick note. I tried tagging an mpg with Windows Explorer.
If you right click and select properties there is an ID tab. It will let you do things like artist, title, album, track ect. as well as album art.
But unfortunately just like Tag&Rename it makes the file unplayable. As when tagging with T&R, removing the tags make them playable once again.
WTF is the deal with this?
Logged

Tylor

  • Recent member
  • *
  • Posts: 8
Re: any support for embedded video tagging?
« Reply #11 on: June 03, 2013, 08:35:07 pm »

Well, I didn't get tagging to work w/ older mpg files, but if you have mp4/m4v video files and you want to manually tag them by pulling data out of the sidecar file, here's a script that should work.  Also supports adding/embedding cover art.  Should be pretty self-explanatory, couple of bits of twisty logic to handle date conversion...

#!/bin/env python
import mutagen
from mutagen.mp4 import *
import xml.etree.ElementTree as ET
import sys
import string
import optparse

# Modified Julian to DMY calculation with an addition of 2415019
# algorithm from http://www.hermetic.ch/cal_stud/jdn.htm
def cvt_serial_date(serial_date):
    l = int(serial_date) + 68569 + 2415019
    n = ( 4 * l ) / 146097
    l = l - (( 146097 * n + 3 ) / 4)
    i = ( 4000 * ( l + 1 ) ) / 1461001
    l = l - (( 1461 * i ) / 4) + 31
    j = ( 80 * l ) / 2447
    day = l - (( 2447 * j ) / 80)
    l = j / 11
    month = j + 2 - ( 12 * l )
    year = 100 * ( n - 49 ) + i + l
    return year, month, day

# parse XML file and update video file w/ known tags
def update_video_tags(video_file, xml_file):
    modified = False

    # parse the XML file
    xml = ET.parse(xml_file)

    # parse/open the video file w/ mutagen
    video = mutagen.File(video_file)

    tag_map = {
        'Genre': '\xa9gen',
        'Description': 'desc',
        'Name': '\xa9nam',
        'Keywords': 'keyw',
        'Date': '\xa9day',
    }

    # traverse each field, matching against known tags
    for field in xml.findall('./Item/Field'):
        name = field.attrib.get('Name', '')
        value = field.text
        if name in tag_map:
            tag_key = tag_map[name]

            # special handling for date to convert
            if name == 'Date':
                y,m,d = cvt_serial_date(value)
                value = [str(y)]
            # otherwise... handle lists
            elif ';' in value:
                fields = value.split(';')
                value = map(string.strip, fields)

            # update tag if different
            if video.get(tag_key) != value:
                print 'adding tag: %s w/ value %s' % (tag_key, value)
                video[tag_key] = value
                modified = True

    # save changes (if changes made)
    if modified:
        video.save()

def add_art(video_file, cover_file):

    # parse/open the video file w/ mutagen
    video = mutagen.File(video_file)

    # load cover art
    covr = []
    data = open(cover_file, 'rb').read()
    if cover_file.endswith('png'):
        covr.append(MP4Cover(data, MP4Cover.FORMAT_PNG))
    else:
        covr.append(MP4Cover(data, MP4Cover.FORMAT_JPEG))
    video['covr'] = covr

    # save changes (if changes made)
    video.save()

## MAIN
if __name__ == '__main__':

    parser = optparse.OptionParser(
        option_list = [
            optparse.make_option("-x", "--xml", action="store", type="string",
                help="XML file", default=None),
            optparse.make_option("-v", "--video", help="video file",
                default=None),
            optparse.make_option("-c", "--cover", help="cover art jpg file",
                default=None),
        ])

    (options, args) = parser.parse_args()

    if not options.xml or not options.video:
        print 'missing required xml or video parameter'
        sys.exit(1)

    update_video_tags(options.video, options.xml)
    if options.cover:
        add_art(options.video, options.cover)
Logged
Pages: [1]   Go Up