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

Could you support parsing M3U8PlaylistModel into .m3u8 files? #29

Closed
wangleiTT opened this issue Oct 20, 2020 · 10 comments
Closed

Could you support parsing M3U8PlaylistModel into .m3u8 files? #29

wangleiTT opened this issue Oct 20, 2020 · 10 comments
Assignees

Comments

@wangleiTT
Copy link

After parsing the .m3u8 file into M3U8PlaylistModel, I tried to modify the details of the model. But I need to convert it to the original .m3u8 file URL and use it as the AVPlayerItem of AVPlayer. So, is there any way to serialize M3U8PlaylistModel to original .m3u8 file?

M3U8Parser is the best HLS parser kit I'v seen. Any answers are helpful, thank you.

@wolfcon
Copy link
Member

wolfcon commented Oct 21, 2020

Try savePlaylistsToPath:(NSString *)path error:(NSError **)error

@wolfcon wolfcon closed this as completed Oct 21, 2020
@wangleiTT
Copy link
Author

Can you provide a way to serialize directly to memory instead of hard disk sandboxing? If I have to read from the sandbox path to memory every time, the efficiency of I/O will be greatly affected. ^ ^

@wolfcon
Copy link
Member

wolfcon commented Oct 21, 2020

Serializing M3U8 string is not perfect right now. Something is missing (x-key, byte-range, etc.)

You can try m3u8PlainString (m3u8PlanString is wrong spelling in 0.5.0. Will be fixed in next version) for MasterPlaylist. 😳

@wangleiTT
Copy link
Author

I have tried m3u8PlainString and found some issues in the result. Here's my snapshot, hope it can help you.

image

@wolfcon
Copy link
Member

wolfcon commented Oct 22, 2020

Could you provide a demo?
Unit test case is fine.

CODECS parsing bug has been found.🤕 but URI

@wangleiTT
Copy link
Author

The demo is very simple, here's my codes:

import UIKit
import M3U8Kit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        DispatchQueue.global().async {
            do {
                let url = URL(string: "https://ks3-cn-beijing.ksyun.com/xpc-test/5de9c696f1e39_dash_hls_playlist.m3u8")!
                let origin = try String(contentsOf: url, encoding: .utf8)
                print(origin)
                
                let m3u8 = try M3U8PlaylistModel(url: url)
                let parsed = m3u8.masterPlaylist.m3u8PlanString()
                print(parsed!)
            } catch let error {
                debugPrint(error)
            }
        }
    }
}

Anything I can help, just reply.😄

@wolfcon
Copy link
Member

wolfcon commented Oct 22, 2020

#EXT-X-MEDIA:TYPE=AUDIO,LANGUAGE="eng",NAME="audio_id_6",DEFAULT=YES,GROUP-ID="audio_group", URI="audio_6.m3u8"

Spaceholder has been found before URI.🙄 It may not be used in M3U8 file.

@wangleiTT
Copy link
Author

Good catch! But will you make some compatibility improvements?

@wolfcon
Copy link
Member

wolfcon commented Oct 22, 2020

M3U8 File shouldn't appear that extra spaceholder.
Trimming method has been added.😳 You shouldn't rely on that🤣

@wangleiTT
Copy link
Author

Already updated to 1.0.0, brilliant fix! 👏🏻👏🏻👏🏻

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

No branches or pull requests

2 participants