代码之家  ›  专栏  ›  技术社区  ›  spuder

如何检测视频文件是否纯静态?

  •  4
  • spuder  · 技术社区  · 6 年前

    以下实用程序有用于分析视频的命令行选项,但是没有一个具有检测视频内容缺失的内置功能。

    1. ffmpeg格式

    2. FFP探头

    3. 手刹

    我尝试过使用ffmpeg导出静态图像,然后使用 image magick 比较这些图像之间的差异。不幸的是,静态图像和实际视频内容之间的差异返回几乎相同的差异百分比。(9%对7%)

    ffmpeg -ss 00:30 -i PICT0050.AVI -vframes 1 -q:v 2 output1.jpg
    
    magick compare -metric PSNR output1.jpg output2.jpg diff.jpg
    9.2191
    
    magick compare -metric PSNR output1.jpg output3.jpg diff.jpg
    7.70127
    


    比较样品1和样品3的结果有7%的差异

    enter image description here

    样本2 enter image description here 样品3 enter image description here 样品4 enter image description here 样品5 enter image description here enter image description here 样本7 enter image description here

    2 回复  |  直到 6 年前
        1
  •  4
  •   Mark Setchell    6 年前

    它看起来像是没有任何颜色的黑白静态图像-所以我会看看平均饱和度,如果它是低/零,我会假设它们是静态的。所以,在 bash 假设你的照片被命名为 sampleXXX.jpg

    for f in sample*jpg; do 
        convert "$f" -colorspace HSL -channel S -separate -format '%M avg sat=%[fx:int(mean*100)]\n' info:
    done
    

    样本输出

    sample1.jpg avg sat=0
    sample2.jpg avg sat=0
    sample3.jpg avg sat=21
    sample4.jpg avg sat=0
    sample5.jpg avg sat=39
    sample6.jpg avg sat=31
    

    这表明样品1、2和4是静态的。

        2
  •  1
  •   fmw42    6 年前

    另一种方法是使用Imagemagick对噪声量进行排序来查看边的数量。噪声图像将有更多的边缘。

    for img in *; do
    edginess=`convert $img -edge 1 -scale 1x1! -format "%[fx:mean]" info:`
    echo "$img $edginess"
    done
    
    1bidV.jpg 0.0472165
    3FJUJ.jpg 0.275502  <---- noise image
    QpQvA.jpg 0.332296  <---- noise image
    b4Gxy.jpg 0.0428422
    gQcXP.jpg 0.0437578
    vF1YZ.jpg 0.322911  <---- noise image