<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Sep 24, 2014, at 1:42 AM, sbwn <*@<a href="http://sbwn.fr" class="">sbwn.fr</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span class="">Hello,</span><span class="Apple-converted-space"> </span><br class=""><span class="">I'm trying to make a C++ program that convert music files, but it doesn't work.</span><span class="Apple-converted-space"> </span><br class=""><br class=""><span class="">main.cpp :<span class="Apple-converted-space"> </span><a href="http://pastebin.com/kTN45Fn1" class="">http://pastebin.com/kTN45Fn1</a></span><span class="Apple-converted-space"> </span><br class=""><span class="">functions.cpp :<span class="Apple-converted-space"> </span><a href="http://pastebin.com/aRwdHxy7" class="">http://pastebin.com/aRwdHxy7</a></span><span class="Apple-converted-space"> </span><br class=""><span class="">Makefile :<span class="Apple-converted-space"> </span><a href="http://pastebin.com/BzBEBicH" class="">http://pastebin.com/BzBEBicH</a></span><span class="Apple-converted-space"> </span><br class=""><span class="">Program output :</span></div><dl class="codebox" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><dd class=""><code class="">[mp3 @ 0x21eb200] max_analyze_duration reached<br class="">Input #0, mp3, from 'test.mp3':<br class=""> Metadata:<br class=""> major_brand : mp42<br class=""> minor_version : 0<br class=""> compatible_brands: isommp42<br class=""> creation_time : 2013-11-29 03:30:21<br class=""> encoder : Lavf53.21.1<br class=""> Duration: 00:03:58.15, start: 0.000000, bitrate: 192 kb/s<br class=""> Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s<br class="">Output #0, mp4, to 'out.mp4':<br class=""> Stream #0.0: Audio: libvorbis, 44100 Hz, stereo, s16, 192 kb/s<br class="">[mp4 @ 0x21ee5c0] Codec for stream 0 does not use global headers but container format requires global headers<br class="">audio encode error-22 Invalid argument</code></dd></dl><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span class="">avcodec_encode_audio2 returns -22 and the error string is "Invalid argument", I don't know more about the error</span></div></div></blockquote></div><br class=""><div class="">This isn’t going to solve your immediate problem, but I can give you one bit of advice on any audio resampling operations you are performing, which gave me fits for weeks. My problem was that after what appeared to be successful resampling, I had a buzz that had been added to the audio. I tried all sorts of machinations to fix this, to no avail. In the end, the problem was the rounding function used (which was to round up, and which was employed in virtually every resampling example I found in sample code, blogs, etc. on the Internet). Change the function used to round down — this will prevent additives to your audio. The logic behind this is probably self-explanatory if you think of the effect to a sound wave by rounding up (adds data) versus down (removes data, albeit a minimal amount). </div><div class=""><br class=""></div><div class="">A change of four characters in my code completely resolved the issue. Keep an eye out for this if you are doing heavy resampling. </div><div class=""><br class=""></div><div class="">Good luck. </div><div class=""><br class=""></div><div class="">Brad</div></body></html>