The Living Thing / Notebooks :

Media metadata management, transcoding and editing

Cat and Girl: XML is Quetzlcoatl

I make music and DJ, and I would like to bulk edit and search my media using my own criteria, especially when it comes to dealing with the crappy media metadata that other artists give me with their tracks. In general I am interested in managing the affiliated artwork and various media artefacts in bulk, en masse and without paying Adobe to waste my hard disk space with their nonsense software.

See also machine listening, playing music.

Transcoding

Technical details of converting AV formats from whatever you have, to whatever you need to use.

Check with your local jurisdiction’s intellectual property laws before doing any of these.

See also remix, innovation.

Streaming

Ant provides open-source WebRTC streaming.

rip web videos

Remember kids, for fair use only!

youtube-dl is an incredible script that (despite the name) downloads not just youtube videos but whole playlists of videos from many many websites, setting up transcoding etc for offline use.

rip VCDS

Rip VCDs because copying the files doesn’t work. (See also ripping VCD to various formats) Two choices. Firstly, using Mencoder which is ubiquitous but ugly.

$ mplayer vcd://  # tells you how many tracks. rip desired ones:
$ for i in 2 3 4 5 6; do
>   mencoder vcd://$i -oac lavc -ovc lavc -o track_$i.avi ;
>   done

Depending on where you want to play it, the following non-re-encoding step might be more hi-fi:

$ mplayer vcd://2 -dumpstream -dumpfile filename.mpg  # No re-encoding

On the other hand, you might want to play this on a mac, which won’t work with either of the above steps without specialist software, so you’ll need to re-encode. See FFMPEG for that, since I couldn’t make it work with Mencoder.

Alternatively, use a specialist vcd ripper, such as vxdxrip in the vcdimager system.

FFMPEG

ffmpeg is handy for video, or extracting audio from video, or whatever other permutation of these ingredients you wish.

Documentation is not so much abstruse, as requiring knowledge of the minor implementation details video formats which is one of the most boring domains of human endeavour imaginable, and something that only patent trolls and sometimes engineers are paid enough to care about. Thankfully we have copy-pasta.

FFMPEG is conservative in its default install under homebrew, skipping anything that might conceivably infringe upon any patent in any jurisdiction, or anything that sounds like too much effort; you might want something more expansive, like:

brew install ffmpeg \
    --with-librsvg \
    --with-fdk-aac \
    --with-libsoxr \
    --with-libvorbis \
    --with-openh264

or even

brew install ffmpeg --with-all

If you wish to salvage pure audio for your sampling (up to you to ensure this is legal in your jurisdiction) by getting rid of the video track:

ffmpeg -i mangled_file.m4a -acodec copy -vn plain_audio_file.m4a

Or replace a video soundtrack:

ffmpeg -i v.mp4 -i a.wav -c:v copy -map 0:v:0 -map 1:a:0 -shortest new.mp4

Or to stitch photos to video for making animated GIFs:

ffmpeg -framerate 5 -start_number 1234 -i IMG_%04d.JPG \
    -c:v libx264 -pix_fmt yuv420p -vf scale=1920:-2:flags=lanczos \
    -crf 20 -preset slow -c:a copy ../something.m4v

There is a wiki for each major format, e.g. AAC audio and H.264 video.

There is a dummies’ guide.

Using these I have stitched together a workflow for, e.g. converting annoying camera video into something modern:

$ for i in 2 3 4 5 6 7 8 9 10 11 12 13; do
> ffmpeg -i filename_$i.avi \
    -c:v libx264 -preset slower -crf 22 \
    -c:a libfdk_aac -vbr 5 \
    filename_$i.mp4;
> done

Normalizing is easiest with wrapper script ffmpeg-normalize.

Advanced class: ffmpeg includes a programmatic control from ZeroMQ, so you can dynamically control filters while, e.g. playing video. There are controversies about implementation.

Converting animated GIFs to movies

ffmpeg -i input.gif -b:v 0 -crf 25 output.mp4

You can also extract information about media using ffprobe. This is designed to be easy to parse programatically, outputting specific values or parseable JSON or all manner of other useful stuff.

Images

see image editing

Misc

PDFs

See PDFs.

editing/annotating metadata

photos

exiftool, exiv2 seem to be popular media manipulation libraries. pyexiv2 is a python binding. Digikam is a whole photo library and metadata management system.

Erasing metadata

Erase all (or most) of the explicit metadata from an image:

exiftool -all= filename.jpg

NB:

ExifTool is not guaranteed to remove metadata completely from a file when attempting to delete all metadata. For JPEG images, all APP segments (except Adobe APP14, which is not removed by default) and trailers are removed which effectively removes all metadata, but for other formats the results are less complete:

mat attempts to erase all metadata from everything it can handle.

Editing media

Free/libre video editors

Searching/indexing/analysing