NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 41 42 43 44 45 … 93 Next »
Easy way to get MPG Framecount?

 
  • 0 Vote(s) - 0 Average
Easy way to get MPG Framecount?
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#1
2006-09-02, 03:12 PM
Easy way to get MPG Framecount?

This seems to be rather illusive on the net. Most folks run through a file and when it ends, you have a frame count...

I already have one way, and that is to attack the text file from Comskip, and parse out of it the detected Framecount. But I want to get the frame count before Comskip runs...

I'm using VB6... Wouldn't mind getting it from ffmpeg, but can't figure out the switches...

Any help would be great...
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#2
2006-09-03, 01:43 PM
I know it's a long weekend for many people, but...

bump
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,944
Threads: 770
Joined: Nov 2003
#3
2006-09-03, 04:53 PM
Are you looking from the total number of frames in the files, or the frames per second?

Either way, MPEG videos typically arnt very easy to extract this type of information in code. It would involve parsing the MPEG2 file, and extracting the fps from one of the sequence header packets, or parsing the first PES and last PES to extract the first and list timestamp and multiply it by the fps if you need the approximate total frame count.
-stattik-
Offline

Posting Freak

Posts: 924
Threads: 26
Joined: Mar 2005
#4
2006-09-05, 03:44 AM
You can use mencoder to report the total length and fps of a recording. Multiplying the two together should give you a pretty accurate framecount. I've got the mencoder arguments if you need them.
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#5
2006-09-08, 04:58 PM
I have to say, that I've been avoiding using Mencoder only because it doesn't come stock with GB-PBR. ZProcess and GB-PVR's access to transcoding is all done through ffmpeg...

But I guess GB-PVR doesn't come with comskip or comclean either...

If Mencoder can give me a frames/length without having to process the whole file, it might be thge way to go...

What would those switches be, and where is your source for that info?

Thanks
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
-stattik-
Offline

Posting Freak

Posts: 924
Threads: 26
Joined: Mar 2005
#6
2006-09-08, 08:28 PM
Actually it's mplayer not mencoder. Copy this line into a bat file and save it. Drop a video on the bat file and you should get an .info file that should have the FPS and show length. You just need to load those variables into your app and you should be able to get total frames.

Code:
D:\progra~1\mplayer\mplayer.exe %1 -identify -frames 0 >%1.info

Edit the path to mplayer as needed.
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#7
2006-09-08, 10:21 PM
-stattik- Wrote:Actually it's mplayer not mencoder. Copy this line into a bat file and save it. Drop a video on the bat file and you should get an .info file that should have the FPS and show length. You just need to load those variables into your app and you should be able to get total frames.

Code:
D:\progra~1\mplayer\mplayer.exe %1 -identify -frames 0 >%1.info

Edit the path to mplayer as needed.

Thanks
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#8
2007-07-21, 03:28 AM
Revisiting this...

With the following batch file, there is about a second (maybe more) as mplayer (I think) starts up a couple of codecs.... I don't need that.

Code:
"C:\Program Files\mplayer\mplayer.exe" %1 -frames 0 > %1.info

The results...

Code:
MPlayer 1.0rc1-3.4.2 (C) 2000-2006 MPlayer Team
CPU: AMD Sempron(tm) Processor 3100+ (Family: 15, Model: 44, Stepping: 2)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 0 SSE2: 0
Compiled with runtime CPU detection.

Playing D:\TV\Recorded\Robot Chicken\Robot.Chicken-S01E11-Toy.Meets.Girl.avi.
AVI file format detected.
VIDEO:  [XVID]  512x384  24bpp  29.970 fps  1279.6 kbps (156.2 kbyte/s)
Clip info:
Software: Nandub v1.0rc1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [dsound] 44100Hz 2ch s16le (2 bytes per sample)
Starting playback...


Exiting... (End of file)

Could I get a faster discovery if I turn off the video and audio codecs? And how would I do that?
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#9
2007-07-24, 09:13 PM
Found the answer: Here's my VB6 Code snippet...

Code:
Private Sub GetFileInfo()

If txtInputFilename = "" Then Exit Sub

'fires up mplayer to get info on file, populates form

cmdline = Chr(34) & MEncoderPath & "\mplayer.exe" & Chr(34) & " " & _
        Chr(34) & txtInputFilename & Chr(34) & _
        " -identify -vo -ao  > " & Chr(34) & App.Path & "\dimensions.info" & Chr(34)
Open App.Path & "\GetDimensions.bat" For Output As #1
    Print #1, cmdline
Close #1
DoEvents

RunShellAndWait Chr(34) & App.Path & "\GetDimensions.bat" & Chr(34), vbHide

txtInputWidth = StringFromTextFile.StringFromTextFile(App.Path & "\dimensions.info", "ID_VIDEO_WIDTH=", " ")
txtInputHeight = StringFromTextFile.StringFromTextFile(App.Path & "\dimensions.info", "ID_VIDEO_HEIGHT=", " ")
txtInputFPS = StringFromTextFile.StringFromTextFile(App.Path & "\dimensions.info", "ID_VIDEO_FPS=", " ")
txtInputLengthSecs = StringFromTextFile.StringFromTextFile(App.Path & "\dimensions.info", "ID_LENGTH=", " ")
txtDuration = Format(txtInputLengthSecs / 24 / 60 / 60, "h:mm:ss")
txtInputAspectRatio = GetRect(txtInputWidth, txtInputHeight)
txtInputFrames = Int(txtInputLengthSecs * IIf(Int(txtInputFPS) = 1000, 25, txtInputFPS))
txtAspectInt = txtInputWidth / txtInputHeight

DoEvents

KillIfExists App.Path & "\GetDimensions.bat"
KillIfExists App.Path & "\dimensions.info"

End Sub

..\mplayer.exe" [txtInputFilename] -identify -vo -ao > dimensions.info"

By adding the video and audio codecs switches, but not actually specifying codec names. MPlayer stops opening the file before it even starts...

Very quick.
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Easy .net snippet for accessing config.xml? zehd 3 1,916 2008-03-23, 05:58 AM
Last Post: zehd
  Easy version control for assemblies? bgowland 3 1,867 2008-02-21, 08:28 AM
Last Post: Ernie-c
  easy way to keep track if visualization is in fullscreen? reven 0 1,233 2006-01-21, 05:45 AM
Last Post: reven

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode