DLNA and Video, continued

My ixquick and DuckDuckGo search-fu have been remarkably unsuccessful in finding what metadata tags are commonly supported by DLNA servers, controllers and renderers. I even resorted to using Google for some searches but the results were not significantly different from those of ixquick.

Not knowing what DLNA can support nor what the Twonky server on the Western Digital MyCloud NAS supports nor what the various controllers, renderers and players I have access to this is basically shooting in the dark.

What Seems to Work
Between the built in player on the Twonky server, two DLNA apps on the Android phone and the Roku Media Player on the Roku2 I can check on how some M4V video tags are handled.

Tag Comment
title Twonky seems to use the file name unless this tag is found in the video.
date Twonky seems to use the file (create/modify?) date unless this tag is found and has at least the yyyy-mm-dd specified. It might also need the hour, minute and second time stamp. For example: “1933-02-02T11:00:00Z”
comment Between the Twonky server and the Roku Media Player app/channel on the Roku2 this seems to be the only tag that shows generic text metadata on a video.

What Does Not Work

Tag Comment
artist
description
genre
synopsis

In addition, while some thumbnails appear there are issues. For everything in my “Movies” folder the icon is of a FBI warning. Even for things I created myself and just placed there for testing. And if I put a paid for movie elsewhere on the server it gets just a screen show from a frame a little ways into the video. There are a bunch of instructions on the web for setting up thumbnails for Twonky but they don’t seem to work on my setup.

Working With Tags

EasyTag – For audio and, surprising to me, some video tagging the EasyTag X Windows app works well. On first try it was able to automatically fix the composer field in all the audio files. It also handles the “comment” and “title” tags on M4V video files. It claims to handle the “date” tag too but I had less success there. I installed this through the homebrew package manager for Mac.

MetaZ – Fast and easy editing of things like title, date, etc. And it accesses a pretty good database of information for movies. But the description and synopsis tags it puts things into does not work with my Twonky Server/Roku Media Player. Also it corrupted at least one file that I used it on so I am likely to only use it for movie data lookup purposes rather than for actually tagging videos. MetaZ is available through GitHub. Last update is a couple of years old.

ffmpeg – This Unix command line utility is way too complicated to remember how to easily use it but is quite powerful. I don’t recall how I installed mine but it can be installed through the homebrew package manager on the Mac. At present it is the tool I am using. It seems to drop any thumbnail (movie poster) that MetaZ adds but is really useful for examining or setting other metadata. Since thumbnails embedded in the video or in an external file don’t work on my setup that is not a big loss.

To make it easy for the three tags that I found work I’ve created a little script:

#! /bin/bash

#
# Script to make it easier to munge meta data on videos
#

if [ "${1}x" == "x" ] ; then
    echo "Need source file"
    exit
fi
INFILE="${1}"

if [ "${2}x" == "x" ] ; then
    OUTFILE="${INFILE}"
else
    OUTFILE="${2}"
fi

echo "IN: \"${INFILE}\""
echo "OUT: \"${OUTFILE}\""

#
#   Get defaults, mostly existing metadata
#
TITLE=$(basename "${OUTFILE}" ".${OUTFILE##*.}")
#TITLE=`ffmpeg -i "${INFILE}" 2>&1 | grep title | cut -d \: -f 2 | sed -e 's/^[[:space:]]*//'`
DATE=`ffmpeg -i "${INFILE}" 2>&1 | grep date | cut -d \: -f 2 | sed -e 's/^[[:space:]]*//'`
SYNOPSIS=`ffmpeg -i "${INFILE}" 2>&1 | grep comment | cut -d \: -f 2 | sed -e 's/^[[:space:]]*//'`

#
# Get supported metadata
#
read -p "Title (${TITLE})? " answer
if [ ! "${answer}x" == "x" ] ; then
    TITLE="${answer}"
fi

read -p "Year (e.g. 1933-02-02) (${DATE})? " answer
if [ ! "${answer}x" == "x" ] ; then
    DATE="${answer}T11:00:00Z"
fi

read -p "Synopsis (${SYNOPSIS})? " answer
if [ ! "${answer}x" == "x" ] ; then
    SYNOPSIS="${answer}"
fi

#
# Create copy with new metadata
#
TMPFILE="temp_$$.${OUTFILE##*.}"
ffmpeg -i "${INFILE}" -metadata "title=${TITLE}" -metadata "comment=${SYNOPSIS}" -metadata "date=${DATE}" -vcodec copy -acodec copy "${TMPFILE}"

#
# Swap old file for new
#
mv -f "${INFILE}" "${INFILE}.old"
mv -f "${TMPFILE}" "${OUTFILE}"