[MPlayer-users] current position
Hugo González Monteverde
hugonz-lists at h-lab.net
Fri Aug 12 06:30:24 CEST 2005
Hi Vinnay,
I wrote a front end using popen2 and Python, which gets the time using
get_percent_pos, the problem is that it has a granularity of 0.01*
length of file (at best, since you can only seek to a keyframe)
I remember reading a post about a patch to be added, that incorporate
the get_time_pos... I wonder if it is in CVS yet.
I do use -quiet because parsing the output without it is a real PITA
given the performance of python and buffering.
Anyway, let me know if you want me to send my script. It is not very
long and I can send it to the list too...
Hugo
Vinay Reddy wrote:
>>>don't use the -quiet option, do I start a separate thread in my
>>>program which deals with mplayer output? What about the replies to
>>>commands that I send to mplayer? Won't the status messages come in
>>>between? Will I have to parse the output to find out if it's a status
>>>message or a reply to my query?
>>
>>Don't use -quiet. In fact, it might be better to use -v. Yes, you will
>>have to parse MPlayer's output. No, you don't need to start another
>>thread. The very suggestion tells me you might be a Java programmer. :)
>
>
> True, more or less.
>
>
>>I'm not sure how you are interfacing with MPlayer, but the nature of
>>your questions suggests you're not doing it the right way. If you were,
>>none of these things would be problems.
>>
>>You'll need to spawn MPlayer such that you can communicate with it
>>bidirectionally. High level languages tend to have this ability
>>natively. (In Python, for example, see the popen2 module.) In C,
>>you'll have to setup a pair of pipes and fork. (Google for
>>"bidirectional communication fork" or some such.)
>
>
> I am programming in Python (my first program in this language) and I
> am using the popen2 call. I communicate with mplayer using the two
> pipes that are returned on calling popen2.
>
>>Your application's main loop will select(2) on the file descriptor that
>>maps to mplayer's stdout. When there's output, handle it line by line
>>and parse it for the lines you're interested in. For status output,
>>look for lines that start with "A:" or "V:" and from there you can
>>easily parse the time.
>>
>>You should not require that mplayer outputs lines in an expected order.
>>If you handle output as described above, you won't have to.
>
>
> Thanks a lot. This sure clears everything (At this point it seems so ;-)).
>
> Regards,
> Vinay
>
> _______________________________________________
> MPlayer-users mailing list
> MPlayer-users at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-users
>
More information about the MPlayer-users
mailing list