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

Not able to play HLS stream - Loading finished before preparation is complete #2141

Open
1 task
grbaczek opened this issue Feb 12, 2025 · 4 comments
Open
1 task
Assignees
Labels

Comments

@grbaczek
Copy link

Version

Media3 main branch

More version details

https://github.com/androidx/media.git - Commit hash: 76088cd

Devices that reproduce the issue

Android emulator API - 33, 34, 35

Devices that do not reproduce the issue

Haven't found any

Reproducible in the demo app?

Yes

Reproduction steps

Add HLS stream to demo app media.exolist.json file

Expected result

I expect stream to play

Actual result

Player seems to be loading all the files one by one - it fails after loading all the files with androidx.media3.common.ParserException: Loading finished before preparation is complete. {contentIsMalformed=true, dataType=1}

Stream works as expected on iOS and VLC player (Version 3.0.20 Vetinari (Apple Silicon))

Note that all hls media files calls redirect (303) to CDN. This has been working as expected for most of the streams.

Image

Media

I am sending link to the stream on [email protected]

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@tianyif
Copy link
Contributor

tianyif commented Feb 13, 2025

Hi @grbaczek,

By trying to play both the two provided urls on demo app, I found that for that "not working" stream, there is never a PmtReader initialized, as a result, we will not be able know the format of the media. And the "working" stream doesn't have such problem.

According to the HLS spec -

"Each Transport Stream Segment MUST contain a PAT and a PMT, or have an EXT-X-MAP tag (Section 4.3.2.5) applied to it. The first two Transport Stream packets in a Segment without an EXT-X-MAP tag SHOULD be a PAT and a PMT."

Could you please make sure that the TS segments in the stream follow the spec?

@grbaczek
Copy link
Author

Hi @tianyif thx for you answer - I will look into it

@grbaczek
Copy link
Author

I have run ffprobe -i file.ts -show_streams -show_format -show_programs on decrypted part_0000.ts files from both streams I have sent you. Data should come from PAT and a PMT packets. I can not see anything off in the output.

part_0000.ts (not working):

Input #0, mpegts, from 'part_0000_decrypted.ts':
  Duration: 00:01:59.69, start: 1.400000, bitrate: 53 kb/s
  Stream #0:0[0x100]: Audio: mp3 (mp3float), 44100 Hz, mono, fltp, 48 kb/s
[STREAM]
index=0
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
initial_padding=0
ts_id=0
ts_packetsize=188
id=0x100
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=126000
start_time=1.400000
duration_ts=10772192
duration=119.691022
bit_rate=48000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
DISPOSITION:multilayer=0
[/STREAM]
[FORMAT]
filename=part_0000_decrypted.ts
nb_streams=1
nb_programs=0
nb_stream_groups=0
format_name=mpegts
format_long_name=MPEG-TS (MPEG-2 Transport Stream)
start_time=1.400000
duration=119.691022
size=800128
bit_rate=53479
probe_score=49
[/FORMAT]

part_0000.ts (working):

Input #0, mpegts, from 'working_part_0000_decrypted.ts':
  Duration: 00:01:59.69, start: 1.400000, bitrate: 53 kb/s
  Stream #0:0[0x100]: Audio: mp3 (mp3float), 44100 Hz, mono, fltp, 48 kb/s
[STREAM]
index=0
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
initial_padding=0
ts_id=0
ts_packetsize=188
id=0x100
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=126000
start_time=1.400000
duration_ts=10772192
duration=119.691022
bit_rate=48000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
DISPOSITION:multilayer=0
[/STREAM]
[FORMAT]
filename=working_part_0000_decrypted.ts
nb_streams=1
nb_programs=0
nb_stream_groups=0
format_name=mpegts
format_long_name=MPEG-TS (MPEG-2 Transport Stream)
start_time=1.400000
duration=119.691022
size=800128
bit_rate=53479
probe_score=49
[/FORMAT]

Streams are generated with the command (ffmpeg 6.1.2-r1):

ffmpeg_command = [
    "ffmpeg",
    "-err_detect", "ignore_err",
    "-f", "mp3",
    "-i", f"concat:{file_params}",
    "-hls_time", str(piece_duration),
    "-hls_playlist_type", "vod",  # Forces hls_list_size to 0; the playlist must not change.
    "-hls_segment_filename", str(Path(output_path, piece_format)),
    "-vn",  # Blocks all video streams.
    "-hls_enc", "1",
    "-hls_enc_key", key,
    "-hls_enc_iv", iv_vector,
    "-b:a", "48k",
    "-hls_enc_key_url", str(Path(output_path, "playlist.key")),
    "-map_metadata", "-1"
]

@grbaczek
Copy link
Author

Ok, I can actually see there is sth off here tsp -I file file.ts -P tables -O drop returns Error: file: cannot detect TS file format for both of the streams. It is interesting though why one works while the other doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants