Skip to content

Latest commit

 

History

History
181 lines (132 loc) · 4.08 KB

multimedia.md

File metadata and controls

181 lines (132 loc) · 4.08 KB

MultiMedia

Media file analysis, editing, transcoding and conversions.

Get the resolution and other details like codec for a video file

ffmpeg -i "$file"

or

ffprobe "$file"

Transcode mkv into standard mp4 for smart TVs to play

ffmpeg -i "input.mkv" "output.mp4"

There is an automated script in the DevOps-Bash-tools repo's media/ directory to iterate many files easily:

mkv_to_mp4.sh *.mkv

or find all mkv files recursively under the given directory and convert them (retains originals), in this case the $pwd denoted by a dot:

mkv_to_mp4.sh .

Video Clipping

Create a clip from a video file using ffmpeg args:

  • -ss <offset> and -to <duration> where duration is integer seconds or HH:MM:SS format
  • -c copy - -c specifies codec, copy is quick and cheap codec compared to transcoding
ffmpeg -i input_vid.mp4 -ss 00:08:35.0 -t 72 -c copy output_vid.mp4

or using time format -to 00:01:12 which is the same as 72 seconds from offset start.

Inspect Media File

ffprobe $file
exiftool $file
mediainfo $file
mediainfo --fullscan $file
avprobe $file
mplayer -vo null -ao null -identify -frames 0 $file
tovid id $file

MP3 metadata editing

Use the id3v2 program to set metadata on mp3 files.

Useful to group a bunch of mp3 files for an audiobook.

Set the --author / -a and --album / -A tags at once so Mac's Books.app groups them properly into one audiobook:

id3v2 -a "MyAuthor" -A "MyAlbum" *.mp3

The scripts mp3_set_artist.sh and mp3_set_album.sh in the DevOps-Bash-tools repo's media/ directory make it slightly easier.

Set the --track number for each mp3 file, so they play in the right order:

i=0
for x in *.mp3; do
  ((i+=1))
  id3v2 -T $i "$x"
done

The scripts mp3_set_track_order.sh and mp3_set_track_name.sh in the DevOps-Bash-tools repo's media/ directory make this slightly easier.

Recursively set Artist/Album - XXX: Danger, use only in an audiobook subdirectory, otherwise it'll ruin the metadata of your MP3 library!

find . -maxdepth 2 -iname '*.mp3' |
{
  i=0
  while read mp3; do
    ((i+=1))
    id3v2 -a "MyAuthor" -A "MyAlbum" "$mp3"
  done
}

Recursively set Track Order - for subdirectories eg. CD1, CD2 etc... XXX: use with care - misused at the top it'd ruin your MP3 library's metadata:

find . -maxdepth 2 -iname '*.mp3' |
{
  i=0
  while read mp3; do
    ((i+=1))
    id3v2 -T $i "$mp3"
  done
}

MediaBox Setup

This is old from 2010 and probably needs some updates:

aptitude install nvidia-glx-173
aptitude -y purge samba
aptitude -y purge bluez bluetooth gnome-bluetooth bluez-utils
aptitude -y purge cups bluez-cups cups-driver-gutenprint foo2zjs foomatic-db foomatic-db-engine ghostscript-cups hpijs hplip openprinting-ppds pxljr splix
apt-get -y purge evolution evolution-common
aptitude -y purge openssh-server
dpkg -l | grep openoffice | awk '{print $2}' | xargs aptitude -y purge language-support-en language-support-writing-en python-uno
aptitude -y install sysstat
aptitude -y install unrar
aptitude -y install libdvdread4
/usr/share/doc/libdvdread4/install-css.sh

Remote control

as root:

mkdir /var/run/lirc # it wouldn't create it and it wouldn't start without it on ubuntu
aptitude -y install dvb-utils

Cyberlink remote shows us as /dev/input/event3 according to google.

Can cat that or after installing dvb-utils, can do:

evtest /dev/input/event3

except dvb-utils has no install candidate and tells you to instead get dvb-apps which is already installed and doesn't have evtest, only the c file for it

less /proc/bus/input/devices

remote control is detected as a keyboard so a bunch of stuff just works out of the box. Should use xmodmap to add the remaining buttons to do things I want

Ported from private Knowledge Base pages 2010+