Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OGG fails with non-contiguous pages #7230

Closed
billyjoker opened this issue Apr 14, 2020 · 8 comments
Closed

Support OGG fails with non-contiguous pages #7230

billyjoker opened this issue Apr 14, 2020 · 8 comments
Assignees

Comments

@billyjoker
Copy link

billyjoker commented Apr 14, 2020

Issue description

Using the Exoplayer demo app, i've replaced the existing OGG file with another OGG file and it fails the playback

Reproduction steps

1- I open the Exoplayer demo app and i select the existing OGG file with uri
2- Playback is rightly played
3- I have placed my content inside the media.exolist.json
4- I open the Exoplayer demo app and i select that file
5- Playback Failed

      {
        "name": "Google Play (Ogg/Vorbis)",
        "uri": "https://ia800300.us.archive.org/16/items/pink_fairy_book_1010_librivox/pinkfairybook_04_lang.ogg"
      },

Important: the file plays right if i use the Google Chrome navigator

Full bug report captured from the device:

E/ExoPlayerImplInternal: Source error
      com.google.android.exoplayer2.ParserException: Loading finished before preparation is complete.
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.maybeThrowPrepareError(ProgressiveMediaPeriod.java:236)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:619)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:329)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:148)
        at android.os.HandlerThread.run(HandlerThread.java:61)
04-14 10:07:05.417 15715-15715/principal.apps.cuentacuentos E/EventLogger: playerFailed [eventTime=0.98, mediaPos=0.00, window=0, period=0
      com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.ParserException: Loading finished before preparation is complete.
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:394)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:148)
        at android.os.HandlerThread.run(HandlerThread.java:61)
     Caused by: com.google.android.exoplayer2.ParserException: Loading finished before preparation is complete.
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.maybeThrowPrepareError(ProgressiveMediaPeriod.java:236)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:619)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:329)
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.os.HandlerThread.run(HandlerThread.java:61) 

Version of ExoPlayer being used is 2.11.4

Nexus 5 with Marshmallow 6.0.1

@icbaker
Copy link
Collaborator

icbaker commented Apr 14, 2020

I can reproduce this behaviour in the demo app, both with the URL provided and a local copy of the same file.

I think the media might be malformed. When I check it with mediainfo it doesn't list any codec information:

$ mediainfo ~/Downloads/pinkfairybook_04_lang.ogg 
General
ID                                       : 1578688666 (0x5E18E09A)
Complete name                            : /usr/local/google/home/ibaker/Downloads/pinkfairybook_04_lang.ogg
Format                                   : Ogg
File size                                : 4.81 MiB

In contrast to the Google Play (Ogg/Vorbis) file in the demo app:

$ mediainfo
$ mediainfo ~/Downloads/play.ogg 
General
Complete name                            : /usr/local/google/home/ibaker/Downloads/play.ogg
Format                                   : Ogg
File size                                : 786 KiB
Duration                                 : 59 s 272 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 109 kb/s
compatible_brands                        : isommp42
Software                                 : Lavf54.20.4
major_brand                              : mp42
minor_version                            : 0
Encoding time                            : 2014-01-27 08:23:44

Audio
ID                                       : 608279781 (0x24419CE5)
Format                                   : Vorbis
Format settings, Floor                   : 1
Duration                                 : 59 s 272 ms
Bit rate mode                            : Variable
Bit rate                                 : 160 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 kHz
Compression mode                         : Lossy
Stream size                              : 1.13 MiB
Writing library                          : libVorbis (Schaufenugget) (20101101 (Schaufenugget))

@icbaker
Copy link
Collaborator

icbaker commented Apr 14, 2020

However ffprobe is able to determine the file is vorbis encoded:

$ ffprobe ~/Downloads/pinkfairybook_04_lang.ogg 
Input #0, ogg, from '/usr/local/google/home/ibaker/Downloads/pinkfairybook_04_lang.ogg':
  Duration: 00:08:48.50, start: 0.000000, bitrate: 76 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 96 kb/s
    Metadata:
      encoder         : Lavc52.79.1
      artist          : Andrew Lang
      title           : 04 - The House in the Wood
      album           : The Pink Fairy Book
      comment         : http://www.archive.org/details/pink_fairy_book_1010_librivox

