Closed jln19 closed 8 years ago
Do you have a small project that you can share so I can investigate? That would be so awesome :)
I will try to whip one up. In the meantime though can you confirm that watermarking has worked for you?
@rFlex Here is the simple project showing that watermarking doesn't work, at least from what I can tell. Thanks for investigating :)
@rFlex Hi! I think problem is in - (SCFilter *)_generateRenderingFilterForVideoSize:(CGSize)videoSize method.
if (renderingFilter.isEmpty) { renderingFilter = nil; }
alway returns nil if no custom filter is setted ignoring watermark
Thanks a lot for the help!. @Klucherev yeah good call, that was what the problem was :).
@rFlex I tried making this update. Now there is a crash at line 317 of SCFilter.m. -[CIImage imageByCompositingOverImage:]: unrecognized selector sent to instance 0x14648c40
Try running the test project with your commit added.
Are you running on iOS 7?
Yes, that device was iOS7. I tested again on iOS9 and didn't get the crash, which makes sense. However, why does adding the watermark change the orientation of the video?
This is another issue where your input video has a orientation metadata that isn't being respected by SCRecorder. You may be able to fix that by setting keepInputAffineTransform to false in SCVideoConfiguration
`assetExportSession.videoConfiguration.keepInputAffineTransform = NO;`
results in this:
This is the desired result:
Ok, I will check it out some time today
@rFlex any updates on this? I've invested a lot of time implementing SCRecorder as a solution to our video recording/playback needs but if watermarking doesn't work I can't use it... and explain to my company why I have to start over :(
Here is a working example based of your project.
Thanks. What did you change? ViewController.m looks the same. Did you make changes in the SCRecorder files?
I added a videoComposition that will take care of transforming your video so the output video doesn't have any special rotation metadata.
I see. Thank you.
It seems that I can't add watermark without adding a filter. How do I add a watermark without using a filter?
Here's my code:
guard self.asset != nil else { return }
let assetExportSession = SCAssetExportSession.init(asset: self.asset)
assetExportSession.delegate = self
assetExportSession.inputAsset = self.asset
assetExportSession.contextType = SCContextType.auto
assetExportSession.outputUrl = self.recordSession.outputUrl
assetExportSession.outputFileType = AVFileType.mp4.rawValue
assetExportSession.videoConfiguration.filter = SCFilter.init(ciFilterName: "CIPhotoEffectFade")
assetExportSession.videoConfiguration.watermarkImage = UIImage(named: "twitter")
assetExportSession.videoConfiguration.watermarkFrame = CGRect(x: 0, y: 0, width: 200, height: 40)
assetExportSession.videoConfiguration.preset = SCPresetHighestQuality
assetExportSession.exportAsynchronously {
if assetExportSession.error == nil {
self.saveVideo(withURL: assetExportSession.outputUrl!)
}
}
Couldn't find any documentation or a working example of watermarking videos. The below is what I could piece together. Can you tell me what is wrong with this? The video gets exported, but the watermark never appears. The watermark is a valid .png file (my_watermark@2x.png) in the app bundle.
I've confirmed that
generatedWatermarkImage
is valid inSCAssetExportSession:_buildWatermarkFilterForVideoSize