2016-10-28 6 views
0

Ich versuche zu erkennen, ob ein Video einen gültigen Inhalt hat oder nur die Standard-Broadcasting-Bars & Ton ist. Bisher habe ich diese Frage angeschaut: https://superuser.com/questions/1036449/detect-color-bars-ffmpeg/1036478#1036478 erzeugt Balken & Ton aus dem ersten Frame und vergleicht dann das mit dem Rest des Streams, aber in meinem Fall muss ich den Befehl ffmpeg innerhalb eines Ordners ausführen, der nur eine Datei hat Das wurde bereits von meinem Python-Skript gefunden.FFMPEG erkennen Farbbalken und Ton in Video

Ist es möglich, ffmpegs blend = difference zu verwenden, um zu überprüfen, ob ein kurzer Balken & Tonclip ein Subclip einer meiner Videodateien ist? Ich denke darüber nach, wie Sie überprüfen können, ob sich eine Saite in einer Saite befindet, oder gibt es eine bessere Möglichkeit, nach Saiten zu suchen, an die ich nicht denke?

Danke!

Antwort

0

fand ich einen Weg, um meinen Skript zu bekommen, um zu tun, was ich mit Python und ffmpeg wollte:

Info auf, wie diese ffmpeg Befehl funktioniert: https://unix.stackexchange.com/questions/101558/compare-video-and-image-percentage-of-differences http://ffmpeg.org/ffmpeg-filters.html#Video-Filters

-------- ------------------------------------------------ BEGIN CODE -------------------------------------------------- -----

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 

-------------------------------------- --------------------- ENDE 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' 

Der eigentliche ffmpeg-Befehl wird entsprechend der verschiedenen ausgeführten Operationen hervorgehoben.

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