[ANN] new version of AudioVideoLib available

Martin Kuball martinkuball at web.de
Fri Jan 6 15:13:44 UTC 2006


Hi!

I made a new version of my AudioVideoLib package. It's available from 
SqueakSource at kilana.unibe.ch.

Before making a first release for SqueakMap I would ask 3 questions:

1. I have a script with some code snippets that show how to use the 
lib. How can I include this into a SqueakMap package?

2. AudioVideoLib has some classes that need initialization. 
Unfortunately there are some dependencies and the order of 
initialization is important. A test with a fresh image went just 
fine. But I wonder if this was by accident or because squeak is realy 
clever. 

3. At the moment AudioVideoLib consists of 4 packages. Do you think 
this is OK or would 1 big package be much better?

Martin

-------------- next part --------------
"scan all avi in a directory and print some information and statistics for each
 ======================================================================================"
| log avi path |
log := StandardFileStream newFileNamed: 'video.log'.
path := '/home/kuball/Video/'.
(FileDirectory on: path) fileNames do:
[ :name |
	(name endsWith: '.avi') ifTrue:
	[
		avi := RIFFArchive openOn: path , name.
		log cr; cr; nextPutAll: name; cr.
		avi printInfoOn: log.
		avi close
	]
]


"extract an elementary stream from an avi
================================================="
| srcAvi demuxer sink |
srcAvi := RIFFArchive openOn: 'fileName'.
demuxer := AVIDemuxer on: srcAvi.
sink := FileSink on: 'dst'.
sink save: (demuxer outputForType: AVFormat audioType index: 1)


"convert a packed avi (used by divx) into a normal one
======================================================================"
| oldNames newNames |
oldNames := #('test1p.avi' 'test2p.avi').
newNames := #('test1.avi' 'test2.avi').

oldNames with: newNames do:
[ :oldName :newName | | srcAvi dstAvi demuxer filter muxer |
	srcAvi := RIFFArchive openOn: oldName.
	demuxer := AVIDemuxer on: srcAvi.
	filter := PackedStreamUnpacker new.
	filter input: (demuxer outputForType: filter inputType index: 1).

	muxer := AVIMuxer new.
"	muxer := AVIMuxerContinousAudio new."
	muxer setVideoInput: filter output.
	muxer addAudioInput: (demuxer outputForType: AVType audio index: 1).

	dstAvi := AVIFile new.
	dstAvi input: muxer.
	dstAvi runtime: 10000.
	dstAvi createIndex.
	dstAvi writeTo: (StandardFileStream newFileNamed: path , newName).
	dstAvi close.
	srcAvi close.
]


"correcting av sync by removing or adding sound at the beginning
 ==============================================================================="
| oldNames newNames |
oldName := 'test.avi'
newNames := #('test-0.5.avi' 'test-0.3.avi' 'test+0.2.avi').

delays := #(-0.5 -0.3 0.3).

newNames with: delays do:
[ :newName :delay | | srcAvi dstAvi demuxer filter muxer |
	srcAvi := RIFFArchive openOn: oldName.
	demuxer := AVIDemuxer on: srcAvi.
	muxer := AVIMuxer new.
	muxer frameRate: srcAvi frameRate.
	muxer setVideoInput: (demuxer outputForType: AVType video index: 1).

	filter := AudioSync withDelay: delay.
	filter input: (demuxer outputForType: filter inputType index: 1).
	muxer addAudioInput: filter output.

	dstAvi := AVIFile new.
	dstAvi input: muxer.
	dstAvi runtime: 100.
	dstAvi createIndex.
	dstAvi writeTo: (StandardFileStream newFileNamed: newName).
	dstAvi close.
	srcAvi close.
]


"scan all audio files in a directory and print some information and statistics for each
 ======================================================================================"
| log path totalTime |
log := Transcript.
"StandardFileStream newFileNamed: 'audio.log'."
path := '/home/kuball/Music/'.
totalTime := 0.
(FileDirectory on: path) fileNames do:
[ :name | | analyzer stream |
	(name endsWith: '.mp3') ifTrue:
	[
		stream := MPAStream on: path , name.
		analyzer := MPAAnalyzer on: stream.
	].
	
	analyzer ifNotNil:
	[
		log nextPutAll: name;
			nextPutAll: ',  ';
			flush.
		analyzer analyzeShort.
		analyzer hasErrors
			ifTrue: [log nextPutAll: analyzer errorMessage]
			ifFalse:
			[
				totalTime := totalTime + analyzer runtime.
				log print: (Duration seconds: analyzer runtime rounded);
					nextPutAll: ',   ';
					nextPutAll: analyzer encodingType;
					nextPutAll: ',   ';
					print: analyzer sampleRate;
					nextPutAll: ',   ';
					nextPutAll: (analyzer isVBR ifTrue: ['vbr'] ifFalse: ['cbr']);
					nextPutAll: ',   ';
					print: (analyzer bitrates at: 1)
			].
		log cr; flush.
	].
	stream ifNotNil: [stream close. stream := nil. analyzer := nil]
].
log nextPutAll: '============================================================';
	cr;
	nextPutAll: '  total runtime: ';
	cr;
	print: (Duration seconds: totalTime);
	cr;
	flush


More information about the Squeak-dev mailing list