Recherche avancée

Médias (16)

Mot : - Tags -/mp3

Autres articles (35)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (4845)

  • The 11th Hour RoQ Variation

    12 avril 2012, par Multimedia Mike — Game Hacking, dreamroq, Reverse Engineering, roq, Vector Quantization

    I have been looking at the RoQ file format almost as long as I have been doing practical multimedia hacking. However, I have never figured out how the RoQ format works on The 11th Hour, which was the game for which the RoQ format was initially developed. When I procured the game years ago, I remember finding what appeared to be RoQ files and shoving them through the open source decoders but not getting the right images out.

    I decided to dust off that old copy of The 11th Hour and have another go at it.



    Baseline
    The game consists of 4 CD-ROMs. Each disc has a media/ directory that has a series of files bearing the extension .gjd, likely the initials of one Graeme J. Devine. These are resource files which are merely headerless concatenations of other files. Thus, at first glance, one file might appear to be a single RoQ file. So that’s the source of some of the difficulty : Sending an apparent RoQ .gjd file through a RoQ player will often cause the program to complain when it encounters the header of another RoQ file.

    I have uploaded some samples to the usual place.

    However, even the frames that a player can decode (before encountering a file boundary within the resource file) look wrong.

    Investigating Codebooks Using dreamroq
    I wrote dreamroq last year– an independent RoQ playback library targeted towards embedded systems. I aimed it at a gjd file and quickly hit a codebook error.

    RoQ is a vector quantizer video codec that maintains a codebook of 256 2×2 pixel vectors. In the Quake III and later RoQ files, these are transported using a YUV 4:2:0 colorspace– 4 Y samples, a U sample, and a V sample to represent 4 pixels. This totals 6 bytes per vector. A RoQ codebook chunk contains a field that indicates the number of 2×2 vectors as well as the number of 4×4 vectors. The latter vectors are each comprised of 4 2×2 vectors.

    Thus, the total size of a codebook chunk ought to be (# of 2×2 vectors) * 6 + (# of 4×4 vectors) * 4.

    However, this is not the case with The 11th Hour RoQ files.

    Longer Codebooks And Mystery Colorspace
    Juggling the numbers for a few of the codebook chunks, I empirically determined that the 2×2 vectors are represented by 10 bytes instead of 6. Now I need to determine what exactly these 10 bytes represent.

    I should note that I suspect that everything else about these files lines up with successive generations of the format. For example if a file has 640×320 resolution, that amounts to 40×20 macroblocks. dreamroq iterates through 40×20 8×8 blocks and precisely exhausts the VQ bitstream. So that all looks valid. I’m just puzzled on the codebook format.

    Here is an example codebook dump :

    ID 0x1002, len = 0x0000014C, args = 0x1C0D
      0 : 00 00 00 00 00 00 00 00 80 80
      1 : 08 07 00 00 1F 5B 00 00 7E 81
      2 : 00 00 15 0F 00 00 40 3B 7F 84
      3 : 00 00 00 00 3A 5F 18 13 7E 84
      4 : 00 00 00 00 3B 63 1B 17 7E 85
      5 : 18 13 00 00 3C 63 00 00 7E 88
      6 : 00 00 00 00 00 00 59 3B 7F 81
      7 : 00 00 56 23 00 00 61 2B 80 80
      8 : 00 00 2F 13 00 00 79 63 81 83
      9 : 00 00 00 00 5E 3F AC 9B 7E 81
      10 : 1B 17 00 00 B6 EF 77 AB 7E 85
      11 : 2E 43 00 00 C1 F7 75 AF 7D 88
      12 : 6A AB 28 5F B6 B3 8C B3 80 8A
      13 : 86 BF 0A 03 D5 FF 3A 5F 7C 8C
      14 : 00 00 9E 6B AB 97 F5 EF 7F 80
      15 : 86 73 C8 CB B6 B7 B7 B7 85 8B
      16 : 31 17 84 6B E7 EF FF FF 7E 81
      17 : 79 AF 3B 5F FC FF E2 FF 7D 87
      18 : DC FF AE EF B3 B3 B8 B3 85 8B
      19 : EF FF F5 FF BA B7 B6 B7 88 8B
      20 : F8 FF F7 FF B3 B7 B7 B7 88 8B
      21 : FB FF FB FF B8 B3 B4 B3 85 88
      22 : F7 FF F7 FF B7 B7 B9 B7 87 8B
      23 : FD FF FE FF B9 B7 BB B7 85 8A
      24 : E4 FF B7 EF FF FF FF FF 7F 83
      25 : FF FF AC EB FF FF FC FF 7F 83
      26 : CC C7 F7 FF FF FF FF FF 7F 81
      27 : FF FF FE FF FF FF FF FF 80 80
    

    Note that 0x14C (the chunk size) = 332, 0x1C and 0x0D (the chunk arguments — count of 2×2 and 4×4 vectors, respectively) are 28 and 13. 28 * 10 + 13 * 4 = 332, so the numbers check out.

    Do you see any patterns in the codebook ? Here are some things I tried :

    • Treating the last 2 bytes as U & V and treating the first 4 as the 4 Y samples :


    • Treating the last 2 bytes as U & V and treating the first 8 as 4 16-bit little-endian Y samples :


    • Disregarding the final 2 bytes and treating the first 8 bytes as 4 RGB565 pixels (both little- and big-endian, respectively, shown here) :


    • Based on the type of data I’m seeing in these movies (which appears to be intended as overlays), I figured that some of these bits might indicate transparency ; here is 15-bit big-endian RGB which disregards the top bit of each pixel :


    These images are taken from the uploaded sample bdpuz.gjd, apparently a component of the puzzle represented in this screenshot.

    Unseen Types
    It has long been rumored that early RoQ files could contain JPEG images. I finally found one such specimen. One of the files bundled early in the uploaded fhpuz.gjd sample contains a JPEG frame. It’s a standard JFIF file and can easily be decoded after separating the bytes from the resource using ‘dd’. JPEGs serve as intraframes in the coding scheme, with successive RoQ frames moving objects on top.

    However, a new chunk type showed up as well, one identified by 0×1030. I have never encountered this type. Where could I possibly find data about this ? Fortunately, iD Games recently posted all of their open sourced games at Github. Reading through the code for their official RoQ decoder, I see that this is called a RoQ_PACKET. The name and the code behind it are both supremely unhelpful. The code is basically a no-op. The payloads of the various RoQ_PACKETs from one sample are observed to be either 8784, 14752, or 14760 bytes in length. It’s very likely that this serves the same purpose as the JPEG intraframes.

    Other Tidbits
    I read through the readme.txt on the first game disc and found this nugget :

            g)      Animations displayed normally or in SPOOKY MODE
    

    SPOOKY MODE is blue-tinted grayscale with color cursors, puzzle
    and game pieces. It is the preferred display setting of the
    developers at Trilobyte. Just for fun, try out the SPOOKY
    MODE.

    The MobyGames screenshot page has a number of screenshots labeled as being captured in spooky mode. Color tricks ?

    Meanwhile, another twist arose as I kept tweaking dreamroq to deal with more RoQ weirdness : After modifying my dreamroq code to handle these 10-byte vectors, it eventually chokes on another codebook. These codebooks happen to have 6-byte vectors again ! Fortunately, I was already working on a scheme to automatically detect which codebook is in play (plugging the numbers into a formula and seeing which vector size checks out).

  • Why Matomo is a serious alternative to Google Analytics 360

    12 décembre 2018, par Jake Thornton — Marketing

    There’s no doubt about it, the free version of Google Analytics offers great value when it comes to making data-driven decisions for your business. But as your business starts to grow, so does the need for a more powerful web analytics tool.

    Why would I need to use a different web analytics tool ? It’s because Google Analytics (free version) is very limited when it comes to meeting the needs of a fast growing business whose website plays a pivotal role in converting its customers.

    This is where the Google Analytics 360 suite comes in, which is designed to meet the needs of businesses looking to get more accurate and insightful metrics.

    So what’s holding a growing business back from using Google Analytics 360 ?

    While GA360 sounds like a great option when upgrading your web analytics platform, we have found there are three core reasons holding businesses back from taking the leap :

    • Businesses can’t bear to swallow the US$150,000+ price tag (per year !) that comes with upgrading
    • Businesses can’t rely on GA360 to give them all the insights they need
    • Businesses want more control and ownership of their data

    Thankfully there are (only a few) alternatives and as the leading open-source alternative to Google Analytics, we hope to share insights on why Matomo Analytics can be the perfect solution for anyone at this crossroads in their web analytics journey.

    First, what does Google Analytics 360 offer that Google Analytics (free) doesn’t ?

    There’s no doubt about it, the GA360 suite is designed for larger sized businesses with demanding data limits, big budgets to use across the Google Marketing Platform (Google Adwords, DoubleClick etc.) and to get more advanced reporting visualisations and options.

    Data Sampling

    Data sampling is the elephant in the room when it comes to comparing GA360 with the freemium version. This is an entire article in its own right but at a basic level, Google Analytics samples your data (makes assumptions based on patterns) once the number of traffic visiting your website reaches a certain limit.

    Google Analytics provides the following information :

    Ad-hoc queries of your data are subject to the following general thresholds for sampling :

    Analytics Standard : 500k sessions at the property level for the date range you are using

    Analytics 360 : 100M sessions at the view level for the date range you are using

    In short, sampled data means inaccurate data. This is why as businesses grow, GA360 becomes a more attractive prospect because there’s no point making data-driven business decisions based on inaccurate data. This is a key weapon Google uses when selling to large businesses, however, this may not seem as concerning if you’re a small business within the sampled data range. For small businesses though, make sure you know the full extent of how this can affect your metrics, for example, your ecommerce data could be sampled, hence your GA reporting not matching your CRM/Ecommerce store data.

    Benefit of using Matomo : There is no data sampling anywhere in Matomo Analytics, that’s why we say 100% Accurate Data reporting across all plans.

    All Matomo data is 100% accurate

    Integration with the Google Marketing Platform

    Yes ok, we’ll admit it, GA does a great job at integrating seamlessly with its own products like Google Ads, Google Optimize etc. with a touch of Salesforce integration ; while GA360 takes this to another level compared to it’s freemium version (integration with Google Search 360, Google Display & Video 360 etc.)

    But… what about non-Google advertising platforms ? Well with Google being a dominant leader as a search engine, web browser, email provider, social media channel ; sometimes Google needs to keep its best interests at heart.

    Google is an online advertising giant and a bonus of Google Search 360 is that you can integrate your Bing Ads, Baidu and Yahoo Japan Search campaigns but that’s about it when it comes to integrations from its direct competitors. 

    Benefit of using Matomo : No biased treatment. You can integrate your Google, Yahoo and Bing search consoles for accurate search engine reporting, and in early 2019, Matomo will be releasing a Google Ads, Bing Ads and Facebook Ads Manager integration feature.

    Roll-Up Reporting
    Roll-Up Reporting for Matomo Nalytics

    Roll-up reporting lets you combine multiple accounts and properties into one view. This is a great benefit when upgrading from GA freemium to GA360. For example, if you’re a digital agency with multiple clients or you manage multiple websites under the one account, the roll-up reporting feature is wonderful when you need to combine data and reporting, instantly.

    Benefit of using Matomo : Matomo’s got this covered ! Roll-up reporting is available in the Matomo Business package (starting at $29 per month) for cloud hosting or you can purchase as a Premium Feature for On-Premise starting at $99 per year.

    Staying in full control of your data

    Who would have thought that one of biggest reasons people choose Matomo isn’t because of anything that leads to a higher ROI, but for the fact that users want more control of their data.
    100% Data Ownership with Matomo

    Matomo’s philosophy around data ownership is simple, you own your data, no one else. If you choose to host Matomo Analytics On-Premise then you are in complete control because your data is stored on your own servers where no one can gain access to it in whichever country you choose.

    So what about when you cloud host Matomo ? For users who don’t have the technical knowledge to host Matomo On-Premise, you can still have 100% data ownership and fully respect your user’s privacy when choosing to host Matomo Analytics through our cloud service.

    The difference between cloud hosting Matomo Analytics vs Google Analytics is that when you choose Matomo, we acknowledge you own the data and we have no right to access it. This means we can’t on-sell it to third-parties, we can’t claim ownership of it, you can export your data at anytime (how awesome is that !) and you can migrate between cloud hosting and hosting on-premise for ultimate flexibility whenever you want.

    Matomo also prides itself in allowing its users to be GDPR compliant with ease with a powerful GDPR Manager.

    Businesses can’t rely on Google Analytics 360 to give them all the insights they need

    Unlike Google Analytics 360, Matomo blends its Premium Web Analytics platform with Conversion Optimization features to allow its users to fully evaluate the user-experience on your website.

    Matomo is designed to be a complete analytics platform, meaning you have everything you need all in the one place which gives you greater insights and better business outcomes.

    Matomo Complete Analytics
    These features include :

    Premium Web Analytics – You can still (accurately) measure all the basic metrics you love and are familiar with in Google Analytics like Location, Referrer traffic, Multi Attribution, Campaign Tracking and Ecommerce etc.

    Conversion Optimization – Eliminate the need for multiple analytics tools to get what Google Analytics doesn’t offer. These features include Heatmaps, Session Recordings, Form Analytics and more – giving you the best chance possible to convert more traffic by evaluating the user-experience.

    By having one tool for all your features you can integrate metrics, have one single view for all your data and it’s easy to use.

    Enhanced SEO – Get more insights into the performance of your search campaigns with unbiased search engine reporting, keyword ranking positions, integration with multiple search consoles and crawling stats. Google Analytics offers limited features to help with your SEO campaigns and only integrates with Google products.

    Visitor Profiles – Get a detailed life-time evaluation of every user who visits your website.

    Tag Manager – A powerful open-source Tag Manager tool to embed your third-party marketing tags. By being open-source and with our commitment to giving you 100% data ownership, you can always ensure you are in full control.

    Just putting it out there ...

    Google leads the market with its freemium tool which offers great insights for businesses (fyi – Matomo has a forever free analytics tool too !), but when it comes to upgrading to get accurate reporting (kind of a big deal), owning your own data (a huge deal !) and having a complete range of features to excel ROI for your business, Matomo Analytics is often a preferred option to the Google Analytics 360 suite.

    Matomo is designed to be easy to use, is fully flexible and gives users full peace of mind by respecting user privacy. Want to learn more about the benefits of Matomo ?

  • How to convert same audio twice using libswresamples's swr_convert

    25 juillet 2019, par JoshuaCWebDeveloper

    I’m working on an audio processing system that sometimes requires that the same audio be resampled twice. The first resampling of the audio from FFmpeg works fine, the second results in distorted audio. I’ve reproduced this problem by modifying the resampling_audio example provided by FFmpeg. How do I convert the same audio twice using swr_convert ?

    Below I’ve attached a modified version of the resampling_audio example. In order to reproduce the issue, follow these steps :

    1. Clone FFmepg project at https://github.com/FFmpeg/FFmpeg
    2. Run ./configure
    3. Run make -j4 examples (this will take awhile the first time)
    4. Run doc/examples/resampling_audio to produce expected output
    5. Replace doc/examples/resampling_audio.c with the version I’ve attached below
    6. Run make -j4 examples
    7. Run doc/examples/resampling_audio again (with new args) to output two new files (one for each conversion).
    8. Import each file into Audacity as raw data, the first file should be 44100 Hz, the second should be 32000 Hz.
    9. The first file will sound the same as the original, the second file will be distorted.

    The environment I ran this in was Ubuntu 16.04 ; I then copied the output files to a Windows PC to open them in Audacity.

    Here is my modified resampling_audio.c file. I’ve created some new variables and copied the blocks of code that do the conversion. The first conversion should be unchanged, the second conversion takes in data from the first conversion and attempts to convert it again.

    /*
    * Copyright (c) 2012 Stefano Sabatini
    *
    * Permission is hereby granted, free of charge, to any person obtaining a copy
    * of this software and associated documentation files (the "Software"), to deal
    * in the Software without restriction, including without limitation the rights
    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    * copies of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    *
    * The above copyright notice and this permission notice shall be included in
    * all copies or substantial portions of the Software.
    *
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    * THE SOFTWARE.
    */

    /**
    * @example resampling_audio.c
    * libswresample API use example.
    */

    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>channel_layout.h>
    #include <libavutil></libavutil>samplefmt.h>
    #include <libswresample></libswresample>swresample.h>

    static int get_format_from_sample_fmt(const char **fmt,
                                         enum AVSampleFormat sample_fmt)
    {
       int i;
       struct sample_fmt_entry {
           enum AVSampleFormat sample_fmt; const char *fmt_be, *fmt_le;
       } sample_fmt_entries[] = {
           { AV_SAMPLE_FMT_U8,  "u8",    "u8"    },
           { AV_SAMPLE_FMT_S16, "s16be", "s16le" },
           { AV_SAMPLE_FMT_S32, "s32be", "s32le" },
           { AV_SAMPLE_FMT_FLT, "f32be", "f32le" },
           { AV_SAMPLE_FMT_DBL, "f64be", "f64le" },
       };
       *fmt = NULL;

       for (i = 0; i &lt; FF_ARRAY_ELEMS(sample_fmt_entries); i++) {
           struct sample_fmt_entry *entry = &amp;sample_fmt_entries[i];
           if (sample_fmt == entry->sample_fmt) {
               *fmt = AV_NE(entry->fmt_be, entry->fmt_le);
               return 0;
           }
       }

       fprintf(stderr,
               "Sample format %s not supported as output format\n",
               av_get_sample_fmt_name(sample_fmt));
       return AVERROR(EINVAL);
    }

    /**
    * Fill dst buffer with nb_samples, generated starting from t.
    */
    static void fill_samples(double *dst, int nb_samples, int nb_channels, int sample_rate, double *t)
    {
       int i, j;
       double tincr = 1.0 / sample_rate, *dstp = dst;
       const double c = 2 * M_PI * 440.0;

       /* generate sin tone with 440Hz frequency and duplicated channels */
       for (i = 0; i &lt; nb_samples; i++) {
           *dstp = sin(c * *t);
           for (j = 1; j &lt; nb_channels; j++)
               dstp[j] = dstp[0];
           dstp += nb_channels;
           *t += tincr;
       }
    }

    int main(int argc, char **argv)
    {
       int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
       int src_rate = 48000, dst_rate = 44100;
       uint8_t **src_data = NULL, **dst_data = NULL, **dst_data2 = NULL;
       int src_nb_channels = 0, dst_nb_channels = 0;
       int src_linesize, dst_linesize;
       int src_nb_samples = 1024, dst_nb_samples, max_dst_nb_samples, dst_nb_samples2, max_dst_nb_samples2;
       enum AVSampleFormat src_sample_fmt = AV_SAMPLE_FMT_DBL, dst_sample_fmt = AV_SAMPLE_FMT_S16;
       const char *dst_filename = NULL, *dst_filename2 = NULL;
       FILE *dst_file, *dst_file2;
       int dst_bufsize, dst_bufsize2;
       const char *fmt;
       struct SwrContext *swr_ctx;
       struct SwrContext *swr_ctx2;
       double t;
       int ret;

       if (argc != 3) {
           fprintf(stderr, "Usage: %s output_file_first output_file_second\n"
                   "API example program to show how to resample an audio stream with libswresample.\n"
                   "This program generates a series of audio frames, resamples them to a specified "
                   "output format and rate and saves them to an output file named output_file.\n",
               argv[0]);
           exit(1);
       }
       dst_filename = argv[1];
       dst_filename2 = argv[2];

       dst_file = fopen(dst_filename, "wb");
       if (!dst_file) {
           fprintf(stderr, "Could not open destination file %s\n", dst_filename);
           exit(1);
       }



       dst_file2 = fopen(dst_filename2, "wb");
       if (!dst_file2) {
           fprintf(stderr, "Could not open destination file 2 %s\n", dst_filename2);
           exit(1);
       }



       /* create resampler context */
       swr_ctx = swr_alloc();
       if (!swr_ctx) {
           fprintf(stderr, "Could not allocate resampler context\n");
           ret = AVERROR(ENOMEM);
           goto end;
       }

       /* set options */
       av_opt_set_int(swr_ctx, "in_channel_layout",    src_ch_layout, 0);
       av_opt_set_int(swr_ctx, "in_sample_rate",       src_rate, 0);
       av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", src_sample_fmt, 0);

       av_opt_set_int(swr_ctx, "out_channel_layout",    dst_ch_layout, 0);
       av_opt_set_int(swr_ctx, "out_sample_rate",       dst_rate, 0);
       av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", dst_sample_fmt, 0);

       /* initialize the resampling context */
       if ((ret = swr_init(swr_ctx)) &lt; 0) {
           fprintf(stderr, "Failed to initialize the resampling context\n");
           goto end;
       }


       /* create resampler context 2 */
       swr_ctx2 = swr_alloc();
       if (!swr_ctx2) {
           fprintf(stderr, "Could not allocate resampler context 2\n");
           ret = AVERROR(ENOMEM);
           goto end;
       }

       /* set options */
       av_opt_set_int(swr_ctx2, "in_channel_layout",    dst_ch_layout, 0);
       av_opt_set_int(swr_ctx2, "in_sample_rate",       dst_rate, 0);
       av_opt_set_sample_fmt(swr_ctx2, "in_sample_fmt", dst_sample_fmt, 0);

       av_opt_set_int(swr_ctx2, "out_channel_layout",    dst_ch_layout, 0);
       av_opt_set_int(swr_ctx2, "out_sample_rate",       32000, 0);
       av_opt_set_sample_fmt(swr_ctx2, "out_sample_fmt", dst_sample_fmt, 0);

       /* initialize the resampling context */
       if ((ret = swr_init(swr_ctx2)) &lt; 0) {
           fprintf(stderr, "Failed to initialize the resampling context 2\n");
           goto end;
       }

       /* allocate source and destination samples buffers */

       src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
       ret = av_samples_alloc_array_and_samples(&amp;src_data, &amp;src_linesize, src_nb_channels,
                                                src_nb_samples, src_sample_fmt, 0);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate source samples\n");
           goto end;
       }

       /* compute the number of converted samples: buffering is avoided
        * ensuring that the output buffer will contain at least all the
        * converted input samples */
       max_dst_nb_samples = dst_nb_samples =
           av_rescale_rnd(src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);

       /* buffer is going to be directly written to a rawaudio file, no alignment */
       dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout);
       ret = av_samples_alloc_array_and_samples(&amp;dst_data, &amp;dst_linesize, dst_nb_channels,
                                                dst_nb_samples, dst_sample_fmt, 0);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate destination samples\n");
           goto end;
       }


       /* compute the number of converted samples: buffering is avoided
        * ensuring that the output buffer will contain at least all the
        * converted input samples */
       max_dst_nb_samples2 = dst_nb_samples2 =
           av_rescale_rnd(dst_nb_samples, 32000, dst_rate, AV_ROUND_UP);

       /* buffer is going to be directly written to a rawaudio file, no alignment */
       // dst_nb_channels2  = av_get_channel_layout_nb_channels(dst_ch_layout);
       ret = av_samples_alloc_array_and_samples(&amp;dst_data2, &amp;dst_linesize, dst_nb_channels,
                                                dst_nb_samples2, dst_sample_fmt, 0);
       if (ret &lt; 0) {
           fprintf(stderr, "Could not allocate destination samples 2\n");
           goto end;
       }

       t = 0;
       do {
           /* generate synthetic audio */
           fill_samples((double *)src_data[0], src_nb_samples, src_nb_channels, src_rate, &amp;t);

           /* compute destination number of samples */
           dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, src_rate) +
                                           src_nb_samples, dst_rate, src_rate, AV_ROUND_UP);
           if (dst_nb_samples > max_dst_nb_samples) {
               av_freep(&amp;dst_data[0]);
               ret = av_samples_alloc(dst_data, &amp;dst_linesize, dst_nb_channels,
                                      dst_nb_samples, dst_sample_fmt, 1);
               if (ret &lt; 0)
                   break;
               max_dst_nb_samples = dst_nb_samples;
           }

           /* convert to destination format */
           ret = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t **)src_data, src_nb_samples);
           if (ret &lt; 0) {
               fprintf(stderr, "Error while converting\n");
               goto end;
           }

           dst_bufsize = av_samples_get_buffer_size(&amp;dst_linesize, dst_nb_channels,
                                                    ret, dst_sample_fmt, 1);
           if (dst_bufsize &lt; 0) {
               fprintf(stderr, "Could not get sample buffer size\n");
               goto end;
           }

           printf("t:%f in:%d out:%d\n", t, src_nb_samples, ret);
           fwrite(dst_data[0], 1, dst_bufsize, dst_file);

           /* compute destination number of samples 2 */
           dst_nb_samples2 = av_rescale_rnd(swr_get_delay(swr_ctx2, dst_rate) +
                                           dst_nb_samples2, 32000, dst_rate, AV_ROUND_UP);
           if (dst_nb_samples2 > max_dst_nb_samples2) {
               av_freep(&amp;dst_data2[0]);
               ret = av_samples_alloc(dst_data2, &amp;dst_linesize, dst_nb_channels,
                                      dst_nb_samples2, dst_sample_fmt, 1);
               if (ret &lt; 0)
                   break;
               max_dst_nb_samples2 = dst_nb_samples2;
           }

           /* convert to destination format */
           ret = swr_convert(swr_ctx2, dst_data2, dst_nb_samples2, (const uint8_t **)dst_data, dst_nb_samples);
           if (ret &lt; 0) {
               fprintf(stderr, "Error while converting 2\n");
               goto end;
           }

           dst_bufsize2 = av_samples_get_buffer_size(&amp;dst_linesize, dst_nb_channels,
                                                    ret, dst_sample_fmt, 1);
           if (dst_bufsize2 &lt; 0) {
               fprintf(stderr, "Could not get sample buffer size 2\n");
               goto end;
           }

           printf("t:%f in:%d out:%d\n", t, dst_nb_samples, ret);
           fwrite(dst_data2[0], 1, dst_bufsize2, dst_file2);
       } while (t &lt; 10);

       if ((ret = get_format_from_sample_fmt(&amp;fmt, dst_sample_fmt)) &lt; 0)
           goto end;
       fprintf(stderr, "Resampling succeeded. Play the output file with the command:\n"
               "ffplay -f %s -channel_layout %"PRId64" -channels %d -ar %d %s\n",
               fmt, dst_ch_layout, dst_nb_channels, dst_rate, dst_filename);

    end:
       fclose(dst_file);

       if (src_data)
           av_freep(&amp;src_data[0]);
       av_freep(&amp;src_data);

       if (dst_data)
           av_freep(&amp;dst_data[0]);
       av_freep(&amp;dst_data);

       swr_free(&amp;swr_ctx);
       return ret &lt; 0;
    }