Media Analysis
Sometimes, if you find yourself in a situation where it is not clear what kind of file is with video or sound, there is a need or desire to extract useful content from the media file.
Here, most often, YouTube comes to the rescue. Just load the file there and it does everything as it should. But YouTube is not omnipotent.
It is clear that frank garbage fell into my hands, but curiosity took its toll and I decided to dig deeper. To begin with, I tried to do the simplest: I changed the extensions, tried to open it with different programs, but it would not be interesting to write about this.
Then I tried to feed the file to ffprobe:
Nothing.
Back, silence.
Armed with my favorite AutoIt tool.
We get the codecs from the format description file, substitute them as an extension, feed ffprobe. If the output of ffprobe resulted in a file longer than 20 bytes, then try to convert the source to dvvideo or to sound.
So, everything worked out for me, in half an hour I already had a bunch of files with which I could already work.
Here, most often, YouTube comes to the rescue. Just load the file there and it does everything as it should. But YouTube is not omnipotent.
It is clear that frank garbage fell into my hands, but curiosity took its toll and I decided to dig deeper. To begin with, I tried to do the simplest: I changed the extensions, tried to open it with different programs, but it would not be interesting to write about this.
Then I tried to feed the file to ffprobe:
ffprobe -v quiet -print_format ini -show_format -show_streams "in" > "in.ini"
Nothing.
ffprobe -v quiet -print_format ini -show_format -show_streams "in.avi" > "in.avi.ini"
Back, silence.
Armed with my favorite AutoIt tool.
#include
#include
RunWait("cmd /c ""ffmpeg -formats > formats.txt""")
Sleep(100)
$f = FileOpen("formats.txt")
$s = " "
$file = "in"
$prev = ""
$sFile = $file
$descriptionFile = $sFile & ".ini"
$cmd_info = "cmd /c ""ffprobe -v quiet -print_format ini -show_format -show_streams " & $sFile & " > """ & $descriptionFile & """"
RunWait($cmd_info)
Sleep(100)
If FileGetSize($descriptionFile) > 20 Then
$cmd_video = "ffmpeg -i " & $sFile & " -target dvvideo " & $sFile & ".avi"
RunWait($cmd_video)
Sleep(100)
$cmd_audio = "ffmpeg -i " & $sFile & " -vn -c:a pcm_s16le " & $sFile & ".wav"
RunWait($cmd_audio)
Sleep(100)
Else
FileDelete($descriptionFile)
EndIf
While $s <> ""
$s = FileReadLine($f)
$ext = "." & StringMid($s, 5, StringInStr(StringMid($s, 5), " ") - 1)
FileMove($file & $prev, $file & $ext, $FC_OVERWRITE)
$sFile = $file & $ext
$descriptionFile = $sFile & ".ini"
$cmd_info = "cmd /c ""ffprobe -v quiet -print_format ini -show_format -show_streams " & $sFile & " > """ & $descriptionFile & """"
RunWait($cmd_info)
$prev = $ext
Sleep(500)
If FileGetSize($descriptionFile) > 20 Then
$cmd_video = "ffmpeg -i " & $sFile & " -target dvvideo " & $sFile & ".avi"
RunWait($cmd_video)
Sleep(100)
$cmd_audio = "ffmpeg -i " & $sFile & " -vn -c:a pcm_s16le " & $sFile & ".wav"
RunWait($cmd_audio)
Sleep(100)
Else
FileDelete($descriptionFile)
EndIf
WEnd
FileClose($f)
We get the codecs from the format description file, substitute them as an extension, feed ffprobe. If the output of ffprobe resulted in a file longer than 20 bytes, then try to convert the source to dvvideo or to sound.
So, everything worked out for me, in half an hour I already had a bunch of files with which I could already work.