@billyjoker
Copy link
Author

Ok i see, as you say ffprobe determine is vorbis enconded, then Exoplayer should be able to play the file.

If i paste the url to Google Chrome, it is able to playback the file with no problems with the embbeded player, so the file is playable

@ryanheise
Copy link

@billyjoker
Copy link
Author

The fact is though using the Google Chrome integrated player, it takes a long time to load and play the file. So finally i decided to recode these conflictive ogg files with Audacity and now they are playing well and fast.

@ryanheise
Copy link

This is still an issue in apps like podcast players where the app is tasked with playing whatever URL comes from the feed.

@icbaker icbaker assigned icbaker and unassigned marcbaechinger May 26, 2020
@icbaker
Copy link
Collaborator

icbaker commented May 26, 2020

I looked deeper into this (using the pinkfairy file from OP as an example).

The file doesn't seem to have contiguous OGG pages. The first page starts at the beginning of the file with the 'OggS' magic string as expected, and declares itself to contain a single segment of data that's 30 bytes long. The page header is 28 bytes, so the next page is expected to start at byte 58 (counting from 0) with another 'OggS' but that's not what we see:

$ hexdump -C ~/Downloads/pinkfairybook_04_lang.ogg -s 58 -n 16
0000003a  66 55 2a 7f 00 00 10 f2  ee 54 2a 7f 00 00 b0 43  |fU*......T*....C|

The next 'OggS' magic string doesn't turn up until byte 1024:

$ hexdump -C ~/Downloads/pinkfairybook_04_lang.ogg -s 1024 -n 16
00000400  4f 67 67 53 00 00 00 00  00 00 00 00 00 00 9a e0  |OggS............|

ExoPlayer assumes the pages are contiguous, and when we read the 58 - 61 bytes and compare them to 'OggS' we find they don't match and return false indicating we encountered an error (quiet=true):
https://github.com/google/ExoPlayer/blob/dev-v2/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java#L98

The magic 'OggS' strings are there to enable us to find the start of the next page, so we should probably keep looking forwards in the file until we find the next page.


Not sure if it's directly related, since the byte offsets mentioned are much larger, but ogginfo also complains these are not valid OGG files:

$ ogginfo ~/Downloads/pinkfairybook_04_lang.ogg
...
WARNING: Hole in data (966 bytes) found at approximate offset 4500 bytes. Corrupted Ogg.
...
WARNING: Hole in data (30 bytes) found at approximate offset 9000 bytes. Corrupted Ogg.
$ ogginfo ~/Downloads/prideandprejudice_01_austen.ogg
...
WARNING: Hole in data (720 bytes) found at approximate offset 4500 bytes. Corrupted Ogg.
...
WARNING: Hole in data (181 bytes) found at approximate offset 9000 bytes. Corrupted Ogg.
WARNING: Hole in data (77 bytes) found at approximate offset 9000 bytes. Corrupted Ogg.
Negative or zero granulepos (0) on Vorbis stream outside of headers. This file was created by a buggy encoder

No warnings are shown for the Google Play (Ogg/Vorbis) file from the demo app.

@icbaker icbaker changed the title Playback OGG fails with specific OGG file produces ParserException Support OGG fails with non-contiguous pages May 26, 2020
ojw28 pushed a commit that referenced this issue Jun 4, 2020
bear_vorbis_gap.ogg is a copy of bear_vorbis.ogg with 10 garbage bytes
(DE AD BE EF DE AD BE EF DE AD) inserted before the second capture
pattern and 3 garbage bytes inserted at the end (DE AD BE).

Issue: #7230
PiperOrigin-RevId: 314715729
@icbaker
Copy link
Collaborator

icbaker commented Jun 4, 2020

This is now fixed on dev-v2.

@icbaker icbaker closed this as completed Jun 4, 2020
@google google locked and limited conversation to collaborators Aug 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants