Fixing Ogg Vorbis files with incorrectly framed headers

Tristan Miller <[email protected]> Thu, 27 Jul 2017 21:18:42 +0200
Newsgroups gmane.comp.multimedia.ogg.vorbis.general
Message-ID <[email protected]>
--===============1345799974213835165==
Content-Type: multipart/signed; micalg=pgp-sha512;
 boundary="Sig_/zj9QOWOd.JooOuEel7rGELk"; protocol="application/pgp-signature"

--Sig_/zj9QOWOd.JooOuEel7rGELk
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Greetings.

Possibly as the result of buggy tagging software, several hundred of my
Ogg Vorbis files exhibit the following warning when examined by ogginfo:

WARNING: Vorbis stream 1 does not have headers correctly framed.
Terminal header page contains additional packets or has non-zero
granulepos

Nonetheless, most media players can play these files without any
problem.  A notable exception is any player using the recently released
GStreamer 1.12.1 (see
<https://bugzilla.gnome.org/show_bug.cgi?id=3D784530>).  In fact, even
though my files were corrupted several years ago, I hadn't noticed
this until a few weeks ago when I upgraded GStreamer to the latest
version.

Can anyone advise me how I can fix my files short of re-encoding them?
I already tried using vorbiscomment to extract and then re-apply the
tags to the file.  In this case ogginfo no longer issues any warning
about the file, but GStreamer applications still refuse to play it, as
the following example demonstrates.  A sample corrupted file can be
obtained at <https://bugzilla.gnome.org/attachment.cgi?id=3D354903>.

$ ogginfo somefile.ogg
Processing file "somefile.ogg"...

New logical stream (#1, serial: 34778229): 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 20040629 (1.1.0)
Channels: 2
Rate: 44100
[=E2=80=A6]

$ gst-play-1.0 somefile.ogg
Press 'k' to see a list of keyboard shortcuts.
Now playing /tmp/somefile.ogg
ERROR Could not decode stream. for file:///tmp/somefile.ogg
ERROR debug information: gstvorbisdec.c(352):
vorbis_handle_header_packet
(): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebi=
n0/GstVorbisDec:vorbisdec0:
couldn't read header packet (-132) Reached end of play list.

$ vorbiscomment --list  --raw --escapes somefile.ogg >somefile.txt

$ vorbiscomment --write --raw --escapes somefile.ogg <somefile.txt

$ ogginfo somefile.ogg || echo "File has warnings"

$ gst-play-1.0 somefile.ogg
Press 'k' to see a list of keyboard shortcuts.
Now playing /tmp/somefile.ogg
ERROR Could not decode stream. for file:///tmp/somefile.ogg
ERROR debug information: gstvorbisdec.c(352):
vorbis_handle_header_packet
(): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebi=
n0/GstVorbisDec:vorbisdec0:
couldn't read header packet (-132) Reached end of play list.

Regards,
Tristan

--=20
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
-=3D-=3D-=3D-=3D-=3D-=3D-
                  Tristan Miller
Free Software developer, ferret herder, logologist
             https://logological.org/
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
-=3D-=3D-=3D-=3D-=3D-=3D-

--Sig_/zj9QOWOd.JooOuEel7rGELk
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE2WFch0UdorzrkBIENu7AW7+KLuQFAll6PJIACgkQNu7AW7+K
LuQVZA//T/aSijG3tMdIPSMBxbuwRZzYKngQZKNmC9zCiHg4YQUyrjQxqyAqrqZQ
bHRxiZPX8iaYIqksVLVtMPVFRMNx5Ped1247Z1wyHrNISqERmCvHNtzKixrR3BsU
rRwKGKqrDSlNSGJpxyEKp1u+P158NnN4xkwGvgFTSOszjScFPrKEUR/qMIiqiKnI
ylYTb3sVSbqdbjACSDYh+mqwANdTj7hr/ULkKYPRB2ygwcx8z+HjASkw/KjaS9VE
/GiZR2L4OiXCbdYjYqqQTwg3xw9/gDLZKHq1hQfdOwv7lp8RNW2PB8qsdIiSa/TR
sWK0DC3TD/98gcm0EIxN9knqCgy4zxleraHwvV9NrUUbAxdOn10VCimY5y7Izch/
DQfKHxv53xFxi1Q7AxWYnzlgM2DZe+qS+XTi4ZyOBNMh0QvNfyVktT2LkpJ5E4J5
DVQ/LG2wDKe3mXz+ttjQ8ujGmVaaqmprXA2P1jaOUAtHC2SxgTKH+IoFnQtZetaL
4+bhQU1DVJBCQNwuukEF8XOHiEP0aFCAZ2/e9TLCq0aWzZO0sD7UmuFhYzkVb+wL
WQLD/eeeTJaqCUsHibNjnh8P27K7Mobttixa8E0Wl8jOSFcy+KhNr9nNvjs4H6ck
gQD1Wtspy1Dk/+28aCFOqLw3bjagCn7KcGwpH0WzWXMNTUClgH8=
=K1NB
-----END PGP SIGNATURE-----

--Sig_/zj9QOWOd.JooOuEel7rGELk--

--===============1345799974213835165==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVm9yYmlzIG1h
aWxpbmcgbGlzdApWb3JiaXNAeGlwaC5vcmcKaHR0cDovL2xpc3RzLnhpcGgub3JnL21haWxtYW4v
bGlzdGluZm8vdm9yYmlzCg==

--===============1345799974213835165==--