you have to write an algorithm in python or php. 

ffmpg -i media

and you parse the output using regular expressions in python it looks like that;


PYTHON CODE:
def bashandgrep (cmdtodo, patterns):
        ret = {}
    
    (child_stdin, child_stdout) = os.popen4(cmdtodo, 'r')
    output = child_stdout.read()
    
    for (name, pattern) in patterns.items():
                # print "scanning for %s" % name
                m = pattern.search(output)
                if m:
                        caps = m.groups()
                        if (len(caps) == 1):
                                ret[name] = caps[0]
                        else:
                                ret[name] = caps
        return ret


def get_duration(media):
    patterns = {
        'duration' : re.compile(r"Duration: ([0-9]+):([0-9]+):([0-9]+)")
    }
    
    command = "/usr/local/bin/ffmpeg -i %s"%media
    data = bashandgrep(command, patterns)

get_duration(media)
#media is a path to the video or sound clip

i don't know if it helps, that's how i do it








"fluke.l" <[EMAIL PROTECTED]> a écrit : Stas Oskin wrote:
> Hi.
>
> Is there any function that can return the duration of the media? I
> tried checking the libraries, but couldn't find any relevant function.
>   
I've write a code to get mp4 file duration.

I'm not familiar with other containers.

If you want a copy just let me know.
> Thanks in advance.
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
>   

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user


 __________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible 
contre les messages non sollicités 
http://mail.yahoo.fr Yahoo! Mail 
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to