<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi all!</p>
<p>I'm trying to use <b>swresample </b>library to resample audio
format from AV_SAMPLE_FMT_U8 to AV_SAMPLE_FMT_S16.</p>
<p>My file is:<br>
</p>
<i>>ffmpeg -i D:\cam_md_start_1.wav</i><br>
<p><i>ffmpeg version 0.11.5 Copyright (c) 2000-2014 the FFmpeg
developers<br>
built on Sep 26 2014 01:10:12 with gcc 4.9-win32 (GCC)<br>
configuration: --enable-memalign-hack --arch=x86_64
--target-os=mingw32 --cross-prefix=x86_64-w64-mingw32-
--disable-ffprobe --disable-ffplay --build-suffix=-ovs-3.1
--enable-shared --disable-static --enable-libass
--prefix=/home/gzh/sdk/mingw-x86_64/ffmpeg-ovs-3.1<br>
libavutil 54. 7.100 / 54. 7.100<br>
libavcodec 56. 1.100 / 56. 1.100<br>
libavformat 56. 4.101 / 56. 4.101<br>
libavdevice 56. 0.100 / 56. 0.100<br>
libavfilter 5. 1.100 / 5. 1.100<br>
libswscale 3. 0.100 / 3. 0.100<br>
libswresample 1. 1.100 / 1. 1.100<br>
Guessed Channel Layout for Input Stream #0.0 : mono<br>
Input #0, wav, from 'D:\cam_md_start_1.wav':<br>
Duration: 00:00:01.49, bitrate: 176 kb/s<br>
Stream #0:0: Audio: <b>pcm_u8</b> ([1][0][0][0] / 0x0001),
22050 Hz, 1 channels, u8, 176 kb/s<br>
At least one output file must be specified<br>
<br>
d:\ngp.sdk64\ffmpeg-ovs-3.1\bin></i><br>
</p>
<p>The code looks like this:</p>
<i>std::unique_ptr<SwrContext, SwrContextDtor> m_swr;</i><i><br>
</i><i> m_swr.reset(swr_alloc());</i><i><br>
</i><i> av_opt_set_int(m_swr.get(), "in_channel_layout",
frame->channel_layout, 0);</i><i><br>
</i><i> av_opt_set_int(m_swr.get(), "out_channel_layout",
frame->channel_layout, 0);</i><i><br>
</i><i> av_opt_set_int(m_swr.get(), "in_sample_rate",
frame->sample_rate, 0);</i><i><br>
</i><i> av_opt_set_int(m_swr.get(), "out_sample_rate",
frame->sample_rate, 0);</i><i><br>
</i><i> av_opt_set_sample_fmt(m_swr.get(),
"in_sample_fmt", (AVSampleFormat)frame->format, 0);</i><i><br>
</i><i> av_opt_set_sample_fmt(m_swr.get(),
"out_sample_fmt", AV_SAMPLE_FMT_S16, 0);</i><i><br>
</i><i> swr_init(m_swr.get());</i><i><br>
</i><i>std::unique_ptr<AVFrame, AVFrameDtor>
converted(av_frame_alloc());</i><i><br>
</i><i> converted->channel_layout =
frame->channel_layout;</i><i><br>
</i><i> converted->sample_rate = frame->sample_rate;</i><i><br>
</i><i> converted->format = AV_SAMPLE_FMT_S16;</i><i><br>
</i><i> int err = swr_convert_frame(m_swr.get(),
converted.get(), frame.get());</i><br>
<br>
The problem is that swr_convert_frame returns value -1 and doesn't
convert the frame.<br>
I have attached input frame as frame.txt and output as
converted.txt.<br>
<br>
Please, could someone help me to understand why swr_convert_frame
fails to convert format?<br>
<br>
<div class="moz-signature">-- <br>
<meta charset="UTF-8">
<table style="width:635px;border-bottom: 1px solid
#91a7c7;border-collapse: collapse;">
<tbody>
<tr>
<td> <br>
</td>
</tr>
</tbody>
</table>
<div style="height: 10px; line-height:10px; font-size:8px;"> </div>
<table style="width:635px;">
<tbody>
<tr>
<td style="width:55px;font-family: Arial, Helvetica,
sans-serif;"> <img style="vertical-align:middle"
src="cid:part1.B7F3512D.25E721F4@ru.axxonsoft.com"> </td>
<td style="width:1%; padding-left: 5px; border-right: 1px
solid #91a7c7; padding-right: 30px;font-family: Arial,
Helvetica, sans-serif;"> <span style="color:#003B74;
font-size:23px;">AxxonSoft</span> </td>
<td style=" padding-left: 25px;vertical-align:
top;font-family: Arial, Helvetica, sans-serif;">
<p style="font-size: 22px;margin: 0;">Rizvan Kuliev</p>
<p style="margin:0; color:#707070; font-size:13px;">Programmer</p>
<p style="margin: 10px 0 0;"><a style="color:#358EDB;
font-size: 13px;"
href="mailto:rizvan.kuliev@axxonsoft.com">rizvan.kuliev@axxonsoft.com</a></p>
</td>
</tr>
</tbody>
</table>
<div style="height: 10px; line-height:10px; font-size:8px;"> </div>
<table style="background: #91a7c7;width:635px; height:30px;"
valign="middle">
<tbody>
<tr>
<td style="width:220px;font-family: Arial, Helvetica,
sans-serif;"> <a href="http://axxonsoft.com"><img
style="margin-left:5px;vertical-align: middle;"
src="cid:part3.75279C10.65A0C33C@ru.axxonsoft.com"></a>
<a href="http://www.youtube.com/user/ITVAXXON"><img
style="vertical-align: middle;"
src="cid:part5.B10FA8F6.848F894E@ru.axxonsoft.com"></a>
<a
href="http://www.linkedin.com/groups/FREE-16-channel-VMS-from-4133198"><img
style="vertical-align: middle;"
src="cid:part7.77569BA2.D9A6B13D@ru.axxonsoft.com"></a>
<a href="http://www.facebook.com/axxonsoft"><img
style="vertical-align: middle;"
src="cid:part9.4C1A4479.A8815702@ru.axxonsoft.com"></a>
<a href="https://twitter.com/#%21/AxxonSoft_EN"><img
style="vertical-align: middle;"
src="cid:part11.0C758E05.54DA2B21@ru.axxonsoft.com"></a>
<a href="skype:skype.itv.ru?call"><img
style="vertical-align: middle;"
src="cid:part13.93577E78.F5BFD37C@ru.axxonsoft.com"></a>
</td>
<td> <a href="http://www.axxonsoft.com/disclaimer.php"
style="color:#FFFFFF;font-size: 11px;margin-left: 10px;">CONFIDENTIALITY
NOTICE</a> </td>
</tr>
</tbody>
</table>
</div>
</body>
</html>