[xiph-cvs] cvs commit: vorbis-python/test enc2.py
Andrew Chatham Master of Python
andrew at xiph.org
Sun Jan 18 22:28:15 PST 2004
andrew 04/01/19 01:28:15
Modified: . ChangeLog
test enc2.py
Log:
2004-1-18 Andrew H. Chatham <pyogg at andrewchatham.com>
* enc2.py: Apply a suggested change from Daniel Holth that makes
the output more valid (eos gets set). Also updated to demonstrate
the new ogg_page.tostring()
Revision Changes Path
1.26 +5 -0 vorbis-python/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ChangeLog 19 Dec 2003 07:54:33 -0000 1.25
+++ ChangeLog 19 Jan 2004 06:28:15 -0000 1.26
@@ -1,3 +1,8 @@
+2004-1-18 Andrew H. Chatham <pyogg at andrewchatham.com>
+ * enc2.py: Apply a suggested change from Daniel Holth that makes
+ the output more valid (eos gets set). Also updated to demonstrate
+ the new ogg_page.tostring()
+
2003-12-18 Andrew H. Chatham <pyogg at andrewchatham.com>
* pyvorbisinfo.c: Incoporate John Morton's explanations about what
all those arguments mean. Now everything that takes a logical
<p><p>1.4 +17 -4 vorbis-python/test/enc2.py
Index: enc2.py
===================================================================
RCS file: /usr/local/cvsroot/vorbis-python/test/enc2.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- enc2.py 8 Feb 2003 07:12:29 -0000 1.3
+++ enc2.py 19 Jan 2004 06:28:15 -0000 1.4
@@ -2,6 +2,10 @@
'''An example of encoding using the Python wave module'''
import ogg.vorbis, wave
+
+# Used to switch between different ways of writing the file out
+write_as_string = 1
+
fout = open('out.ogg', 'wb')
inwav = wave.open('in.wav','rb')
channels = inwav.getnchannels()
@@ -16,6 +20,15 @@
og = os.flush()
nsamples = 1024
+def FinishPage(ogg_page):
+ """Take a finished ogg page object and write it out to a file."""
+ if not write_as_string:
+ ogg_page.writeout(fout) # write it to a file
+ else:
+ # We'll do this the longer way
+ data = ogg_page.tostring()
+ fout.write(data)
+
eos = 0
total = 0
while not eos:
@@ -23,9 +36,9 @@
total = total + nsamples
if not data:
vd.write(None)
- break
- vd.write_wav(data)
- #print 100.0 * total / inwav.getnframes()
+ else:
+ vd.write_wav(data)
+ print 100.0 * total / inwav.getnframes()
vb = vd.blockout()
while vb:
vb.analysis()
@@ -37,7 +50,7 @@
while not eos:
og = os.pageout()
if not og: break
- og.writeout(fout)
+ FinishPage(og)
eos = og.eos()
op = vd.bitrate_flushpacket()
vb = vd.blockout()
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list