Update to use segment 11 of the Elephant's Dream (HD) data as test data.

Improve the reporting of ES unit data slightly.

--HG--
extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%4048
issue20
tibs 2008-09-02 12:18:15 +00:00
rodzic 8be8e9acf8
commit 657f94b363
4 zmienionych plików z 74 dodań i 43 usunięć

Wyświetl plik

@ -10,12 +10,26 @@ at least *some* predictable data to play with.
Contents of this directory Contents of this directory
========================== ==========================
Still to be finalised (but probably a segment of Elephant's Dream -- see the For Linux users, a convenient ``setup.sh`` is provided, which will use
links below for an explanation. ``wget`` to download a segment of `Elephant's Dream`_, ``unzip`` it, and
produce an ES file from (the resulting) TS file.
This is then used as test data by the doctests in the sibling ``python``
directory.
Useful links Useful links
============ ============
Consolidated list of test video clip resources
----------------------------------------------
http://forum.doom9.org/archive/index.php/t-135034.html
A hopefully usedul resource on the Doom9 forum.
Note the link to a list of "broken" streams:
http://forum.doom9.org/showthread.php?t=134693
Elephant's Dream Elephant's Dream
---------------- ----------------
http://www.elephantsdream.org/ http://www.elephantsdream.org/

20
data/setup.sh 100755
Wyświetl plik

@ -0,0 +1,20 @@
#! /bin/sh
#
# A very simple script to retrieve and pre-process test data, as used by
# ../python/rundoctest.py
#
# Assumes it is being run in the 'data' directory
# Assumes the presence of 'wget' and 'unzip', and that the tstools have been
# built.
# Retrieve a segment of Elephant's Dream in TS (11 is the smallest segment)
wget http://www.w6rz.net/ed24p_11.zip
unzip ed24p_11.zip
ts2es ed24p_11.ts ed24p_11.video.es
# Afterwards:
#
# ed24p_11.zip 146M
# ed26p_11.ts 314M
# ed24p_11.video.es 147M

Wyświetl plik

@ -1,20 +1,15 @@
Some tests for the Python binding of the TS tools Some tests for the Python binding of the TS tools
================================================= =================================================
It's difficult to find example data files that are generally available. For We shall assume that our standard sample data has been downloaded and expanded
the moment, I'm going to use a file I have locally, and unfortunately others into our sibling ``data`` directory. See the ``../data/setup.sh`` script.
will have to manage without. This is still better than no testing...
>>> test_es_file = '/Users/tibs/sw/tstools/data/aladdin.es' >>> test_es_file = '../data/ed24p_11.video.es'
First, check we've got the basics working: First, check we've got the basics working:
>>> from tstools import ESFile >>> from tstools import ESFile
>>> try: >>> stream = ESFile(test_es_file)
... stream = ESFile(test_es_file)
... except:
... test_es_file = '/home/tibs/Videos/aladdin.es'
... stream = ESFile(test_es_file)
The filename is available as a "readonly" value: The filename is available as a "readonly" value:
@ -40,32 +35,20 @@ We should be able to iterate over its ES units:
... es_unit_list.append(unit) ... es_unit_list.append(unit)
... if count > 5: ... if count > 5:
... break ... break
ES unit: start code 00, len 14: 00 00 01 00 01 1a 01 02 ES unit: start code 00, len 9: 00 00 01 00 01 df ff fb b8
ES unit: start code 01, len 972: 00 00 01 01 1a 10 73 10 ES unit: start code b5, len 9: 00 00 01 b5 85 45 4b 5d 80
ES unit: start code 02, len 515: 00 00 01 02 1a 10 b3 05 ES unit: start code 01, len 1645: 00 00 01 01 0a b0 10 09...
ES unit: start code 03, len 372: 00 00 01 03 2a 11 31 41 ES unit: start code 02, len 1634: 00 00 01 02 0a b0 10 09...
ES unit: start code 04, len 347: 00 00 01 04 32 11 75 8f ES unit: start code 03, len 16: 00 00 01 03 0a b0 10 07...
ES unit: start code 05, len 335: 00 00 01 05 32 11 70 8b ES unit: start code 04, len 15: 00 00 01 04 0a b0 10 02...
From hexdump I get (something that can be written out as):: From ``hexdump -C`` I get (something that can be written out as)::
00 00 01 00 01 1a 01 02 20 00 00 00 00 00 00 00 01 00 01 df ff fb b8
00 00 01 01 1a 10 73 10 1e 67 08 53 75 65 bf 1d 00 6d ... 00 00 01 b5 85 45 4b 5d 80
00 00 01 01 0a b0 10 09 1c 56 ec d8 72 94 01 ...
which tends to support those results (applying the rule "split before which tends to support those results.
00 00 01")..
Confusingly ('cos it confuses me, who am easily confused), ``esreport -es -v``
gives me something that translates as::
ES unit: start code 00, len 12: 00 00 01 00 00 4a 0c 98
ES unit: start code 01, len 1717: 00 00 01 01 1a 87 e2 40
ES unit: start code 02, len 988: 00 00 01 02 1b f8 90 69
ES unit: start code 03, len 865: 00 00 01 03 2a 93 e2 45
ES unit: start code 04, len 803: 00 00 01 04 2a 93 e2 45
ES unit: start code 05, len 685: 00 00 01 05 32 93 e2 65
(which suggests I'm misremembering how that works).
And close it: And close it:
@ -88,14 +71,14 @@ We can ask an ES unit about itself:
0 0
>>> data = unit.data >>> data = unit.data
>>> len(data) >>> len(data)
14 9
>>> data[0] >>> data[0]
'\x00' '\x00'
>>> text = 'data:' >>> text = 'data:'
>>> for ii in range(8): >>> for ii in range(8):
... text += ' %02x'%ord(data[ii]) ... text += ' %02x'%ord(data[ii])
>>> print text >>> print text
data: 00 00 01 00 01 1a 01 02 data: 00 00 01 00 01 df ff fb
>>> unit.fred >>> unit.fred
Traceback (most recent call last): Traceback (most recent call last):
... ...
@ -120,12 +103,12 @@ We can create an ES unit from a Python 'string':
>>> from tstools import ESUnit >>> from tstools import ESUnit
>>> print 'old ',repr(es_unit_list[0]) >>> print 'old ',repr(es_unit_list[0])
old ES unit: start code 00, len 14: 00 00 01 00 01 1a 01 02 old ES unit: start code 00, len 9: 00 00 01 00 01 df ff fb b8
>>> new = ESUnit(es_unit_list[0].data) >>> new = ESUnit(es_unit_list[0].data)
>>> print 'new ',repr(new) >>> print 'new ',repr(new)
new ES unit: start code 00, len 14: 00 00 01 00 01 1a 01 02 new ES unit: start code 00, len 9: 00 00 01 00 01 df ff fb b8
>>> print 'old ',repr(es_unit_list[0]) >>> print 'old ',repr(es_unit_list[0])
old ES unit: start code 00, len 14: 00 00 01 00 01 1a 01 02 old ES unit: start code 00, len 9: 00 00 01 00 01 df ff fb b8
>>> new == es_unit_list[0] >>> new == es_unit_list[0]
True True
@ -167,14 +150,14 @@ We already saw an ESOffset being returned:
>>> es_unit_list[0].start_posn >>> es_unit_list[0].start_posn
0+0 0+0
>>> es_unit_list[1].start_posn >>> es_unit_list[1].start_posn
14+0 9+0
>>> es_unit_list[1].start_posn.report() >>> es_unit_list[1].start_posn.report()
Offset 0 in packet at offset 14 in file Offset 0 in packet at offset 9 in file
Output more like that produced by the C report tools can also be obtained: Output more like that produced by the C report tools can also be obtained:
>>> print es_unit_list[1].start_posn.formatted() >>> print es_unit_list[1].start_posn.formatted()
00000000/00000014 00000000/00000009
We can create our own: We can create our own:
@ -240,7 +223,7 @@ be overkill, but all seemed sensible at the time):
>>> f.seek(-1) >>> f.seek(-1)
Traceback (most recent call last): Traceback (most recent call last):
... ...
TSToolsException: Error seeking to (-1,) in file '/Users/tibs/sw/tstools/data/aladdin.es' TSToolsException: Error seeking to (-1,) in file '../data/ed24p_11.video.es'
Let's try proper seeking, though: Let's try proper seeking, though:

Wyświetl plik

@ -271,6 +271,11 @@ cdef class ESUnit:
self.unit.data_len) self.unit.data_len)
for 0 <= ii < min(self.unit.data_len,8): for 0 <= ii < min(self.unit.data_len,8):
text += ' %02x'%self.unit.data[ii] text += ' %02x'%self.unit.data[ii]
if self.unit.data_len == 9:
text += ' %02x'%self.unit.data[8]
elif self.unit.data_len > 9:
text += '...'
return text return text
cdef __set_es_unit(self, ES_unit_p unit): cdef __set_es_unit(self, ES_unit_p unit):
@ -467,3 +472,12 @@ cdef class ESFile:
self.fileno = -1 self.fileno = -1
self.name = None self.name = None
self.mode = None self.mode = None
# ----------------------------------------------------------------------
# vim: set filetype=python expandtab shiftwidth=4:
# [X]Emacs local variables declaration - place us into python mode
# Local Variables:
# mode:python
# py-indent-offset:4
# End: