我正在尝试检测某个视频是否包含任何有效内容,或者只是标准的广播栏&音。到目前为止,我已经查看了这个问题:https://superuser.com/questions/1036449/detect-color-bars-ffmpeg/1036478#1036478 产生酒吧&第一帧的音调,然后将其与流的其余部分进行比较,但在我的情况下,我需要在一个只有一个文件的文件夹中运行ffmpeg命令,该文件已经被我的python脚本找到。
是否可以使用ffmpeg' blend = difference来检查短条和&音调片段是我的一个视频文件的子片段?我正在考虑这个问题,就像检查一个字符串是否在一个字符串中一样,或者是否有更好的方法来检查我没想到的条形图?
谢谢!
答案 0 :(得分:0)
我找到了一种让我的脚本用python和ffmpeg做我想做的事的方法:
有关此ffmpeg命令如何工作的信息: http://ffmpeg.org/ffmpeg-filters.html#Video-Filters question
----------------------------------------------- ---------开始代码--------------------------------------- ----------------
selection = "'gt(scene\,0.1)'" # The decimal here is the threshold for determining video quality (0 -> 1)
proc5 = Popen('C:/ffmpeg/bin/ffmpeg.exe -i "'+ src +'" -vf "select='+ selection +'" -vsync 0 -f image2 -y //fn101cdmzst01.foxneo.com/signiant/foxsports/soundmouse/FileManagerInfo/Thumbnails/thumbnails-%02d.jpg 2>&1', stdout=PIPE, shell=True) # This is the ffmpeg command. The specifics of how it works are explained below
res, err = proc5.communicate() # Read proc5's (the ffmpeg command) stdout to res and stderr to err
proc5.wait() # Wait for ffmpeg to finish processing the whole video file
res = str(res.decode('ascii')) # Decode the ascii output from stdout and convert to a string
print(res)
if r"Output file is empty" in res: # If the ascii output from stdout has the string "Output file is empty", remove it. Otherwise, perform name changes and file move for soundmouse
----------------------------------------------- ------------ END CODE ------------------------------------ -------------------
FFMPEG COMMAND: 'C:/ffmpeg/bin/ffmpeg.exe -i "'+ src +'" -vf "select='+ selection +'" -vsync 0 -f image2 -y //fn101cdmzst01.foxneo.com/signiant/foxsports/soundmouse/FileManagerInfo/Thumbnails/thumbnails-%02d.jpg 2>&1'
实际的ffmpeg命令根据它执行的各种操作突出显示。
C:/ffmpeg/bin/ffmpeg.exe # make an absolute path call to ffmpeg.exe
-i "'+ src +'" # set the absolute path to the source file as the input
-vf "select='+ selection +'" # use a video filter to select frames with large change before and after (based on the decimal threshold that is set) and compare it with the following portion of the command
-vsync 0 -f image2 -y //fn101cdmzst01.foxneo.com/signiant/foxsports/soundmouse/FileManagerInfo/Thumbnails/thumbnails-%02d.jpg # compare the selected frame with the previous one stored in the Thumbnails folder and then overwrite the comparison thumbnail with the selected frame for the next comparison
2>&1' # redirect stderr to stdout so that we can read it with Python's proc5.communicate() function