确定连续的视频剪辑

发布于 2024-11-24 22:21:56 字数 169 浏览 2 评论 0原文

我有一个很长的视频流,但不幸的是,它的形式是 1000 个 15 秒长的随机命名的剪辑。我想根据两个这样的 15 秒剪辑的“相似性”的某种衡量标准来重建原始视频,回答“剪辑 2 中的活动似乎是剪辑 1 的延伸”的问题。剪辑之间有很小的间隙——每个间隙大约几百毫秒。如果结果足够好,我还可以手动修复结果,因此结果不必是完美的。

I a long video stream, but unfortunately, it's in the form of 1000 15-second long randomly-named clips. I'd like to reconstruct the original video based on some measure of "similarity" of two such 15s clips, something answering the question of "the activity in clip 2 seems like an extension of clip 1". There are small gaps between clips --- a few hundred milliseconds or so each. I can also manually fix up the results if they're sufficiently good, so results needn't be perfect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋风の叶未落 2024-12-01 22:21:56

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

(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) 排序“算法”:

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 值意味着 2 个图像差异很大,以至于 2 个剪辑不能彼此相邻。

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

A very simplistic approach can be:

(a) Create an automated process to extract the first and last frame of each video-clip in a known image format (e.g. JPG) and name them according to video-clip names, e.g. if you have the video clips:

clipA.avi, clipB.avi, clipC.avi

you may create the following frame-images:

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

(b) The sorting "algorithm":

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).

Very simplistic... but I think it can be effective...

PS1: Regarding the ImageDif() function: You can create a new DifImage, which is the difference of Images ClipX.last-frame.jpg, ClipY.first_frame.jpg and then then sum all pixels of DifImage to a single floating point ImageDif value. You can also optimize the process to abort the difference (or sum process) if your sum is bigger than some limit: You are actually interested in small differences. A ImageDif value which is larger than an (experimental) limit, means that the 2 images differs so much that the 2 clips cannot be one next each other.

PS2: The sorting algorithm order of complexity must be approximately O(n*log(n)), therefore for 1000 video clips it will perform about 3000 image comparisons (or a little more if you optimize the algorithm and you allow it to not find a match for some clips)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文