2

Apple's Photo.app has no problem playing the audio from some videos (for example, videos recorded by an iPhone). But it does not play the audio from videos created by an Olympus SZ-31MR digital camera.

These videos do play within Photos, but they are silent.

When played in Quicktime Player (and VLC), the audio plays correctly.

According to Quicktime Player, videos from this camera are encoded as "H.264, 1920 × 1080, Millions; 16-bit Integer (Little Endian), Stereo, 32.000 kHz"

This is in OS X El Capitan (10.11.2) and Photos.app 1.3 (350.23.0), but the problem is not new. This thread on discussions.apple.com claims the problem is the audio codec used by the Olympus camera.

Is there a way in which I can play these videos and get sound, without having to find the individual video files and open them in Quicktime.app? Any of the following solutions would be acceptable:

  1. Some kind of install (a Quicktime plugin?) that fixes the behaviour in Photos.
  2. An alternative photo browser that can import (or view in place) the Photos library and which can play the audio in these videos. (I've tried Lyn, but that has the same behaviour as Photos.)
  3. Some way of transcoding these videos so that the audio plays in Photos. I have lots of videos and import new videos regularly, so a convenient interface would be important here.
1

(Answering my own question.)

The problem is that the Olympus SZ-31MR encodes its audio as signed 16-bit PCM. This audio format is not supported by Photos. So the audio needs to be transcoded in order to play from Photos.

The command-line program ffmpeg can transcode audio streams while leaving the video streams unchanged. For example, here's how to transcode the audio to Apple Lossless (ALAC) and copy the video:

$ ffmpeg -i input.mov -vcodec copy -acodec alac output.mov

Experimentally, it seems that Photos doesn't mind if I edit the videos in its library, so here's a shell script that automates transcoding the Olympus's 16-bit PCM to Photos-compatible ALAC:

#!/bin/sh
# Convert movies in Photos library from 16-bit little-endian PCM to
# Apple Lossless.

set -e

# Location of Photos library
PHOTOS=~/"Pictures/Photos Library.photoslibrary/Masters"

# Directory for movie backups
BACKUPDIR=~/movie-backups
mkdir -p "$BACKUPDIR"

find "$PHOTOS" -name '*.MOV' | while read MOV; do
  if ffprobe -v fatal -show_streams -select_streams a -of flat -i "$MOV" |
    grep -q 'codec_name="pcm_s16le"'
  then
    echo "Transcoding $MOV..."
    BACKUP=$BACKUPDIR/$(echo "$MOV" | sed 's+_+__+g;s+/+_+g')
    TMP=$BACKUPDIR/tmp.mov
    ffmpeg -v fatal -y -nostdin -i "$MOV" -vcodec copy -acodec alac "$TMP"
    mv -- "$MOV" "$BACKUP"
    mv -- "$TMP" "$MOV"
  fi
done

This script is careful to keep the original movies in a backup directory in case something goes wrong, and it uses set -e and ffmpeg -v fatal to avoid continuing after an error, but it does overwrite the movies in the Photos library, so use it at your own risk.

  • You could also use the built-in afconvert program. There's a guide here macworld.com/article/1138554/105audioterm.html – rptb1 Dec 22 '15 at 15:03
  • @rptb1: Can you say why you recommend afconvert? Is it better than ffmpeg in some way? Also, I can't figure out how to use afconvert to do what I want. Sure, I can run afconvert -f adts input.mov output.mov, but the output only contains the audio track. I need the video as well. – Gareth Rees Dec 22 '15 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .