python 回车失效
This is an overview of a simple script I made in python to try and capture fireflies. The difficulty of fireflies are that it’s hard to take a photo or a video that accurately captures what it’s like to be there.
这是我用python创建的一个简单脚本的概述,以尝试捕获萤火虫。 萤火虫的难点在于,很难拍摄出能够准确捕捉其所处状态的照片或视频。
I made a few simple scripts to average some images together to see if the result was any better.
我制作了一些简单的脚本来将一些图像平均在一起,以查看结果是否更好。
I liked the basic results and put the scripts together into a single script. I tried to combine some of the features to speed it up, and allow it to run multiple outputs.
我喜欢基本结果,并将这些脚本放到一个脚本中。 我试图结合一些功能来加速它,并允许它运行多个输出。
A breakdown of the Arguments:
细目分类:
— input — The video file to be operated on.
— 输入 —要操作的视频文件。
— frame_avg — This is how many frames make each frame. The more specified the slower it takes to run. The Basic idea is demo’d below:
— frame_avg —这是每帧制作多少帧。 指定的越多,运行速度就越慢。 基本想法如下所示:
The window slides through the video feed and anything within the range has the operation applied to it
窗口在视频源中滑动,并且该范围内的所有内容均已应用该操作
— start- This takes a format of a <Sec>.<frame> So 2.5 seconds depending on frame rate might be 2.15. To make things work better, if you choose the wrong frame number, it will round it to seconds. eg. 0.60 would be 2 seconds at 30 frames per second.
— 开始 -这采用<Sec>。<frame>格式,因此2.5秒(取决于帧速率)可能是2.15。 为了使性能更好,如果您选择了错误的帧号,则会将其舍入到秒。 例如。 0.60将是每秒30帧的2秒。
— length -How long to run for on the desired clip. It takes the same <sec>.<frame> format as the — start flag
— 长度 -在所需剪辑上运行多长时间。 它采用与开始标记相同的<sec>。<frame>格式。
— scale -An integer to divide the image by. 1 is full sized. 2 would divide the image in half. 3 by a third. This is based on the input resolution. It will give a warning if the output is greater then 1080p. Larger sizes are slower so choosing something like 4 is good to review the results.
- 规模 -An整数由划分图像。 1已全尺寸。 2将图像分成两半。 3分之三。 这基于输入分辨率。 如果输出大于1080p,则会发出警告。 较大的尺寸较慢,因此选择类似4的值可以很好地查看结果。
— frame_rate -This is the rate at which the output would be. It will affect the playback speed. If left blank it will either take it from the input or default to 30.
— frame_rate-这是输出的速率。 它将影响播放速度。 如果保留为空白,则将其从输入中获取或默认为30。
— rolling_mean — A window of images turned into a mean.
— rolling_mean —图像窗口变成了平均值。
—rolling_median — A window of images with each output being the Median image of all the images within the window
— rolling_median —图像窗口,每个输出是该窗口中所有图像的中间图像
—rolling_max— A window of , where the result image is the max value from of all the images from the window
— rolling_max —的窗口,其中结果图像是该窗口中所有图像中的最大值
— max— A simple calculation of the max value of the all the images so far. This works best on short clips
— max —到目前为止所有图像的最大值的简单计算。 这在短片上效果最好
— all-This will run all 4 modes together. This way you don’t need to call them all.
— 全部 -这将同时运行所有4种模式。 这样,您无需全部调用它们。
— overwrite -This will replace whatever name you choose. Otherwise it will append a number at the end so your old results won’t be over written.
— 覆盖 -这将替换您选择的任何名称。 否则,它将在末尾附加一个数字,这样您的旧结果将不会被覆盖。
— output -The name you want. It will provide a default if none is given. Depending on your codec you need to provide an extension. Without an extension it will apply it’s own.
— 输出 -您想要的名称。 如果没有给出默认值,它将提供一个默认值。 根据您的编解码器,您需要提供扩展。 没有扩展,它将自己使用。
Some basic examples of what the different modes look like on some short clips.
一些简短片段中不同模式的基本示例。
To explain we are going to assume we have some film strip like above and we are looking at a single highlighted pixel (in red) across these pictures.
为说明起见,我们将假设我们有一些如上所述的胶卷,并且正在查看这些图片中的单个高亮像素(红色)。
![Image for post](https://miro.medium.com/max/9999/1*m2BqKJStHhN0itFTtNSqpA.png)
例子: (Examples:)
![Image for post](https://miro.medium.com/max/9999/1*2hb7wArm8BCROi61kBEifg.png)
Max: Max in the basic sense is the pixel in the range of interest that has the highest value is selected. The red box shows the output image will use the circled pixel from it’s choices in the window
最大值 :从基本意义上讲,最大值是在感兴趣范围内选择具有最高值的像素。 红色框显示输出图像将使用窗口中选择的圆圈像素
The “max” is actually a special case, it’s calculated over all images so far instead of a moving window. This allows it to be done much faster and it has an interesting effect. It also only works for tripod mounted and short clips. Eventually it will become white given enough time.
实际上,“最大值”是一种特殊情况,它是根据到目前为止的所有图像而不是移动的窗口计算得出的。 这使得它可以更快地完成,并且具有有趣的效果。 它也仅适用于安装在三脚架上的短夹。 最终,如果有足够的时间,它将变成白色。
Rolling Max: Like max it’s each pixel is the brightest value seen so far into the video clip. But unlike Max, it’s only applied to a rolling window. This means movement will recover, and it works on much longer clips.
Rolling Max :与max一样, Rolling Max是每个像素到目前为止在视频剪辑中看到的最亮的值。 但是与Max不同,它仅适用于滚动窗口。 这意味着运动将恢复,并且可以在更长的剪辑上使用。
![Image for post](https://miro.medium.com/max/9999/1*xxJbAmnutDHI5wYGGmvWzg.png)
Rolling Median: Looking at the window, if we imagine we had them sorted from darkest to brightest(Pictured below) the highlighted value above would now be the one in the middle. This is the pixel that gets put in the frame.
滚动中位数:看着窗口,如果我们假设我们将它们从最暗到最亮排序(如下图所示),则上面的突出显示的值现在将是中间的值。 这是放入帧中的像素。
![Image for post](https://miro.medium.com/max/9999/1*iL0UR_3Q5Ca-HnBCjUvIfw.png)
This has the effect that it will reduce the appearance of noise. It will cause objects to have a delayed motion blur to them. It does not work great with fast motion. But It has a cool effect.
这样的效果是它将减少噪声的出现。 这将导致对象延迟运动模糊。 快速运动效果不佳。 但是它具有很酷的效果。
Rolling Mean: The command is called avg but is technically a mean calculation. Looking at the same examples as before
滚动均值:该命令称为avg,但从技术上讲是均值计算。 看与以前相同的例子
![Image for post](https://miro.medium.com/max/9999/1*Z0Dn9da2qSLotIpAdlkHng.png)
We take the entire set of pixel values. Add them together, divide by the number of samples, and get the value that is used. The result ends up being a kind of long exposure. Movement is blurred the window as if it was a long exposure of that length.
我们采用整个像素值集。 将它们加在一起,除以样本数,得到使用的值。 结果最终是一种长时间的曝光。 运动模糊了窗口,好像是长时间的曝光一样。
for this example, the usage of 15 for the -frame_avg flag with a 30fps source video, means each still is as if it was exposed for 1/2 a second (Technically less if our shutter speed is greater then 1/30th of a second).
在此示例中,对于带有30fps源视频的-frame_avg标志使用15,表示每个帧都好像在每秒曝光1/2秒(如果我们的快门速度大于1/30秒,则技术上会更少) )。
Simply started 1/30th a second apart from each other. The effect is a little more interesting then the median. But is only supported because it was also easy to add.
彼此之间的间隔仅为1/30秒。 效果比中位数更有趣。 但是仅受支持,因为它也很容易添加。
Ending Remarks: The python script is pretty easy to read through, and hopefully is either helpful to someone trying to do something similar, or simply trying to perform some simple effects on a video clip.
结束语: python脚本很容易阅读,希望对尝试做类似事情的人有所帮助,或者只是尝试对视频剪辑执行一些简单的效果。
I plan to try and clean up and share a bunch of other random short helper python scripts I’ve used for one purpose or another that might be useful to someone.
我打算尝试清理并共享一堆我用于某个目的或对某人有用的其他随机短助手python脚本。
Ref:
参考:
github: https://github.com/etchelepi/frame_lapse
github的: https : //github.com/etchelepi/frame_lapse
The clips used above are from the following two clips. If it helps demonstrate the difference between the before and after.
上面使用的剪辑来自以下两个剪辑。 如果它有助于证明之前和之后的区别。
翻译自: https://medium.com/@evantchelepi/frame-lapse-python-script-3d8d35010fb5
python 回车失效