[theora] Add an intro to a theora file without re-encoding?

Michael Opdenacker michael at free-electrons.com
Tue Jul 21 05:24:56 PDT 2009


On 07/21/2009 12:01 PM, Lino Mastrodomenico wrote:
> 2009/7/21 Michael Opdenacker <michael at free-electrons.com>:
>   
>> I still have a problem with oggSilence... When I ask for a 6s duration,
>>     
>
> While you wait for a proper solution with oggSilence, you may want to
> try this small Python program:
>
> ---< cut here >---
> # usage: silence.py frequency_in_Hz duration_in_seconds output.wav
>
> import struct, sys
>
> freq = int(sys.argv[1])
> size = int(round(float(sys.argv[2]) * freq)) * 4
> f = open(sys.argv[3], 'wb')
> header = ('RIFF', size + 36, 'WAVEfmt \x10\0\0\0\1\0\2\0',
>           freq, freq * 4, '\4\0\x10\0data', size)
> f.write(struct.pack('< 4s I 16s 2I 8s I', *header))
> f.write(struct.pack('B', 0) * size)
> f.close()
> ---< cut here >---
>
> Use e.g. with:
>     silence.py 44100 3.51 silence.wav
>
> to create 3.51 seconds of silence at 44100 Hz with filename "silence.wav".
>
> It always creates stereo 16-bit-per-sample files. Works with any Python version.
> It keeps the whole file in memory, so if you need hours of silence...
>   
Hi Lino,

Thank you very much for this small script. It's a very good workaround.
This way, I can complete my script without putting too much stress on Yorn.

Cheers,

Michael.


-- 
Michael Opdenacker, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
+ 33 621 604 642



More information about the theora mailing list