AlwardL24 / SwiftYoutubeExtractor

A Swift package to extract format URLs for Youtube videos. Fully Swift implementation of a (very small) subset of youtube-dl's features.
MIT License
2 stars 0 forks source link

Stream is slow. #1

Open Franknxtn opened 9 months ago

Franknxtn commented 9 months ago

I can get video Stream URL fine. However, stream is very very slow and freezes.

AlwardL24 commented 9 months ago

Sorry to hear that. Most of my testing has been with audio. Have you tried with different formats? Also, could you send an example video ID which reproduces the issue?

Franknxtn commented 9 months ago

Below are few videos i tried. but all streams are really reallys slow.

dBDkYofMUs4 69lO08ar-mI b_l1IP_6psY

I use below code for URL extraction to no avail.

Task {
    let formats = try await extractor.formats(for: "dBDkYofMUs4")
            let mp4Formats      = formats.filter({$0.fileExtension == "mp4"})

                if let sdFormat = mp4Formats.first(where: {$0.qualityDescription == "480p"}){

print(sdFormat.url.absoluteString)
//load this url in AVPlayer.

                }

}

}
AlwardL24 commented 9 months ago

I think the issue is likely because the AVPlayer has to download the whole .mp4 file before it starts playing.

I haven't yet implemented HLS support (for .m3u8 files) but I will work on that. I think that should fix your issue as the video can be played back live, rather than having to download the whole thing first.