View Full Version : Can I use ffmpegsource/ffvideosource to determine video format
wiseant
11th September 2012, 23:53
Hi
I looked through the docs for ffmpegsource - couldn't find what I was looking for.
Can I use ffmpegsource/ffvideosource avisynth plugin [ffms2.dll] to determine the type of video codec, i.e. 264, vc1, or mpeg-2/mpv/m2v re ts or m2ts clip?
TIA
TheFluff
12th September 2012, 09:47
FFMS2 does not expose that information, no.
StainlessS
12th September 2012, 14:10
You saw the MediaInfo demo in another thread
(http://forum.doom9.org/showthread.php?p=1590078#post1590078)
MediaInfo allows you to use a template to query the info that your after, and you could I think access via RT_Stats funcs (although I have not tried it).
wiseant
12th September 2012, 20:41
@TheFluff
Thanks for the info
@StainlessS
Yes, I saw that MediaInfo demo - and did a test run with it - another great tool
Looks like that is best way to do this with an avisynth script - I have been avoiding using MediaInfo - probably cause I was too lazy to figure out all the syntax commands
wiseant
13th September 2012, 02:45
@StainlessS
Well this seems to work as long as RTCall.avs is in the same folder i.e. D:\MediaTest along with MediaInfo.dll, MediaInfo.exe, and Template.txt
RTCall.avs
FN = "D:\newmobcal1440_12mbps.ts"
filename = "D:\MediaTest\mymedia.bat"
quote = chr(34)
media = "mediainfo.exe --Inform=file://Template.txt " + quote + FN + quote + " >> sept12.txt"
RT_TxtWriteFile(media,filename)
RT_Call("D:\MediaTest\mymedia.bat")
retrun ColorBars()
Template.txt:
General;ClipName->%CompleteName%\nVideoCodec:%Video_Format_List%\nAudioCodec:%Audio_Format_List%\n
Video;VideoWidth:%Width%\r\nVideoHeight:%Height%\r\nVideoFramerate:%FrameRate%\r\nVideoFrameCount:%FrameCount%\r\nVideoStreamSize in bytes:%StreamSize%\r\nVideoDuration in ms:%Duration%\r\nVideoBitrate in bps:%BitRate%\r\nPixelAspectRatio:%PixelAspectRatio%\r\nDisplayAspectRatio:%DisplayAspectRatio%\r\n
Audio;AudioDuration in ms:%Duration%\r\nAudioBitRate in bps:%BitRate%\r\nAudioChannels:%Channel(s)%\r\nAudioSamplingRate:%SamplingRate%\r\nAudioStreamSize in bytes:%StreamSize%
Output:
ClipName->D:\newmobcal1440_12mbps.ts
VideoCodec:MPEG Video
AudioCodec:AC-3
VideoWidth:1440
VideoHeight:1080
VideoFramerate:29.970
VideoFrameCount:1810
VideoStreamSize in bytes:104715052
VideoDuration in ms:60394
VideoBitrate in bps:13870984
PixelAspectRatio:1.333
DisplayAspectRatio:1.778
AudioDuration in ms:60128
AudioBitRate in bps:384000
AudioChannels:2
AudioSamplingRate:48000
AudioStreamSize in bytes:2886144
Works opening RTCall.avs in VirtualDub, AvsPMod, and MediaPlayerClassic
Perhaps you can come up with a better way to implement this . .
wiseant
13th September 2012, 09:29
Updated:
By using Template.txt with RT_Call:
RT_Call("MediaInfo.Exe" + " --LogFile=" + "sept12.txt" + " --Inform=file://Template.txt " + "D:\newmobcal1440_12mbps.ts")
return colorbars()
StainlessS
13th September 2012, 22:41
Currently modding AutoCropLevelsGenny.avs to take a MediaInfo template (like yours above) with a paired replacement file,
so replacement file (line for line matching the mediainfo template) might contain eg:-
[MI_CLIPNAME]
[MI_VIDEOCODEC]
[MI_AUDIOCODEC]
[MI_VIDEOWIDTH]
[MI_VIDEOHEIGHT]
for the first first few lines in your template, so you could insert eg [MI_VIDEOCODEC] into the template log file (or AVS or Cmd or Group command file).
Would allow you to select any info you like that is output by Mediainfo and insert it into a generated log, avs or command file.
Also adding a group command file (containing commands for entire directory of clips) with header and tail templates,
so eg head might ask for input (eg bitrate) and tail might wait for keypress.
wiseant
14th September 2012, 04:56
@StainlessS
Now that sounds interesting
I was thinking - it would be possible to analyze a video using various tools, create a custom batch file for encoding, and run the batch file from VirtualDub that can use x264 or HCEnc - all within an avs file . . .
StainlessS
14th September 2012, 09:32
There is a prob with the above mentioned paired replacement, if you want a specific stream eg Eng subs for hard of hearing.
It would have no way at all of knowing what you want, it only matches the pair of template lines and simply replaces text.
You might be able to eg fetch data for the first n sets of subs and in script, make them into pseudo arrays using
RT_TxtAddStr, then scan the arrays to figure out which is closest to the required.
I dont myself really need that, I usually dump non wanted streams during ripping.
Anyway, the script when done will just be a demo, and intended as a starting point for more adventurous scripts.
Keep getting bitten by the 4096-1 string concatenation/allocation bug in 2.58 & 2.6a3, you really need to be using the RT_StrAddStr and
RT_TxtAddStr functs to avoid, thought I'd discovered another string bug, but turned out I had somehow reverted back to
an earlier version of this script function (StrReplace):-
http://forum.doom9.org/showthread.php?p=1590402#post1590402
Although, I have to wonder if the bug can appear in eg LeftStr, MidStr etc too. EDIT: No it cant.
EDIT: 4096-1 bug, not affect filenames, too short.
Gavino
14th September 2012, 10:05
I have to wonder if the bug can appear in eg LeftStr, MidStr etc too.
The bug is due to incorrect interpretation of the value returned by _vsnprintf() and only affects string concatenation (with the '+' operator).
LeftStr, MidStr, etc, use strncat() and are not affected.
StainlessS
14th September 2012, 10:13
Danke Sehr.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.