首页 \ 问答 \ 向后播放视频(Play video backwards)

向后播放视频(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:

enter image description here

I think I'm doing something wrong with outputURL, please help if you know what to do


原文:https://stackoverflow.com/questions/47617100
更新时间:2022-08-28 18:08

最满意答案

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

相关问答

更多
  • 变换比浏览器中的变焦更具可预测性。 缩放会影响不同浏览器中的定位 。 例如 position:absolute; left:50px; zoom: 50%; IE不会改变左边的值 Chrome会将左侧的值更改为25px。 (左=左*缩放)和Devtools不会告诉你这一点,计算值仍然会显示left: 50px ,但它是撒谎。 在所有浏览器中, 转换的处理方式都是一样的(据我所知)。 position:absolute; left:50px; transform: scale(0.5) 在Chrome和IE浏 ...
  • 你需要操纵矩阵来完成你想要做的事情: var transform = new WebKitCSSMatrix(window.getComputedStyle(element).webkitTransform); transform = transform.rotateAxisAngle(0,0,0,45) element.style.webkitTransform = transform; 操作WebkitCSSMatrix的方法是: .multiply() .inverse() .t ...
  • 正如我在上面的评论中提到的,只需在您的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 ...
  • 尝试使用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 ...
  • 我想你忘记了关键帧中的'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.
  • 你总是可以删除一些支持,如转换等,并检查问题是否仍然存在。 谢谢。 you can always delete some supports such as transitioned etc and check if problem persists. Thanks.
  • HTML5 Canvas的.scale方法实际上并没有调整画布的大小。 它所做的只是影响将来在画布上绘制的内容。 这是它如何工作的一个很好的例子https://www.w3schools.com/tags/canvas_scale.asp正如你所看到的,原始矩形保持相同的大小,但第二个是两倍大。 您需要直接更改画布的高度和宽度。 像这样的东西应该这样做调整HTML5画布大小以适应窗口 The .scale method for HTML5 Canvas does not actually resize th ...
  • 您需要在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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。