File: testfilm_prop_ced.py

package info (click to toggle)
pymecavideo 6.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,996 kB
  • sloc: python: 4,604; xml: 881; makefile: 134
file content (68 lines) | stat: -rw-r--r-- 2,169 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import print_function

import sys
import threading
import os.path

import cv


class film:
    """
    Une classe pour accéder aux images d'un film
    """

    def __init__(self, filename):
        """
        le constructeur
        @param filename le nom d'un fichier video
        """
        self.filename = filename
        self.filesize = os.path.getsize(filename)
        self.capture = cv.CreateFileCapture(self.filename)
        t = threading.Thread(target=self.autoTest)
        t.start()
        t.join(5.0)  # attente de 5 secondes au plus


    def autoTest(self):
        self.ok = False
        try:
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_POS_MSEC)
            print ("CV_CAP_PROP_POS_MSEC : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_POS_FRAMES)
            print ("CV_CAP_PROP_POS_FRAMES : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_POS_AVI_RATIO)
            print ("CV_CAP_PROP_POS_AVI_RATIO : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FRAME_WIDTH)
            print ("CV_CAP_PROP_FRAME_WIDTH : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FRAME_HEIGHT)
            print ("CV_CAP_PROP_FRAME_HEIGHT : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FPS)
            print ("CV_CAP_PROP_FPS : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FOURCC)
            print ("CV_CAP_PROP_FOURCC : ", self.data)
            self.data = cv.GetCaptureProperty(self.capture, cv.CV_CAP_PROP_FRAME_COUNT)
            print ("CV_CAP_PROP_FRAME_COUNT : ", self.data)
            self.ok = True
        except:
            pass

    def __int__(self):
        return int(self.ok)

    def __nonzero__(self):
        return self.ok


if __name__ == '__main__':
    if len(sys.argv) > 1:
        vidfile = sys.argv[1]
        if film(vidfile):
            sys.exit(0)
        else:
            sys.exit(1)