Question

=== BACKGROUND ===

Some time ago I ripped a lot of music from an internet radio station. Unfortunately something seems to have went wrong, since the length of most files is displayed as being several hours, but they started playing at the correct position.

Example: If a file is really 3 minutes long and it would be displayed as 3 hours, playback would start at 2 hours and 57 minutes.

Before I upgraded my system, gstreamer was in an older version and its behaviour would be as described above, so I didn't pay too much attention. Now I have a new version of gstreamer which cannot handle these files correctly: It "plays" the whole initial offset.

=== /BACKGROUND ===

So here is my question: How is it possible to modify an OGG/Vorbis file in order to get rid of useless initial offsets? Although I tried several tag-edit programs, none of them would allow me to edit these values. (Interestingly enough easytag will display me both times, but write the wrong one...)

Was it helpful?

Solution

I finally found a solution! Although it wasn't quite what I expected...

After trying several other options I ended up with the following code:

#!/bin/sh

cd "${1}"

OUTDIR="../`basename "${1}"`.new"

IFS="
"
find . -wholename '*.ogg' | while read filepath;
do
    # Create destination directory
    mkdir -p "${OUTDIR}/`dirname "${filepath}"`"

    # Convert OGG to OGG
    avconv -i "${filepath}" -f ogg -acodec libvorbis -vn "${OUTDIR}/${filepath}"

    # Copy tags
    vorbiscomment -el "${filepath}" | vorbiscomment -ew "${OUTDIR}/${filepath}"
done

This code recursively reencodes all OGG files and then copies all vorbis comments. It's not a very efficient solution, but it works nevertheless...

What the problem was: I guess it has something to do with the output of ogginfo:

...
New logical stream (#1, serial: 74a4ca90): type vorbis
WARNING: Vorbis stream 1 does not have headers correctly framed. Terminal header page contains additional packets or has non-zero granulepos
Vorbis headers parsed for stream 1, information follows... Version: 0
Vendor: Xiph.Org libVorbis I 20101101 (Schaufenugget)
...

Which disappears after reencoding the file...

At the rate at which I'm currently encoding it will probably take several hours until my whole media library will be completely reencoded... but at least I verified with several samples that it works :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top