向后播放视频(Play video backwards)
我想要的基本上是反转AVAsset和输出视频文件,我发现这个链接 - https://github.com/tempire/ReverseAVAsset/blob/master/AVAsset.swift
这就是我所做的:
import UIKit import AVFoundation import AVKit class ViewController: UIViewController { var playerViewController = AVPlayerViewController() var playerView = AVPlayer() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let path = Bundle.main.path(forResource: "video", ofType: "mov") let outputUrl = URL(fileURLWithPath: "\(NSUUID().uuidString)video.mov") let originalAsset = AVAsset(url: URL(fileURLWithPath: path!)) let reversedAsset = originalAsset.reversedAsset(outputUrl) playerView = AVPlayer(playerItem: AVPlayerItem(asset: reversedAsset!)) playerViewController.player = playerView present(playerViewController, animated: true) { self.playerViewController.player?.play() } } }
但它不工作,这就是我最终的结果:
我想我对outputURL做错了,如果你知道该怎么做,请帮忙
What I want is basically reverse an AVAsset and output video file and I found this link - https://github.com/tempire/ReverseAVAsset/blob/master/AVAsset.swift
This is what I did:
import UIKit import AVFoundation import AVKit class ViewController: UIViewController { var playerViewController = AVPlayerViewController() var playerView = AVPlayer() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let path = Bundle.main.path(forResource: "video", ofType: "mov") let outputUrl = URL(fileURLWithPath: "\(NSUUID().uuidString)video.mov") let originalAsset = AVAsset(url: URL(fileURLWithPath: path!)) let reversedAsset = originalAsset.reversedAsset(outputUrl) playerView = AVPlayer(playerItem: AVPlayerItem(asset: reversedAsset!)) playerViewController.player = playerView present(playerViewController, animated: true) { self.playerViewController.player?.play() } } }
But its not working and this is what I end up with:
I think I'm doing something wrong with outputURL, please help if you know what to do
原文:https://stackoverflow.com/questions/47617100
最满意答案
HTML5 Canvas的.scale方法实际上并没有调整画布的大小。 它所做的只是影响将来在画布上绘制的内容。
这是它如何工作的一个很好的例子https://www.w3schools.com/tags/canvas_scale.asp正如你所看到的,原始矩形保持相同的大小,但第二个是两倍大。您需要直接更改画布的高度和宽度。 像这样的东西应该这样做调整HTML5画布大小以适应窗口
The .scale method for HTML5 Canvas does not actually resize the canvas. All it does is to affect things that will be drawn on the canvas in the future.
This is a good example of how it works https://www.w3schools.com/tags/canvas_scale.asp As you can see, the original rectangle remains the same size but the second one is twice as big.You need to do directly change the height and width of your canvas. Something like this should do it Resize HTML5 canvas to fit window
相关问答
更多-
缩放VS.(Zoom Vs. Scale in CSS3)[2022-06-18]
变换比浏览器中的变焦更具可预测性。 缩放会影响不同浏览器中的定位 。 例如 position:absolute; left:50px; zoom: 50%; IE不会改变左边的值 Chrome会将左侧的值更改为25px。 (左=左*缩放)和Devtools不会告诉你这一点,计算值仍然会显示left: 50px ,但它是撒谎。 在所有浏览器中, 转换的处理方式都是一样的(据我所知)。 position:absolute; left:50px; transform: scale(0.5) 在Chrome和IE浏 ... -
通过js结合css3变换(Combine css3 transforms via js)[2022-09-05]
你需要操纵矩阵来完成你想要做的事情: var transform = new WebKitCSSMatrix(window.getComputedStyle(element).webkitTransform); transform = transform.rotateAxisAngle(0,0,0,45) element.style.webkitTransform = transform; 操作WebkitCSSMatrix的方法是: .multiply() .inverse() .t ... -
CSS3过渡只有规模(CSS3 transition only scale)[2023-09-27]
正如我在上面的评论中提到的,只需在您的scale:hover添加background:red scale:hover类。 .scale:hover{ -webkit-transform: scale(1.1); -moz-transform: scale(1.1); -o-transform: scale(1.1); transform: scale(1.1); background:red; } DEMO As I mentioned in the comment above, just add the ... -
您错过了为各个渲染引擎添加供应商前缀版本。 .img{ -webkit-transform:scale(0.85); -moz-transform:scale(0.85); -ms-transform:scale(0.85); -o-transform:scale(0.85); transform:scale(0.85); } You missed to add vendor-prefixed versions for the individual render e ...
-
使用CSS3 Transform Scale和jQuery创建动画效果(Animate pulsing effect using CSS3 Transform Scale and jQuery)[2023-09-08]
尝试使用CSS动画 。 @keyframes pulse { 0% { transform: scale(1, 1); } 50% { transform: scale(1.1, 1.1); } 100% { transform: scale(1, 1); } } #test { animation: pulse 1s linear infinite; } http://jsfiddle.net/rooseve/g4 ... -
CSS3比例动画关键帧(CSS3 Scale Animation Keyframes)[2022-03-24]
我想你忘记了关键帧中的's'。 尝试@keyframes和@ -webkit-keyframes。 I think you forgot the 's' in keyframes. try @keyframes and @-webkit-keyframes. -
解决这个问题的hacky方法是使用包装元素并将translate放在该元素上。 The hacky way to solve this is to use a wrapper element and put the translate on that element.
-
检查css3动画是否已完成,例如使用jquery进行变换缩放(check if the css3 animation is done for example transform scale using jquery)[2023-11-01]
你总是可以删除一些支持,如转换等,并检查问题是否仍然存在。 谢谢。 you can always delete some supports such as transitioned etc and check if problem persists. Thanks. -
画布规模麻烦与css3(canvas scale trouble with css3)[2023-03-04]
HTML5 Canvas的.scale方法实际上并没有调整画布的大小。 它所做的只是影响将来在画布上绘制的内容。 这是它如何工作的一个很好的例子https://www.w3schools.com/tags/canvas_scale.asp正如你所看到的,原始矩形保持相同的大小,但第二个是两倍大。 您需要直接更改画布的高度和宽度。 像这样的东西应该这样做调整HTML5画布大小以适应窗口 The .scale method for HTML5 Canvas does not actually resize th ... -
CSS3规模不起作用(CSS3 scale not working)[2022-02-22]
您需要在transform定义后添加分号,否则浏览器会将其视为错误并忽略后续规则。 transform: scale(1.5, 1.5); /*you didn't have the semi-colons here*/ -ms-transform: scale(1.5, 1.5); -webkit-transform: scale (1.5, 1.5); -moz-transform: scale(1.5, 1.5); -o-transform: scale(1.5, 1.5); You need to ...