python dash_使用python dash moviepy制作自己的视频编辑器应用

python dash

Plotly’s Dash framework is a great Python library for quickly and easily making interactive web apps without coding HTML or JavaScript! Moviepy is an excellent library for programmatically editing video files. However, out-of-the-box Dash is subject to browser storage limits which makes working with storage-hungry video files difficult. This article will cover how we can use np-8’s Dash-uploader library to get around the ~100MB–200MB browser storage limits which opens Dash apps up to very large user input files (video or data). We will also touch on thedirtyfew’s ServerSideOutput (part of dash-extensions) which allows for easy storing of data on the server. You can check out this GitHub repository which contains 3 Dash app files that I will go through below.

Plotly的Dash框架是一个很棒的Python库,无需编写HTML或JavaScript即可快速轻松地制作交互式Web应用程序! Moviepy是用于以编程方式编辑视频文件的出色库。 但是,开箱即用的Dash受到浏览器存储限制的限制,这使处理需要大量存储的视频文件变得困难。 本文将介绍我们如何使用np-8的Dash-uploader库来解决大约100MB–200MB的浏览器存储限制,这将使Dash应用程序最多处理非常大的用户输入文件(视频或数据)。 我们也将触及thedirtyfew的ServerSideOutput (破折号-扩展的一部分),它允许在服务器上的数据,便于存放。 您可以签出这个GitHub存储库,其中包含3个Dash应用程序文件,我将在下面进行介绍。

存储问题...通过示例 (The Storage Issue...by Example)

Ok, let's start with some data! I made a script (st_make_data.py) that creates a file with a json-like format, simulating sensor data that came over serial from a microcontroller. The data is just a sine and cosine curve. I used this to make a few files with increasing numbers of rows (10k, 100k, 1m, & 5m rows) which corresponded to ~0.8MB, 8MB, 82MB, & 409MB file sizes.

好的,让我们从一些数据开始! 我制作了一个脚本( st_make_data.py ),该脚本创建了一个类似json格式的文件,以模拟来自微控制器串行传输的传感器数据。 数据只是正弦和余弦曲线。 我用它来制作一些行数增加的文件(10k,100k,1m和5m行),它们对应于〜0.8MB,8MB,82MB和409MB的文件大小。

Here we have a simple Dash app (user_large_data_sql.py) that takes in the data, parses it and plots it (allowing the user to chose data for each axes). There are 2 options for uploading data: the standard Dash dcc.Store object and the Dash-uploader du.Upload object (which also uses its own dcc.Store object to old the filename).

在这里,我们有一个简单的Dash应用程序( user_large_data_sql.py ),它可以接收数据,对其进行解析和绘制(允许用户为每个轴选择数据)。 有2个上传数据的选项:标准Dash dcc.Store对象和Dash-uploader du.Upload对象(它们也使用其自己的dcc.Store对象来旧文件名)。

The callback for this is a little special. It checks the context to see which upload object was fired. If the standard upload object was fired it parses the base64 object and collects the lines from the file as you would with small data. All this callback does, in the end, is enable a button for processing the data, but this is where we run into trouble with the larger files.

这个回调有点特殊。 它检查上下文以查看触发了哪个上载对象。 如果触发了标准上载对象,则它将解析base64对象,并像处理小数据一样从文件中收集行。 最后,所有回调都启用了一个用于处理数据的按钮,但这是我们遇到较大文件的问题。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值