Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (100)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • 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 ;

Sur d’autres sites (13030)

  • Reverse Engineering Italian Literature

    1er juillet 2014, par Multimedia Mike — Reverse Engineering

    Some time ago, Diego “Flameeyes” Pettenò tried his hand at reverse engineering a set of really old CD-ROMs containing even older Italian literature. The goal of this RE endeavor would be to extract the useful literature along with any structural metadata (chapters, etc.) and convert it to a more open format suitable for publication at, e.g., Project Gutenberg or Archive.org.

    Unfortunately, the structure of the data thwarted the more simplistic analysis attempts (like inspecting for blocks of textual data). This will require deeper RE techniques. Further frustrating the effort, however, is the fact that the binaries that implement the reading program are written for the now-archaic Windows 3.1 operating system.

    In pursuit of this RE goal, I recently thought of a way to glean more intelligence using DOSBox.

    Prior Work
    There are 6 discs in the full set (distributed along with 6 sequential issues of a print magazine named L’Espresso). Analysis of the contents of the various discs reveals that many of the files are the same on each disc. It was straightforward to identify the set of files which are unique on each disc. This set of files all end with the extension “LZn”, where n = 1..6 depending on the disc number. Further, the root directory of each disc has a file indicating the sequence number (1..6) of the CD. Obviously, these are the interesting targets.

    The LZ file extensions stand out to an individual skilled in the art of compression– could it be a variation of the venerable LZ compression ? That’s actually unlikely because LZ — also seen as LIZ — stands for Letteratura Italiana Zanichelli (Zanichelli’s Italian Literature).

    The Unix ‘file’ command was of limited utility, unable to plausibly identify any of the files.

    Progress was stalled.

    Saying Hello To An Old Frenemy
    I have been showing this screenshot to younger coworkers to see if any of them recognize it :


    DOSBox running Window 3.1

    Not a single one has seen it before. Senior computer citizen status : Confirmed.

    I recently watched an Ancient DOS Games video about Windows 3.1 games. This episode showed Windows 3.1 running under DOSBox. I had heard this was possible but that it took a little work to get running. I had a hunch that someone else had probably already done the hard stuff so I took to the BitTorrent networks and quickly found a download that had the goods ready to go– a directory of Windows 3.1 files that just had to be dropped into a DOSBox directory and they would be ready to run.

    Aside : Running OS software procured from a BitTorrent network ? Isn’t that an insane security nightmare ? I’m not too worried since it effectively runs under a sandboxed virtual machine, courtesy of DOSBox. I suppose there’s the risk of trojan’d OS software infecting binaries that eventually leave the sandbox.

    Using DOSBox Like ‘strace’
    strace is a tool available on some Unix systems, including Linux, which is able to monitor the system calls that a program makes. In reverse engineering contexts, it can be useful to monitor an opaque, binary program to see the names of the files it opens and how many bytes it reads, and from which locations. I have written examples of this before (wow, almost 10 years ago to the day ; now I feel old for the second time in this post).

    Here’s the pitch : Make DOSBox perform as strace in order to serve as a platform for reverse engineering Windows 3.1 applications. I formed a mental model about how DOSBox operates — abstracted file system classes with methods for opening and reading files — and then jumped into the source code. Sure enough, the code was exactly as I suspected and a few strategic print statements gave me the data I was looking for.

    Eventually, I even took to running DOSBox under the GNU Debugger (GDB). This hasn’t proven especially useful yet, but it has led to an absurd level of nesting :


    GDB runs DOSBox runs Windows 3.1

    The target application runs under Windows 3.1, which is running under DOSBox, which is running under GDB. This led to a crazy situation in which DOSBox had the mouse focus when a GDB breakpoint was triggered. At this point, DOSBox had all desktop input focus and couldn’t surrender it because it wasn’t running. I had no way to interact with the Linux desktop and had to reboot the computer. The next time, I took care to only use the keyboard to navigate the application and trigger the breakpoint and not allow DOSBox to consume the mouse focus.

    New Intelligence

    By instrumenting the local file class (virtual HD files) and the ISO file class (CD-ROM files), I was able to watch which programs and dynamic libraries are loaded and which data files the code cares about. I was able to narrow down the fact that the most interesting programs are called LEGGENDO.EXE (‘reading’) and LEGGENDA.EXE (‘legend’ ; this has been a great Italian lesson as well as RE puzzle). The first calls the latter, which displays this view of the data we are trying to get at :


    LIZ: Authors index

    When first run, the program takes an interest in a file called DBBIBLIO (‘database library’, I suspect) :

    === Read(’LIZ98\DBBIBLIO.LZ1’) : req 337 bytes ; read 337 bytes from pos 0x0
    === Read(’LIZ98\DBBIBLIO.LZ1’) : req 337 bytes ; read 337 bytes from pos 0x151
    === Read(’LIZ98\DBBIBLIO.LZ1’) : req 337 bytes ; read 337 bytes from pos 0x2A2
    [...]
    

    While we were unable to sort out all of the data files in our cursory investigation, a few things were obvious. The structure of this file looked to contain 336-byte records. Turns out I was off by 1– the records are actually 337 bytes each. The count of records read from disc is equal to the number of items shown in the UI.

    Next, the program is interested in a few more files :

    *** isoFile() : ’DEPOSITO\BLOKCTC.LZ1’, offset 0x27D6000, 2911488 bytes large
    === Read(’DEPOSITO\BLOKCTC.LZ1’) : req 96 bytes ; read 96 bytes from pos 0x0
    *** isoFile() : ’DEPOSITO\BLOKCTX0.LZ1’, offset 0x2A9D000, 17152 bytes large
    === Read(’DEPOSITO\BLOKCTX0.LZ1’) : req 128 bytes ; read 128 bytes from pos 0x0
    === Seek(’DEPOSITO\BLOKCTX0.LZ1’) : seek 384 (0x180) bytes, type 0
    === Read(’DEPOSITO\BLOKCTX0.LZ1’) : req 256 bytes ; read 256 bytes from pos 0x180
    === Seek(’DEPOSITO\BLOKCTC.LZ1’) : seek 1152 (0x480) bytes, type 0
    === Read(’DEPOSITO\BLOKCTC.LZ1’) : req 32 bytes ; read 32 bytes from pos 0x480
    === Read(’DEPOSITO\BLOKCTC.LZ1’) : req 1504 bytes ; read 1504 bytes from pos 0x4A0
    [...]

    Eventually, it becomes obvious that BLOKCTC has the juicy meat. There are 32-byte records followed by variable-length encoded text sections. Since there is no text to be found in these files, the text is either compressed, encrypted, or both. Some rough counting (the program seems to disable copy/paste, which thwarts more precise counting), indicates that the text size is larger than the data chunks being read from disc, so compression seems likely. Encryption isn’t out of the question (especially since the program deems it necessary to disable copy and pasting of this public domain literary data), and if it’s in use, that means the key is being read from one of these files.

    Blocked On Disassembly
    So I’m a bit blocked right now. I know exactly where the data lives, but it’s clear that I need to reverse engineer some binary code. The big problem is that I have no idea how to disassemble Windows 3.1 binaries. These are NE-type executable files. Disassemblers abound for MZ files (MS-DOS executables) and PE files (executables for Windows 95 and beyond). NE files get no respect. It’s difficult (but not impossible) to even find data about the format anymore, and details are incomplete. It should be noted, however, the DOSBox-as-strace method described here lends insight into how Windows 3.1 processes NE-type EXEs. You can’t get any more authoritative than that.

    So far, I have tried the freeware version of IDA Pro. Unfortunately, I haven’t been able to get the program to work on my Windows machine for a long time. Even if I could, I can’t find any evidence that it actually supports NE files (the free version specifically mentions MZ and PE, but does not mention NE or LE).

    I found an old copy of Borland’s beloved Turbo Assembler and Debugger package. It has Turbo Debugger for Windows, both regular and 32-bit versions. Unfortunately, the normal version just hangs Windows 3.1 in DOSBox. The 32-bit Turbo Debugger loads just fine but can’t load the NE file.

    I’ve also wondered if DOSBox contains any advanced features for trapping program execution and disassembling. I haven’t looked too deeply into this yet.

    Future Work
    NE files seem to be the executable format that time forgot. I have a crazy brainstorm about repacking NE files as MZ executables so that they could be taken apart with an MZ disassembler. But this will take some experimenting.

    If anyone else has any ideas about ripping open these binaries, I would appreciate hearing them.

    And I guess I shouldn’t be too surprised to learn that all the literature in this corpus is already freely available and easily downloadable anyway. But you shouldn’t be too surprised if that doesn’t discourage me from trying to crack the format that’s keeping this particular copy of the data locked up.

  • CD-R Read Speed Experiments

    21 mai 2011, par Multimedia Mike — Science Projects, Sega Dreamcast

    I want to know how fast I can really read data from a CD-R. Pursuant to my previous musings on this subject, I was informed that it is inadequate to profile reading just any file from a CD-R since data might be read faster or slower depending on whether the data is closer to the inside or the outside of the disc.

    Conclusion / Executive Summary
    It is 100% true that reading data from the outside of a CD-R is faster than reading data from the inside. Read on if you care to know the details of how I arrived at this conclusion, and to find out just how much speed advantage there is to reading from the outside rather than the inside.

    Science Project Outline

    • Create some sample CD-Rs with various properties
    • Get a variety of optical drives
    • Write a custom program that profiles the read speed

    Creating The Test Media
    It’s my understanding that not all CD-Rs are created equal. Fortunately, I have 3 spindles of media handy : Some plain-looking Memorex discs, some rather flamboyant Maxell discs, and those 80mm TDK discs :



    My approach for burning is to create a single file to be burned into a standard ISO-9660 filesystem. The size of the file will be the advertised length of the CD-R minus 1 megabyte for overhead— so, 699 MB for the 120mm discs, 209 MB for the 80mm disc. The file will contain a repeating sequence of 0..0xFF bytes.

    Profiling
    I don’t want to leave this to the vagaries of any filesystem handling layer so I will conduct this experiment at the sector level. Profiling program outline :

    • Read the CD-ROM TOC and get the number of sectors that comprise the data track
    • Profile reading the first 20 MB of sectors
    • Profile reading 20 MB of sectors in the middle of the track
    • Profile reading the last 20 MB of sectors

    Unfortunately, I couldn’t figure out the raw sector reading on modern Linux incarnations (which is annoying since I remember it being pretty straightforward years ago). So I left it to the filesystem after all. New algorithm :

    • Open the single, large file on the CD-R and query the file length
    • Profile reading the first 20 MB of data, 512 kbytes at a time
    • Profile reading 20 MB of sectors in the middle of the track (starting from filesize / 2 - 10 MB), 512 kbytes at a time
    • Profile reading the last 20 MB of sectors (starting from filesize - 20MB), 512 kbytes at a time

    Empirical Data
    I tested the program in Linux using an LG Slim external multi-drive (seen at the top of the pile in this post) and one of my Sega Dreamcast units. I gathered the median value of 3 runs for each area (inner, middle, and outer). I also conducted a buffer flush in between Linux runs (as root : 'sync; echo 3 > /proc/sys/vm/drop_caches').

    LG Slim external multi-drive (reading from inner, middle, and outer areas in kbytes/sec) :

    • TDK-80mm : 721, 897, 1048
    • Memorex-120mm : 1601, 2805, 3623
    • Maxell-120mm : 1660, 2806, 3624

    So the 120mm discs can range from about 10.5X all the way up to a full 24X on this drive. For whatever reason, the 80mm disc fares a bit worse — even at the inner track — with a range of 4.8X - 7X.

    Sega Dreamcast (reading from inner, middle, and outer areas in kbytes/sec) :

    • TDK-80mm : 502, 632, 749
    • Memorex-120mm : 499, 889, 1143
    • Maxell-120mm : 500, 890, 1156

    It’s interesting that the 80mm disc performed comparably to the 120mm discs in the Dreamcast, in contrast to the LG Slim drive. Also, the results are consistent with my previous profiling experiments, which largely only touched the inner area. The read speeds range from 3.3X - 7.7X. The middle of a 120mm disc reads at about 6X.

    Implications
    A few thoughts regarding these results :

    • Since the very definition of 1X is the minimum speed necessary to stream data from an audio CD, then presumably, original 1X CD-ROM drives would have needed to be capable of reading 1X from the inner area. I wonder what the max read speed at the outer edges was ? It’s unlikely I would be able to get a 1X drive working easily in this day and age since the earliest CD-ROM drives required custom controllers.
    • I think 24X is the max rated read speed for CD-Rs, at least for this drive. This implies that the marketing literature only cites the best possible numbers. I guess this is no surprise, similar to how monitors and TVs have always been measured by their diagonal dimension.
    • Given this data, how do you engineer an ISO-9660 filesystem image so that the timing-sensitive multimedia files live on the outermost track ? In the Dreamcast case, if you can guarantee your FMV files will live somewhere between the middle and the end of the disc, you should be able to count on a bitrate of at least 900 kbytes/sec.

    Source Code
    Here is the program I wrote for profiling. Note that the filename is hardcoded (#define FILENAME). Compiling for Linux is a simple 'gcc -Wall profile-cdr.c -o profile-cdr'. Compiling for Dreamcast is performed in the standard KallistiOS manner (people skilled in the art already know what they need to know) ; the only variation is to compile with the '-D_arch_dreamcast' flag, which the default KOS environment adds anyway.

    C :
    1. #ifdef _arch_dreamcast
    2.   #include <kos .h>
    3.  
    4.   /* map I/O functions to their KOS equivalents */
    5.   #define open fs_open
    6.   #define lseek fs_seek
    7.   #define read fs_read
    8.   #define close fs_close
    9.  
    10.   #define FILENAME "/cd/bigfile"
    11. #else
    12.   #include <stdio .h>
    13.   #include <sys /types.h>
    14.   #include </sys><sys /stat.h>
    15.   #include </sys><sys /time.h>
    16.   #include <fcntl .h>
    17.   #include <unistd .h>
    18.  
    19.   #define FILENAME "/media/Full disc/bigfile"
    20. #endif
    21.  
    22. /* Get a current absolute millisecond count ; it doesn’t have to be in
    23. * reference to anything special. */
    24. unsigned int get_current_milliseconds()
    25. {
    26. #ifdef _arch_dreamcast
    27.   return timer_ms_gettime64() ;
    28. #else
    29.   struct timeval tv ;
    30.   gettimeofday(&tv, NULL) ;
    31.   return tv.tv_sec * 1000 + tv.tv_usec / 1000 ;
    32. #endif
    33. }
    34.  
    35. #define READ_SIZE (20 * 1024 * 1024)
    36. #define READ_BUFFER_SIZE (512 * 1024)
    37.  
    38. int main()
    39. {
    40.   int i, j ;
    41.   int fd ;
    42.   char read_buffer[READ_BUFFER_SIZE] ;
    43.   off_t filesize ;
    44.   unsigned int start_time, end_time ;
    45.  
    46.   fd = open(FILENAME, O_RDONLY) ;
    47.   if (fd == -1)
    48.   {
    49.     printf("could not open %s\n", FILENAME) ;
    50.     return 1 ;
    51.   }
    52.   filesize = lseek(fd, 0, SEEK_END) ;
    53.  
    54.   for (i = 0 ; i <3 ; i++)
    55.   {
    56.     if (i == 0)
    57.     {
    58.       printf("reading inner 20 MB...\n") ;
    59.       lseek(fd, 0, SEEK_SET) ;
    60.     }
    61.     else if (i == 1)
    62.     {
    63.       printf("reading middle 20 MB...\n") ;
    64.       lseek(fd, (filesize / 2) - (READ_SIZE / 2), SEEK_SET) ;
    65.     }
    66.     else
    67.     {
    68.       printf("reading outer 20 MB...\n") ;
    69.       lseek(fd, filesize - READ_SIZE, SEEK_SET) ;
    70.     }
    71.     /* read 20 MB ; 40 chunks of 1/2 MB */
    72.     start_time = get_current_milliseconds() ;
    73.     for (j = 0 ; j <(READ_SIZE / READ_BUFFER_SIZE) ; j++)
    74.       if (read(fd, read_buffer, READ_BUFFER_SIZE) != READ_BUFFER_SIZE)
    75.       {
    76.         printf("read error\n") ;
    77.         break ;
    78.       }
    79.     end_time = get_current_milliseconds() ;
    80.     printf("%d - %d = %d ms => %d kbytes/sec\n",
    81.       end_time, start_time, end_time - start_time,
    82.       READ_SIZE / (end_time - start_time)) ;
    83.   }
    84.  
    85.   close(fd) ;
    86.  
    87.   return 0 ;
    88. }
  • how to extract audio from video using ffmpeg c++

    29 septembre 2020, par daenerys

    I am trying to write c++ code on how to extract audio from mp4 format file. I have compiled the examples in ffmpeg library and tried to run the demuxing_decoding.c file. The problem is that on running the code, it starts to decode way more than the actual file size and decodes wrong codec format (the decoded files cant be run).

    &#xA;&#xA;

    here is the demuxing_decoding.c that I am trying to run :

    &#xA;&#xA;

    #include &#xA;&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>channel_layout.h>&#xA;#include <libavutil></libavutil>common.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libavutil></libavutil>mathematics.h>&#xA;#include <libavutil></libavutil>samplefmt.h>&#xA;&#xA;#define INBUF_SIZE 4096&#xA;#define AUDIO_INBUF_SIZE 20480&#xA;#define AUDIO_REFILL_THRESH 4096&#xA;&#xA;/* check that a given sample format is supported by the encoder */&#xA;static int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt)&#xA;{&#xA;    const enum AVSampleFormat *p = codec->sample_fmts;&#xA;&#xA;    while (*p != AV_SAMPLE_FMT_NONE) {&#xA;        if (*p == sample_fmt)&#xA;            return 1;&#xA;        p&#x2B;&#x2B;;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;/* just pick the highest supported samplerate */&#xA;static int select_sample_rate(AVCodec *codec)&#xA;{&#xA;    const int *p;&#xA;    int best_samplerate = 0;&#xA;&#xA;    if (!codec->supported_samplerates)&#xA;        return 44100;&#xA;&#xA;    p = codec->supported_samplerates;&#xA;    while (*p) {&#xA;        best_samplerate = FFMAX(*p, best_samplerate);&#xA;        p&#x2B;&#x2B;;&#xA;    }&#xA;    return best_samplerate;&#xA;}&#xA;&#xA;/* select layout with the highest channel count */&#xA;static int select_channel_layout(AVCodec *codec)&#xA;{&#xA;    const uint64_t *p;&#xA;    uint64_t best_ch_layout = 0;&#xA;    int best_nb_channels   = 0;&#xA;&#xA;    if (!codec->channel_layouts)&#xA;        return AV_CH_LAYOUT_STEREO;&#xA;&#xA;    p = codec->channel_layouts;&#xA;    while (*p) {&#xA;        int nb_channels = av_get_channel_layout_nb_channels(*p);&#xA;&#xA;        if (nb_channels > best_nb_channels) {&#xA;            best_ch_layout    = *p;&#xA;            best_nb_channels = nb_channels;&#xA;        }&#xA;        p&#x2B;&#x2B;;&#xA;    }&#xA;    return best_ch_layout;&#xA;}&#xA;&#xA;/*&#xA; * Audio encoding example&#xA; */&#xA;static void audio_encode_example(const char *filename)&#xA;{&#xA;    AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    AVFrame *frame;&#xA;    AVPacket pkt;&#xA;    int i, j, k, ret, got_output;&#xA;    int buffer_size;&#xA;    FILE *f;&#xA;    uint16_t *samples;&#xA;    float t, tincr;&#xA;&#xA;    printf("Encode audio file %s\n", filename);&#xA;&#xA;    /* find the MP2 encoder */&#xA;    codec = avcodec_find_encoder(AV_CODEC_ID_MP2);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not allocate audio codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* put sample parameters */&#xA;    c->bit_rate = 64000;&#xA;&#xA;    /* check that the encoder supports s16 pcm input */&#xA;    c->sample_fmt = AV_SAMPLE_FMT_S16;&#xA;    if (!check_sample_fmt(codec, c->sample_fmt)) {&#xA;        fprintf(stderr, "Encoder does not support sample format %s",&#xA;                av_get_sample_fmt_name(c->sample_fmt));&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* select other audio parameters supported by the encoder */&#xA;    c->sample_rate    = select_sample_rate(codec);&#xA;    c->channel_layout = select_channel_layout(codec);&#xA;    c->channels       = av_get_channel_layout_nb_channels(c->channel_layout);&#xA;&#xA;    /* open it */&#xA;    if (avcodec_open2(c, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    f = fopen(filename, "wb");&#xA;    if (!f) {&#xA;        fprintf(stderr, "Could not open %s\n", filename);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* frame containing input raw audio */&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate audio frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    frame->nb_samples     = c->frame_size;&#xA;    frame->format         = c->sample_fmt;&#xA;    frame->channel_layout = c->channel_layout;&#xA;&#xA;    /* the codec gives us the frame size, in samples,&#xA;     * we calculate the size of the samples buffer in bytes */&#xA;    buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,&#xA;                                             c->sample_fmt, 0);&#xA;    if (buffer_size &lt; 0) {&#xA;        fprintf(stderr, "Could not get sample buffer size\n");&#xA;        exit(1);&#xA;    }&#xA;    samples = av_malloc(buffer_size);&#xA;    if (!samples) {&#xA;        fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",&#xA;                buffer_size);&#xA;        exit(1);&#xA;    }&#xA;    /* setup the data pointers in the AVFrame */&#xA;    ret = avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,&#xA;                                   (const uint8_t*)samples, buffer_size, 0);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not setup audio frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* encode a single tone sound */&#xA;    t = 0;&#xA;    tincr = 2 * M_PI * 440.0 / c->sample_rate;&#xA;    for (i = 0; i &lt; 200; i&#x2B;&#x2B;) {&#xA;        av_init_packet(&amp;pkt);&#xA;        pkt.data = NULL; // packet data will be allocated by the encoder&#xA;        pkt.size = 0;&#xA;&#xA;        for (j = 0; j &lt; c->frame_size; j&#x2B;&#x2B;) {&#xA;            samples[2*j] = (int)(sin(t) * 10000);&#xA;&#xA;            for (k = 1; k &lt; c->channels; k&#x2B;&#x2B;)&#xA;                samples[2*j &#x2B; k] = samples[2*j];&#xA;            t &#x2B;= tincr;&#xA;        }&#xA;        /* encode the samples */&#xA;        ret = avcodec_encode_audio2(c, &amp;pkt, frame, &amp;got_output);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding audio frame\n");&#xA;            exit(1);&#xA;        }&#xA;        if (got_output) {&#xA;            fwrite(pkt.data, 1, pkt.size, f);&#xA;            av_free_packet(&amp;pkt);&#xA;        }&#xA;    }&#xA;&#xA;    /* get the delayed frames */&#xA;    for (got_output = 1; got_output; i&#x2B;&#x2B;) {&#xA;        ret = avcodec_encode_audio2(c, &amp;pkt, NULL, &amp;got_output);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding frame\n");&#xA;            exit(1);&#xA;        }&#xA;&#xA;        if (got_output) {&#xA;            fwrite(pkt.data, 1, pkt.size, f);&#xA;            av_free_packet(&amp;pkt);&#xA;        }&#xA;    }&#xA;    fclose(f);&#xA;&#xA;    av_freep(&amp;samples);&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_close(c);&#xA;    av_free(c);&#xA;}&#xA;&#xA;/*&#xA; * Audio decoding.&#xA; */&#xA;static void audio_decode_example(const char *outfilename, const char *filename)&#xA;{&#xA;    AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    int len;&#xA;    FILE *f, *outfile;&#xA;    uint8_t inbuf[AUDIO_INBUF_SIZE &#x2B; AV_INPUT_BUFFER_PADDING_SIZE];&#xA;    AVPacket avpkt;&#xA;    AVFrame *decoded_frame = NULL;&#xA;&#xA;    av_init_packet(&amp;avpkt);&#xA;&#xA;    printf("Decode audio file %s to %s\n", filename, outfilename);&#xA;&#xA;    /* find the mpeg audio decoder */&#xA;    codec = avcodec_find_decoder(AV_CODEC_ID_MP2);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not allocate audio codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* open it */&#xA;    if (avcodec_open2(c, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    f = fopen(filename, "rb");&#xA;    if (!f) {&#xA;        fprintf(stderr, "Could not open %s\n", filename);&#xA;        exit(1);&#xA;    }&#xA;    outfile = fopen(outfilename, "wb");&#xA;    if (!outfile) {&#xA;        av_free(c);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* decode until eof */&#xA;    avpkt.data = inbuf;&#xA;    avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);&#xA;&#xA;    while (avpkt.size > 0) {&#xA;        int i, ch;&#xA;        int got_frame = 0;&#xA;&#xA;        if (!decoded_frame) {&#xA;            if (!(decoded_frame = av_frame_alloc())) {&#xA;                fprintf(stderr, "Could not allocate audio frame\n");&#xA;                exit(1);&#xA;            }&#xA;        }&#xA;&#xA;        len = avcodec_decode_audio4(c, decoded_frame, &amp;got_frame, &amp;avpkt);&#xA;        if (len &lt; 0) {&#xA;            fprintf(stderr, "Error while decoding\n");&#xA;            exit(1);&#xA;        }&#xA;        if (got_frame) {&#xA;            /* if a frame has been decoded, output it */&#xA;            int data_size = av_get_bytes_per_sample(c->sample_fmt);&#xA;            if (data_size &lt; 0) {&#xA;                /* This should not occur, checking just for paranoia */&#xA;                fprintf(stderr, "Failed to calculate data size\n");&#xA;                exit(1);&#xA;            }&#xA;            for (i=0; inb_samples; i&#x2B;&#x2B;)&#xA;                for (ch=0; chchannels; ch&#x2B;&#x2B;)&#xA;                    fwrite(decoded_frame->data[ch] &#x2B; data_size*i, 1, data_size, outfile);&#xA;        }&#xA;        avpkt.size -= len;&#xA;        avpkt.data &#x2B;= len;&#xA;        avpkt.dts =&#xA;        avpkt.pts = AV_NOPTS_VALUE;&#xA;        if (avpkt.size &lt; AUDIO_REFILL_THRESH) {&#xA;            /* Refill the input buffer, to avoid trying to decode&#xA;             * incomplete frames. Instead of this, one could also use&#xA;             * a parser, or use a proper container format through&#xA;             * libavformat. */&#xA;            memmove(inbuf, avpkt.data, avpkt.size);&#xA;            avpkt.data = inbuf;&#xA;            len = fread(avpkt.data &#x2B; avpkt.size, 1,&#xA;                        AUDIO_INBUF_SIZE - avpkt.size, f);&#xA;            if (len > 0)&#xA;                avpkt.size &#x2B;= len;&#xA;        }&#xA;    }&#xA;&#xA;    fclose(outfile);&#xA;    fclose(f);&#xA;&#xA;    avcodec_close(c);&#xA;    av_free(c);&#xA;    av_frame_free(&amp;decoded_frame);&#xA;}&#xA;&#xA;/*&#xA; * Video encoding example&#xA; */&#xA;static void video_encode_example(const char *filename, int codec_id)&#xA;{&#xA;    AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    int i, ret, x, y, got_output;&#xA;    FILE *f;&#xA;    AVFrame *frame;&#xA;    AVPacket pkt;&#xA;    uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;&#xA;    printf("Encode video file %s\n", filename);&#xA;&#xA;    /* find the mpeg1 video encoder */&#xA;    codec = avcodec_find_encoder(codec_id);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not allocate video codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* put sample parameters */&#xA;    c->bit_rate = 400000;&#xA;    /* resolution must be a multiple of two */&#xA;    c->width = 352;&#xA;    c->height = 288;&#xA;    /* frames per second */&#xA;    c->time_base = (AVRational){1,25};&#xA;    /* emit one intra frame every ten frames&#xA;     * check frame pict_type before passing frame&#xA;     * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;     * then gop_size is ignored and the output of encoder&#xA;     * will always be I frame irrespective to gop_size&#xA;     */&#xA;    c->gop_size = 10;&#xA;    c->max_b_frames = 1;&#xA;    c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;&#xA;    if (codec_id == AV_CODEC_ID_H264)&#xA;        av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;&#xA;    /* open it */&#xA;    if (avcodec_open2(c, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    f = fopen(filename, "wb");&#xA;    if (!f) {&#xA;        fprintf(stderr, "Could not open %s\n", filename);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        exit(1);&#xA;    }&#xA;    frame->format = c->pix_fmt;&#xA;    frame->width  = c->width;&#xA;    frame->height = c->height;&#xA;&#xA;    /* the image can be allocated by any means and av_image_alloc() is&#xA;     * just the most convenient way if av_malloc() is to be used */&#xA;    ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height,&#xA;                         c->pix_fmt, 32);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Could not allocate raw picture buffer\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* encode 1 second of video */&#xA;    for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;        av_init_packet(&amp;pkt);&#xA;        pkt.data = NULL;    // packet data will be allocated by the encoder&#xA;        pkt.size = 0;&#xA;&#xA;        fflush(stdout);&#xA;        /* prepare a dummy image */&#xA;        /* Y */&#xA;        for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;            for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;            }&#xA;        }&#xA;&#xA;        /* Cb and Cr */&#xA;        for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;            for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;            }&#xA;        }&#xA;&#xA;        frame->pts = i;&#xA;&#xA;        /* encode the image */&#xA;        ret = avcodec_encode_video2(c, &amp;pkt, frame, &amp;got_output);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding frame\n");&#xA;            exit(1);&#xA;        }&#xA;&#xA;        if (got_output) {&#xA;            printf("Write frame %3d (size=%5d)\n", i, pkt.size);&#xA;            fwrite(pkt.data, 1, pkt.size, f);&#xA;            av_free_packet(&amp;pkt);&#xA;        }&#xA;    }&#xA;&#xA;    /* get the delayed frames */&#xA;    for (got_output = 1; got_output; i&#x2B;&#x2B;) {&#xA;        fflush(stdout);&#xA;&#xA;        ret = avcodec_encode_video2(c, &amp;pkt, NULL, &amp;got_output);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding frame\n");&#xA;            exit(1);&#xA;        }&#xA;&#xA;        if (got_output) {&#xA;            printf("Write frame %3d (size=%5d)\n", i, pkt.size);&#xA;            fwrite(pkt.data, 1, pkt.size, f);&#xA;            av_free_packet(&amp;pkt);&#xA;        }&#xA;    }&#xA;&#xA;    /* add sequence end code to have a real mpeg file */&#xA;    fwrite(endcode, 1, sizeof(endcode), f);&#xA;    fclose(f);&#xA;&#xA;    avcodec_close(c);&#xA;    av_free(c);&#xA;    av_freep(&amp;frame->data[0]);&#xA;    av_frame_free(&amp;frame);&#xA;    printf("\n");&#xA;}&#xA;&#xA;/*&#xA; * Video decoding example&#xA; */&#xA;&#xA;static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,&#xA;                     char *filename)&#xA;{&#xA;    FILE *f;&#xA;    int i;&#xA;&#xA;    f = fopen(filename,"w");&#xA;    fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);&#xA;    for (i = 0; i &lt; ysize; i&#x2B;&#x2B;)&#xA;        fwrite(buf &#x2B; i * wrap, 1, xsize, f);&#xA;    fclose(f);&#xA;}&#xA;&#xA;static int decode_write_frame(const char *outfilename, AVCodecContext *avctx,&#xA;                              AVFrame *frame, int *frame_count, AVPacket *pkt, int last)&#xA;{&#xA;    int len, got_frame;&#xA;    char buf[1024];&#xA;&#xA;    len = avcodec_decode_video2(avctx, frame, &amp;got_frame, pkt);&#xA;    if (len &lt; 0) {&#xA;        fprintf(stderr, "Error while decoding frame %d\n", *frame_count);&#xA;        return len;&#xA;    }&#xA;    if (got_frame) {&#xA;        printf("Saving %sframe %3d\n", last ? "last " : "", *frame_count);&#xA;        fflush(stdout);&#xA;&#xA;        /* the picture is allocated by the decoder, no need to free it */&#xA;        snprintf(buf, sizeof(buf), outfilename, *frame_count);&#xA;        pgm_save(frame->data[0], frame->linesize[0],&#xA;                 frame->width, frame->height, buf);&#xA;        (*frame_count)&#x2B;&#x2B;;&#xA;    }&#xA;    if (pkt->data) {&#xA;        pkt->size -= len;&#xA;        pkt->data &#x2B;= len;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;static void video_decode_example(const char *outfilename, const char *filename)&#xA;{&#xA;    AVCodec *codec;&#xA;    AVCodecContext *c= NULL;&#xA;    int frame_count;&#xA;    FILE *f;&#xA;    AVFrame *frame;&#xA;    uint8_t inbuf[INBUF_SIZE &#x2B; AV_INPUT_BUFFER_PADDING_SIZE];&#xA;    AVPacket avpkt;&#xA;&#xA;    av_init_packet(&amp;avpkt);&#xA;&#xA;    /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */&#xA;    memset(inbuf &#x2B; INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);&#xA;&#xA;    printf("Decode video file %s to %s\n", filename, outfilename);&#xA;&#xA;    /* find the mpeg1 video decoder */&#xA;    codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    c = avcodec_alloc_context3(codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not allocate video codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if (codec->capabilities &amp; AV_CODEC_CAP_TRUNCATED)&#xA;        c->flags |= AV_CODEC_FLAG_TRUNCATED; // we do not send complete frames&#xA;&#xA;    /* For some codecs, such as msmpeg4 and mpeg4, width and height&#xA;       MUST be initialized there because this information is not&#xA;       available in the bitstream. */&#xA;&#xA;    /* open it */&#xA;    if (avcodec_open2(c, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    f = fopen(filename, "rb");&#xA;    if (!f) {&#xA;        fprintf(stderr, "Could not open %s\n", filename);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    frame_count = 0;&#xA;    for (;;) {&#xA;        avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);&#xA;        if (avpkt.size == 0)&#xA;            break;&#xA;&#xA;        /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio)&#xA;           and this is the only method to use them because you cannot&#xA;           know the compressed data size before analysing it.&#xA;&#xA;           BUT some other codecs (msmpeg4, mpeg4) are inherently frame&#xA;           based, so you must call them with all the data for one&#xA;           frame exactly. You must also initialize &#x27;width&#x27; and&#xA;           &#x27;height&#x27; before initializing them. */&#xA;&#xA;        /* NOTE2: some codecs allow the raw parameters (frame size,&#xA;           sample rate) to be changed at any frame. We handle this, so&#xA;           you should also take care of it */&#xA;&#xA;        /* here, we use a stream based decoder (mpeg1video), so we&#xA;           feed decoder and see if it could decode a frame */&#xA;        avpkt.data = inbuf;&#xA;        while (avpkt.size > 0)&#xA;            if (decode_write_frame(outfilename, c, frame, &amp;frame_count, &amp;avpkt, 0) &lt; 0)&#xA;                exit(1);&#xA;    }&#xA;&#xA;    /* some codecs, such as MPEG, transmit the I and P frame with a&#xA;       latency of one frame. You must do the following to have a&#xA;       chance to get the last frame of the video */&#xA;    avpkt.data = NULL;&#xA;    avpkt.size = 0;&#xA;    decode_write_frame(outfilename, c, frame, &amp;frame_count, &amp;avpkt, 1);&#xA;&#xA;    fclose(f);&#xA;&#xA;    avcodec_close(c);&#xA;    av_free(c);&#xA;    av_frame_free(&amp;frame);&#xA;    printf("\n");&#xA;}&#xA;&#xA;int main(int argc, char **argv)&#xA;{&#xA;    const char *output_type;&#xA;&#xA;    /* register all the codecs */&#xA;    avcodec_register_all();&#xA;&#xA;    if (argc &lt; 2) {&#xA;        printf("usage: %s output_type\n"&#xA;               "API example program to decode/encode a media stream with libavcodec.\n"&#xA;               "This program generates a synthetic stream and encodes it to a file\n"&#xA;               "named test.h264, test.mp2 or test.mpg depending on output_type.\n"&#xA;               "The encoded stream is then decoded and written to a raw data output.\n"&#xA;               "output_type must be chosen between &#x27;h264&#x27;, &#x27;mp2&#x27;, &#x27;mpg&#x27;.\n",&#xA;               argv[0]);&#xA;        return 1;&#xA;    }&#xA;    output_type = argv[1];&#xA;&#xA;    if (!strcmp(output_type, "h264")) {&#xA;        video_encode_example("test.h264", AV_CODEC_ID_H264);&#xA;    } else if (!strcmp(output_type, "mp2")) {&#xA;        audio_encode_example("test.mp2");&#xA;        audio_decode_example("test.pcm", "test.mp2");&#xA;    } else if (!strcmp(output_type, "mpg")) {&#xA;        video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);&#xA;        video_decode_example("test%02d.pgm", "test.mpg");&#xA;    } else {&#xA;        fprintf(stderr, "Invalid output type &#x27;%s&#x27;, choose between &#x27;h264&#x27;, &#x27;mp2&#x27;, or &#x27;mpg&#x27;\n",&#xA;                output_type);&#xA;        return 1;&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;&#xA;

    What could be wrong ?&#xA;The command I used is :

    &#xA;&#xA;

    ./demuxing_decoding /home/cortana/Burn.mp4 /home/cortana/Desktop/Burn.mp4 /home/cortana/Desktop/Burn.aac&#xA;

    &#xA;