首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >确定连续的视频剪辑

确定连续的视频剪辑
EN

Stack Overflow用户
提问于 2011-07-17 17:57:48
回答 1查看 102关注 0票数 0

我有一个很长的视频流,但不幸的是,它的形式是1000个15秒长的随机命名的剪辑。我想根据两个这样的15s剪辑的“相似性”来重建原始视频,这回答了“剪辑2中的活动看起来像剪辑1的扩展”的问题。剪辑之间有很小的间隙-每个几百毫秒左右。如果结果足够好,我也可以手动修复结果,因此结果不需要完美。

EN

回答 1

Stack Overflow用户

发布于 2011-07-25 02:06:02

一种非常简单的方法可以是:

(a)创建一个自动过程,以提取已知图像格式(例如,JPG)的每个视频剪辑的第一帧和最后一帧,并根据视频剪辑名称命名它们,例如,如果您有视频剪辑:

clipA.avi、clipB.avi、clipC.avi

您可以创建以下帧图像:

clipA_first.jpg、clipA_last.jpg、clipB_first.jpg、clipB_last.jpg、clipC_first.jpg、clipC_last.jpg

(b)排序“算法”:

代码语言:javascript
复制
1. Create a 'Clips' list of Clip-Records containing each:

(a) clip-name (string)
(b) prev-clip-name (string)
(c) prev-clip-diff (float)
(d) next-clip-name (string)
(e) next-clip-diff (float)

2. Apply the following processing:

for Each ClipX having ClipX.next-clip-name == "" do:
{
    ClipX.next-clip-diff = <a big enough number>;
    for Each ClipY having ClipY.prev-clip-name == "" do:
    {
       float ImageDif =  ImageDif(ClipX.last-frame.jpg, ClipY.first_frame.jpg);
       if (ImageDif < ClipX.next-clip-diff)
       {
           ClipX.next-clip-name = ClipY.clip-name;
           ClipX.next-clip-diff = ImageDif;
       }
    }
    Clips[ClipX.next-clip-name].prev-clip-name = ClipX.clip-name;
    Clips[ClipX.next-clip-name].prev-clip-diff = ClipX.next-clip-diff;
}

3. Scan the Clips list to find the record(s) with no <prev-clip-name> or 
   (if all records have a <prev-clip-name> find the record with the max <prev-clip-dif>.
   This is a good candidate(s) to be the first clip in sequence.

4. Begin from the clip(s) found in step (3) and rename the clip-files by adding 
   a 5 digits number (00001, 00002, etc) at the beginning of its filename and going 
   from aClip to aClip.next-clip-name and removing the clip from the list.

5. Repeat steps 3,4 until there are no clips in the list.

6. Voila! You have your sorted clips list in the form of sorted video filenames! 
   ...or you may end up with more than one sorted lists (if you have enough 
   'time-gap' between your video clips).

非常简单化...但我认为它是有效的……

PS1:关于ImageDif()函数:您可以创建一个新的DifImage,这是图像ClipX.last-frame.jpg,ClipY.first_frame.jpg的差异,然后将DifImage的所有像素求和为一个浮点ImageDif值。如果您的和大于某个限制,您还可以优化过程以中止差值(或求和过程):您实际上对微小的差值感兴趣。大于(实验)限制的ImageDif值意味着这两个图像差别太大,以至于两个剪辑不可能是彼此相邻的。

PS2:排序算法的复杂度顺序必须大约为O(n*log(n)),因此对于1000个视频剪辑,它将执行大约3000次图像比较(如果您优化算法,并允许它在某些剪辑中找不到匹配,则会执行更多)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6723087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档