swift can not save .m3u8 file to gallery
M3U8 is an audio/video playlist file and it cannot be saved to the gallery.
m3u8 file AVAssetImageGenerator error
You won't be able to get still images for a live stream using AVAssetImageGenerator. Instead, you can use
AVPlayerItemVideoOutput
With AVPlayerItemVideoOutput you can get an image that is appropriate to display at a specified time for a given .m3u8 stream using the following method: - (CVPixelBufferRef)copyPixelBufferForItemTime:(CMTime)itemTime itemTimeForDisplay:(CMTime *)outItemTimeForDisplay
Then, you can convert the returned CVPixelBufferRef into an image (or other) for display.
Load image form Gallery in swift from path given by UIImagePickerViewController?
Save image in Document Directory taken from Gallery or Camera.
func origionalImage(origionalImage: UIImage!, editedImage: UIImage!, userInfo info: [NSObject : AnyObject]!) {
let imageData = NSData(data:UIImagePNGRepresentation(origionalImage)!)
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let docs: String = paths[0]
let imageName = self.randomStringWithLength(6) as String
//imageName can save in sqlite to load image later
let fullPath = String("\(docs)/\(imageName).png")
print(fullPath)
let result = imageData.writeToFile(fullPath, atomically: true)
print("FILE WRITTEN SUCCESS=>:\(result)")
}
Load Image from Database
let tempDBObject = self.petListArray[indexPath.row] as! Database
cell?.petName.text = tempDBObject.Hname
//Doc Path
let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! as String
let imagePath = String("\(documentDirectory)/\(tempDBObject.Hpath!)")
if imagePath == "" {
}else{
cell?.petImageView.image = UIImage(contentsOfFile: imagePath)
}
How can I capture an image when AVPlayer playing m3u8 stream?
AVAssetImageGenerator
may require local assets. Maybe you'd have more luck adding an AVPlayerItemVideoOutput
to your AVPlayer
, seeking to the desired spot and calling copyPixelBufferForItemTime:itemTimeForDisplay:
on the videoOutput.
Can we manually download/cache the transport stream while streaming m3u8 file
Something similar has been implemented here: https://github.com/StyleShare/HLSCachingReverseProxyServer
It downloads the segments while streaming, if the segment is available locally, it will use that instead.
Related Topics
Swift: Implementing Protocol Initializer in a Class
Value of Type 'Authdataresult' Has No Member 'Uid'
Swift Can Not Save .M3U8 File to Gallery
Randomizing Node Movement Duration
With Data (Not Nsdata), in Fact How Actually Do You Make a Utf8 Version of a Jpeg
Update All Value in One Attribute Core Data
Xcode Swift 3: Timer and Segue View Controller Error
Finding All Types That Conform to a Protocol
Unexpectedly Found Nil While Unwrapping an Optional Value Parsing JSON Swift
How to Sleep for Few Milliseconds in Swift 2.2
Simple Swift Class Does Not Compile
Image Disappears When Styling Class to Make a Round Image
Swift: Filter a Dictionary with Array as Value
Swift Tuple Has Unexpected Print Result
Label Showing Top of Screen Instead of Being on the Inputaccessoryview
How to Notify a Queue in Swift (Gcd)
How to Check for Value in Firebase That Is Held Under a Autoid Child