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

Consider formatting the output of MediaSegment's duration #17

Closed
bitholic opened this issue Jun 5, 2020 · 1 comment · Fixed by #18
Closed

Consider formatting the output of MediaSegment's duration #17

bitholic opened this issue Jun 5, 2020 · 1 comment · Fixed by #18

Comments

@bitholic
Copy link

bitholic commented Jun 5, 2020

I found a input M3u8 playlist like this:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:53
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11.528000,
5UkiTad9_3021444571_copy0.ts
#EXTINF:9.118000,
5UkiTad9_3021444571_copy1.ts
#EXTINF:52.569000,
5UkiTad9_3021444571_copy2.ts
#EXTINF:6.658000,
5UkiTad9_3021444571_copy3.ts
#EXTINF:0.673000,
5UkiTad9_3021444571_copy4.ts
#EXTINF:2.254000,
5UkiTad9_3021444571_copy5.ts
#EXTINF:2.239000,
5UkiTad9_3021444571_copy6.ts
#EXTINF:0.960000,
5UkiTad9_3021444571_copy7.ts
#EXTINF:0.000011,
5UkiTad9_3021444571_copy8.ts
#EXT-X-ENDLIST

Notice the last media segment, it's duration is very small(0.000011), if I use this lib to parse and output this file, the output will be:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:53
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11.528,
5UkiTad9_3021444571_copy0.ts
#EXTINF:9.118,
5UkiTad9_3021444571_copy1.ts
#EXTINF:52.569,
5UkiTad9_3021444571_copy2.ts
#EXTINF:6.658,
5UkiTad9_3021444571_copy3.ts
#EXTINF:0.673,
5UkiTad9_3021444571_copy4.ts
#EXTINF:2.254,
5UkiTad9_3021444571_copy5.ts
#EXTINF:2.239,
5UkiTad9_3021444571_copy6.ts
#EXTINF:0.96,
5UkiTad9_3021444571_copy7.ts
#EXTINF:1.1E-5,
5UkiTad9_3021444571_copy8.ts
#EXT-X-ENDLIST

The parse code is very simple:

MediaPlaylist newPlaylist = MediaPlaylist.builder().allowCache(true).from(playlist).build();
System.out.println(parser.writePlaylistAsString(newPlaylist));

You can see that the duration of the last segment is expressed in scientific notation, which will cause play problems. If I play this m3u8 file in the default HLS player of iOS, the media will be treated as a live stream instead of a ended playList.

So I wonder if formatting can be used to output the media segment's duration? like String.fromat("%.6f", duration)

carlanton added a commit that referenced this issue Jun 6, 2020
carlanton added a commit that referenced this issue Jun 8, 2020
carlanton added a commit that referenced this issue Jun 8, 2020
@carlanton
Copy link
Owner

Thanks for the bug report! It's fixed in version 0.13 which should be on maven soon.

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

Successfully merging a pull request may close this issue.

2 participants