Digital Media guide

This is advanced material on how to manage your own collection of media, whether it is photos and movies, or anything else. Have all of your media properly tagged and stored in Apple friendly formats. One of the main purpose of the article, is to give you  a way to TAG all of your media and supply it with useful information, because in digital millennium you should be able to search for things easily and tagging is essential to select desired media from collection.

Why tagging is important

This guide applies not only to OS X and iOS users. It may be of interest to any user who uses Linux or Windows. Apple introduces its media standards, and they are mostly MP4 and such based.

MP4 provides for great tagging abilities (and it integrates with Windows, too!). So it’s always nice to get rid of mkv, wav and such and always use more modern file formats.

Appliances and benefits:

  • Convert voice recordings by 3rd party apps and hardware to taggable, searchable format (multifon wav recordings to m4a)
  • Can browse media by tag: face, genre, release year, type: home video, movie, etc.
  • Portable: data is stored within files, not some proprietary library

Approaches to update metadata:

  • One time scripts to scan media library directory
  • Convert mkv to mp4 in flexget (or other downloaders): set exec command on download complete, run metadata update command with tvdb info (which is fetched by flex get). This is tricky: it can be done in config file only for direct downloads, for transmission downloads we need to pass the data from flexget to transmissions’ download complete handler. Good way – write csv file with flex get that torrent-download-complete script will read.
  • wmp does good with mp4 tags, it can also edit them!

This article is a hub! It contains both detailed information and many references to subpages.

Selected formats:

  • Videos:

    M4V for: downloaded movies, old home movies, MOV for: clips filmed on iPhone since they have GPS tag that we want to keep

  • Audio:

    M4A for: ripped CDs or converting from lossless to lossy, and converting from WAV (voice recordings), MP3 for anything else

Required software:

  • Command Line Tools for Xcode
  • HomeBrew
  • AtomicParsley can change mp4(m4v) metadata without reencoding or remixing files

Install everything required via HomeBrew:

Note: important to install ffmpeg with fdk-aac encoder, since it’s best codec for AAC audio encoding.


brew install ffmpeg --with-fdk-aac
brew install atomicparsley exiftool

Videos

General information on converting video files to our required formats

Before converting video files, we need to know whether their audio streams are those supported by our file formats of choice:
M4V video files audio codecs: AAC, etc – ffmpeg names: ac3, aac.


ffprobe -show_streams -select_streams a -print_format json -v quiet -hide_banner some.mkv

Next our approach is to convert or remix using ffmpeg. And then we can set more tags using AtomicParsley.

Note: On a Synology box, add LD_LIBRARY_PATH=/opt/lib followed by space, in front of ffmpeg command.

Convert .avi to .m4v

We know that the audio and video coding are not compatible with MP4 based container. Thus, let’s set our command for AVI to convert audio and video tracks to standard MP4 container codecs: audio to AAC, and video to MPEG4.


ffmpeg -i MVI_1539.AVI \
  -vcodec mpeg4 -c:a libfdk_aac \
  -metadata title="Dancing Bear" \
  -metadata comment="Title Created Using FFmpeg metadata tag" \
  hak5--0813--wochentliche-dosis-von-technolust--hd720p30.h264.mp4

Convert .mkv to .m4v

Convert MKV to M4V (MP4 based format which is readable by PS3 also) while retaining existing audio and video coding (only change container), mostly works for 90% of downloaded movies and tv series, it’s also FAST:


ffmpeg -i "file.mkv" \
  -vcodec copy -acodec copy 
  -metadata title="The Godfather part II" 
  -metadata comment="Title Created Using FFmpeg metadata tag"
  "The Godfather Part II.m4v"

Here is the gotcha for remaining 10%. Since we fetched info about streams, we know whether file contains appropriate codecs for container or not. It’s possible that the file contains a few supported and unsupported audio codecs (tracks). As such, we should select appropriate tracks by using “map” option of ffmpeg. Simply supply it at the end of above command:

-map 0.0 -map 0.1

This selects video track (0.0 is always its position) and the first audio track (0.1).
You should always use map option if there are unsupported tracks.
If you decide to include unsupported tracks, they should be converted to AAC:

      
ffmpeg -i Skyline.mkv \      
 -map 0:0 -map 0:1 -map 0:2 \        
 -c:v copy \         
 -c:a:0 copy \       
 -c:a:1 libfdk_aac \         
 Skyline.m4v         

In this example we keep video codec, while re-encoding second audio stream to AAC and leaving first audio stream intact.

Movies

Set mp4 atom so that iTunes knows these are Movie videos:


AtomicParsley file.mp4 --stik value=9

Home Videos

iTunes 11 introduces a new category to the Movies section for Home Videos, allowing users to more easily filter their own personal video content from the main movies listings.

I bet you have some home movies and you want to tag them as such, along with having ability to view them as “Home Movies” in iTunes.

Set our MP4 based video files as “Home Videos” using AtomicParsley:

AtomicParsley file.mp4 --stik value=0

TV Shows

Set our MP4 based video files as “TV Shows” using AtomicParsley:

AtomicParsley file.mp4 --stik value=10

Audio

Since we know that we are working with mp4 audio files, we will set specific tags when converting via ffmpeg

Voice Call Recordings

“`bash
ffmpeg -i call-2013-0524-1103-42.wav \
-c:a libfdk_aac \
-metadata author="Danila Vershinin" \
-metadata title="Conversation with +7927…" \
-metadata genre="Voice Memo" \
output222.m4a
“`

Perfect artwork

Embed artwork into mp4 and m4a files:

AtomicParsley S01E03.Guilty.720P.mp4 --artwork ../South\ Park/75897-5.jpg

Special cases

Let’s talk about what we’ve left out. And some special media which is not that common to reside in user storage devices:

Movies with subtitles shipped as .SRT files

Unfortunately, Playstation 3 does not support display of internetl .MP4 subtitles. In all other players you should be fine. Here is how you can embed .srt subtitle into .mp4 file:

ffmpeg -i "Ong-Bak.2003.1080p.BluRay.x264.anoXmous_.mp4" -sub_charenc CP1252 -i "Ong-Bak.2003.1080p.BluRay.x264.anoXmous_eng.srt" -map 0:v -map 0:a -c copy -map 1 -c:s:0 mov_text -metadata:s:s:0 language=eng output.mp4

WhatsApp audios in a video file

This is about audio recording which doesn’t have a video. We only want to convert it to an audio file by extracting the audio:

“`bash
ffmpeg -i “WhatsApp Audio 2021-09-19 at 03.34.13.mpeg” -vn -c:a copy “WhatsApp Audio 2021-09-19 at 03.34.13.mp3”
“`

Movies with advanced subtitles

That mainly applies to Japanese dorama fans. For now, stick to .mkv. By the way, you can tag mkv like this:

mkvpropedit Two.and.a.Half.Men.S01E01.720p.WEB-DL.AAC2.0.H.264-TB.mkv –edit info –set “title=The movie”

Podcasts downloaded by Synology

In this case you have to set media type to Podcasts and update all the metadata.

Some great podcasts:

http://feeds.feedburner.com/doctype/itunes
http://revision3.com/tekzilla/feed/mp4-hd30

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *