View Full Version : Mplayer and Python
Razorholt
28th June 2008, 08:14
Hello -
I'm finishing (Finally!) my GUI based on Python + mplayer but I noticed that when I play any files with it there are some frames dropping issues.
Anybody else noticed it?
Thanks,
- Dan
mplayer cmd
params = (" -vo directx -adapter 1 -slave -quiet -nocolorkey -priority abovenormal " +
"-ao win32 -softvol -softvol-max 100.0 -af volnorm -speed 1 " +
"-fs ")
LoRd_MuldeR
28th June 2008, 12:41
1. Why use "-softvol", is there a specific reason?
2. Why use "-ao win32" instead of "-ao dsound", which apparently is the preferred audio renderer under Windows?
3. Try "-vo gl:yuv=2:force-pbo:ati-hack" instead of "-vo directx". It's much faster and doesn't need to worry about "-adapter".
4. Try adding "-framedrop" (this is soft framedrop) for better performance.
reepa
28th June 2008, 17:04
2. Why use "-ao win32" instead of "-ao dsound", which apparently is the preferred audio renderer under Windows?
For me -ao dsound cuts off audio at the end (i.e. stops playing back the file too soon). Win32 works correctly.
Razorholt
28th June 2008, 19:38
1. Why use "-softvol", is there a specific reason?
2. Why use "-ao win32" instead of "-ao dsound", which apparently is the preferred audio renderer under Windows?
3. Try "-vo gl:yuv=2:force-pbo:ati-hack" instead of "-vo directx". It's much faster and doesn't need to worry about "-adapter".
4. Try adding "-framedrop" (this is soft framedrop) for better performance.
Ok, I did all that but "-vo gl:yuv=2:force-pbo:ati-hack" gives me sound only, no video :( On the other hand "-vo gl:yuv=2" gives me sound + B&W video :rolleyes:
As for "-ao dsound" I guess it works as good as "-ao win32".
Thanks!
LoRd_MuldeR
28th June 2008, 19:44
Ok, I did all that but "-vo gl:yuv=2:force-pbo:ati-hack" gives me sound only, no video :(
Are your graphics drives up-to-date? Are you on ATI or Nvidia? Is your MPlayer build up-to-date too?
Razorholt
28th June 2008, 20:26
INTEL(R) EXTREME GRAPHICS REPORT
Report Date: 06/28/2008
Report Time[hr:mm:ss]: 14:16:44
Driver Version: 6.14.10.4342
Operating System: Windows NT* 5.1.2600 Service Pack 2
Default Language: English
DirectX* Version: 9.0
Physical Memory: 510 MB
Min. Graphics Memory: 1 MB
Max. Graphics Memory: 64 MB
Graphics Memory in use: 6 MB
Processor: x86
Processor Speed: 2192 MHZ
Vendor ID: 0x8086
Device ID: 0x2562
Device Revision: 1
* Output Devices Connected to Graphics Accelerator *
Active Monitors:1
Yes Sir, that's my powerful Dell Dimension machine... right there!!! Woohoo! :D
Mplayer is up-to-date as well as all the drivers. :)
LoRd_MuldeR
28th June 2008, 20:29
I think an OpenGL 2.0 capable graphics card will be required for the GL renderer...
Razorholt
28th June 2008, 20:36
Video card: Intel(R) 82845G/GL/GE/PE/GV
You may be right... But I should be able to use GL, right?
Razorholt
28th June 2008, 20:41
Can I print the FPS info on the screen in realtime? What would be the cmd for that?
LoRd_MuldeR
28th June 2008, 20:55
I use ATI Tray Tools for that. FRAPS would be an alternative...
Leak
28th June 2008, 23:22
Video card: Intel(R) 82845G/GL/GE/PE/GV
You may be right... But I should be able to use GL, right?
Open GL? Maybe.
Open GL 2.0? Probably not.
Your onboard graphics chipset is from 2002, the Open GL 2.0 spec is from 2004...
np: The Orb - Terminus (Cydonia Remastered)
Razorholt
29th June 2008, 01:21
ok, so if I keep directx what can I do to solve the frames dropping issue? I tried "-nodouble", "-noframedrop" as well as "-framedrop" and "hardframedrop" in case the CPU couldn't cope with the frames rate. All that failed :(
Again, the file plays well in SMplayer but won't play flawlessly using my Python script.
Thanks for your suggestions.
LoRd_MuldeR
29th June 2008, 01:34
Instead of "-nocolorkey" try to use the overlay with a proper colorkey, like "-colorkey 0x020202".
Of course you'll have to fill your video window with that color.
Also: Do you pass the correct window handle? I cannot see "-wid" in your parameter list :confused:
Razorholt
29th June 2008, 01:58
Of course you'll have to fill your video window with that color.
What do you mean by that? How do I do it?
Also: Do you pass the correct window handle? I cannot see "-wid" in your parameter list
Yes, yes. I add -wid to the final cmd line.
def Go(self,name):
global threadStop
threadStop = 0
self.timeposition=0
self.cmdSW = 0
self.stdoutQueue = Queue.Queue()
params = ("-vo directx -adapter 1 -slave -quiet -nocolorkey -priority abovenormal " +
"-ao dsound -softvol-max 100.0 -af volnorm " +
"-fs ")
h = self.GetHandle()
winID = " -wid " + str(h) + " "
self.mpc = "mplayer " + winID + params + name
print self.mpc
self.mplayer = subprocess.Popen(self.mpc, bufsize=1000,
stdin=subprocess.PIPE,stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
self.stdoutThread = thread.start_new_thread(stdoutReader,
(self,
self.mplayer.stdout))
LoRd_MuldeR
29th June 2008, 02:32
What do you mean by that? How do I do it?
Well, you pass the handle of the window, in which you want the video to appear, to MPlayer. Right?
That window is part of your application, so it shouldn't be a problem to fill that window with a certain color, e.g. 0x020202.
Now you simply pass this color as "-colorkey" to MPlayer and that's it.
The video overlay will then shine through all the pixels that have the specified keycolor - in your application or in another one.
AFAIK that is how video overlay works since ever...
Razorholt
29th June 2008, 02:49
Oh I see. That would be the place:
self.SetBackgroundColour((0x00,0x0,0x0))
And that helps how? What's the benefit?
Thanks,
-Dan
LoRd_MuldeR
29th June 2008, 02:58
And that helps how? What's the benefit?
That's how "overlays" work. Not more. not less :p
An application using a hardware overlay gets a completely separate section of video memory that belongs only to that application. Because nothing else uses it, the program never needs to waste time considering whether a given piece of the memory belongs to it, nor does it need to worry about the user moving the window and changing the location of the video memory. To get the image from the separate video memory to display in tandem with the remaining shared elements on the display, the graphical subsystem associates a certain attribute (for example, a particular color) to be a "mask" for that overlay, which the graphics card understands to mean that it is to draw from the separate overlay buffer onto the screen. (This technique is commonly known as "chroma key".)
http://en.wikipedia.org/wiki/Hardware_overlay
Razorholt
29th June 2008, 03:35
Alrighty... At least I got that one fixed :thanks:
How about the not so flawless video? No idea at all?
Thanks for your help LoRd_MuldeR. I really do apreciate your time :)
LoRd_MuldeR
29th June 2008, 03:41
You could try direct rendering "-dr" and/or you could try raising the priority of the MPlayer process.
Also make sure that no other application has already created on overlay interface, when mplayer starts up.
Only one application can use a video overlay with full hardware acceleration.
Razorholt
29th June 2008, 04:00
You could try direct rendering "-dr" and/or you could try raising the priority of the MPlayer process.
Both have no effects.
Also make sure that no other application has already created on overlay interface, when mplayer starts up.
Only one application can use a video overlay with full hardware acceleration.
checked that twice. Still no improvement.
What kills me is that SMplayer plays that file just fine :devil: Why my cmd won't give the same result??? :o
Razorholt
29th June 2008, 07:10
Some results from FRAPS:
2008-06-29 01:03:52 - mplayer
Frames: 953 - Time: 40021ms - Avg: 23.812 - Min: 18 - Max: 28
2008-06-29 01:04:55 - mplayer
Frames: 256 - Time: 10672ms - Avg: 23.988 - Min: 20 - Max: 26
The video is 23.976 fps so I guess the average is fine but look at the Min. and Max. FPS. Is it pretty much what I should expect from any video?
Razorholt
29th June 2008, 18:35
Well... I think I fixed the issue and this is thanks to Lord_Mulder!!
The problem was "-ao win32" that was probably trying to have the audio stay in synch with the video and forcing frames to drop or something. I switched to "-ao dsound" as it was advised earlier BUT I also changed my cmd line as well as the mplayer version.
Now it plays sooo flawlessly :)
OT: Is there any recent 4MB ish mplayer.exe version out there? I have one that I took from SMplayer but I have to fire it twice before it shows the video... weird.
Edit: The 4MB version of mplayer I have is: Sherpya-SVN-r24762-4.2.1 but I don't know whether it is fro P4, Celeron, etc...
LoRd_MuldeR
30th June 2008, 14:07
OT: Is there any recent 4MB ish mplayer.exe version out there?
If you have a MPlayer.exe that is only 4 MB in size, it was compressed with UPX most likely :p
I have one that I took from SMplayer but I have to fire it twice before it shows the video... weird.
This sounds like the problem discussed here:
http://forum.doom9.org/showpost.php?p=1151051&postcount=615
Razorholt
1st July 2008, 07:26
If you have a MPlayer.exe that is only 4 MB in size, it was compressed with UPX most likely :p
Got it!
This sounds like the problem discussed here:
http://forum.doom9.org/showpost.php?p=1151051&postcount=615
Could be but I'm not on ATI.
Also, regarding "-ao dsound" when I stream a video and it stalls - or buffer - the audio goes into a loop repeating the last half second sound until the video resumes. I didn't get it with "-ao win32". How can I fix it?
Thanks,
- Dan
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.