<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-2" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19403">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>
<DIV><FONT face=Arial>Hi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>I checked <STRONG>doc/examples/muxingc.c</STRONG> file
where an example generating MPEG AV file is explained. Then I try to change
AV format to "<STRONG>webm</STRONG>" (video is encoded with VP8
and audio with vorbis encoder). I have problems with setting the right
parameters for vorbis encoder. When I debugging through the code I figured out
that vorbis only accepts (AV_SAMPLE_FMT_FLTP) sample format type. Example
was done with (AV_SAMPLE_FMT_S16). I looked into source code to figure out
that when I call <STRONG></STRONG></FONT></DIV>
<DIV><FONT face=Arial><STRONG></STRONG></FONT> </DIV>
<DIV><FONT face=Arial><STRONG>av</STRONG><FONT face=Consolas><FONT
face=Arial><STRONG>codec_fill_audio_frame(<WBR>AVFrame, channels, sample_format,
buffer, buf_size, align)</STRONG>, </FONT></FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial><FONT face=Consolas><FONT face=Arial>in case of
AV_SAMPLE_FMT_FLTP the buffer should be type <STRONG>float*</STRONG> and audio
samples should have values between -1.0 to 1.0. For more than one channel
values are <STRONG>not interleaved </STRONG>(FLTP - float plain) but
they are followed by each other (array: all values for channel0, all values for
channel 1, ...).</FONT></FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>When I accept those changes in my code, unfortunately I
still don't get correct result. If I use mono (1 channel only) then the flag
(<FONT face=Consolas><FONT face=Arial>got_packet</FONT></FONT>) returned from
function <FONT face=Consolas><FONT
face=Arial><STRONG>avcodec_encode_audio2</STRONG> is set only once (after
around 5 consecutive calls), with <FONT face=Consolas><FONT
face=Consolas><STRONG><FONT
face=Arial>AVPacket->pts</FONT></STRONG> </FONT></FONT>timestamp set to
some huge values. Because of that only video is
encoded.</FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial>When I set stereo mode I get error from function <FONT
face=Consolas><FONT face=Arial><STRONG>av_interleaved_write_frame</STRONG>
(-12).</FONT></FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>I tested the same code and setting AV format to
"<STRONG>asf</STRONG>", where audio is encoded with WMA2 encoder and also
accepts AV_SAMPLE_FMT_FLTP sample format type. I got correct AV file which can
be played with VLC player or Windows media player.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>I think I still need to set some flags for vorbis encoder,
but I can't figure out. I would appreciate any suggestions.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>Best regards</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>For audio encoder I set those parameters:</FONT></DIV>
<DIV> </DIV><FONT face=Consolas><FONT face=Arial>
<DIV>c->sample_fmt = AV_SAMPLE_FMT_FLTP;</DIV></FONT></FONT>
<DIV><FONT face=Consolas><FONT face=Consolas><FONT face=Arial>c->sample_rate
= 44100; </FONT></FONT></FONT></DIV><FONT face=Consolas><FONT face=Consolas>
<DIV><FONT face=Arial>c->channels = 1; </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial>My code to prepare samples in AV_SAMPLE_FMT_FLTP sample
format:</FONT></DIV><FONT color=#0000ff face=Consolas><FONT color=#0000ff
face=Consolas><FONT color=#0000ff face=Consolas>
<DIV> </DIV></FONT></FONT></FONT>
<DIV><FONT color=#0000ff face=Consolas><FONT color=#0000ff face=Consolas><FONT
color=#0000ff face=Consolas><FONT color=#000000
face=Arial>void</FONT></FONT></FONT></FONT><FONT face=Arial><FONT size=+0><FONT
size=+0> TT_Transcode::get_audio_frame_<WBR>fltp(</FONT></FONT><FONT
size=+0><FONT size=+0><FONT size=+0>float</FONT></FONT></FONT><FONT
size=+0><FONT size=+0> *fsamples, </FONT></FONT><FONT size=+0><FONT
size=+0><FONT size=+0>int</FONT></FONT></FONT><FONT size=+0><FONT size=+0>
frame_size, </FONT></FONT><FONT size=+0><FONT size=+0><FONT
size=+0>int</FONT></FONT></FONT></FONT><FONT size=+0><FONT size=+0><FONT
face=Arial> nb_channels)</FONT></FONT></FONT></DIV><FONT size=+0><FONT size=+0>
<DIV><FONT face=Arial>{</FONT></DIV></FONT></FONT>
<DIV><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff
face=Arial> int</FONT></FONT></FONT><FONT size=+0><FONT
size=+0><FONT face=Arial> j, i;</FONT></FONT></FONT></DIV><FONT size=+0><FONT
size=+0></FONT></FONT>
<DIV><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff
face=Arial> float</FONT></FONT></FONT><FONT size=+0><FONT
size=+0><FONT face=Arial> v;</FONT></FONT></FONT></DIV><FONT size=+0><FONT
size=+0></FONT></FONT>
<DIV><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff
face=Arial> float</FONT></FONT></FONT><FONT size=+0><FONT
size=+0><FONT face=Arial> *q;</FONT></FONT></FONT></DIV><FONT size=+0><FONT
size=+0></FONT></FONT>
<DIV><FONT size=+0><FONT size=+0><FONT face=Arial>
</FONT></FONT></FONT><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff
face=Arial>for</FONT></FONT></FONT><FONT size=+0><FONT size=+0><FONT face=Arial>
(j = 0; j < frame_size; j++) {</FONT></FONT></FONT></DIV><FONT size=+0><FONT
size=+0>
<DIV><FONT face=Arial> v = (sin(t) *
10000.0) / 32767.0f; //values between -1.0 and +1.0</FONT></DIV>
<DIV><FONT face=Arial> fsamples[ j ] =
v;</FONT></DIV></FONT></FONT>
<DIV><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff
face=Arial> for</FONT></FONT></FONT><FONT
face=Consolas><FONT face=Consolas><FONT face=Arial> (i = 1; i < nb_channels;
i++)</FONT></FONT></FONT></DIV><FONT face=Consolas><FONT face=Consolas>
<DIV><FONT face=Arial> {</FONT></DIV>
<DIV><FONT face=Arial>
fsamples[i * in_linesize + j] = v;</FONT></DIV>
<DIV><FONT face=Arial> } </FONT></DIV>
<DIV><FONT face=Arial> t +=
tincr;</FONT></DIV>
<DIV><FONT face=Arial> tincr +=
tincr2;</FONT></DIV>
<DIV><FONT face=Arial> }</FONT></DIV>
<DIV><FONT
face=Arial>}</FONT></DIV></FONT></FONT></FONT></FONT></FONT></DIV></BODY></HTML>