Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (74)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

Sur d’autres sites (6375)

  • how to reencode with ffmpeg (with limited x264)

    26 mai 2012, par sarfraz

    Until now I used this script to reencode my rips for my box (tv decoder) :

    ^_^ ( ~ ) -> cat ~/++/src/convert.sh
    #! /bin/bash

    name=$(path -r "$1") # it gives the file name without the extension

    [ "$1" = *.mp4 ] && ffmpeg -i "$name".mp4 -vcodec copy -acodec copy "$name".mkv
    x264 --preset veryfast --tune animation --crf 18 --vf resize:720,576,16:15 -o "$name".tmp.mkv "$name".mkv
    mkvmerge -o "$name [freeplayer sd]".mkv "$name".tmp.mkv --no-video "$1"
    rm -rf "$name".tmp.mkv
    [ "$1" = *.mp4 ] && rm -rf "$name".mkv
    exit 0

    #EOF

    It works on my ubuntu and archlinux laptops. But it doesn’t on my desktop witch runs fedora.
    Google says that the x264 package shiped by rpmfusion doesn,t support lavf and ffms2.
    And I cannot unistall it because smplayer (witch i like) needs it.

    Ok, so I have to compile it. Google then says "you have to build ffmpeg, ffms2 tnen x264 ensuring that the flags are correctly refered." Well, didn’t work (ffms2 cannot find LIBAV - even when I am telling where - and x264 does’t configure with lavf...)

    My question is : can I use ffmpeg alone to do what my script does.
    I have ffmpeg version 0.8.11, x264 0.116.2048 59cb2eb and gcc : 4.6.1 20110804 (Red Hat 4.6.1-7)

    Any hint wound be appreciated.

    EDIT : Ok, I found that : ffmpeg -i input file -acodec copy -vcodec libx264 -preset veryfast -tune animation [that part I don’t have] output

    PS : english is not my native, plz forgive any spelling fault.

  • MP3 audio recording from an input device using the FFmpeg API

    25 novembre 2014, par Hascoet Julien

    I’ve been trying to use the ffmpeg library (I’m working in C with the ffmpeg API) to decode and encode in mp3 from my microphone on Linux. The mp3lane lib is installed and I manage to open all codecs and to decode input samples.
    Here are my input settings :

    Input #1, alsa, from 'default':
     Duration: N/A, start: 1416946099.454877, bitrate: 1536 kb/s
       Stream #1:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s

    And I manage to decode it ; therefore, it gives me 2 channels of 64 samples after calling avcodec_decode_audio4 right after av_read_frame. The output frame that avcodec_decode_audio4 just gave me seems to be ok with 2 channels as well and 64 samples per channel. Packets are size of 256 and 16-bit*2*64 = 256 bytes so that makes sense.

    The problem is when i’m trying to encode this decoded frame with avcodec_encode_audio2 and the codec sets to AV_CODEC_ID_MP3 (I don’t have any codec opening issues) it gives me a segmentation fault (core dumped) whereas everything is allocated... I wonder that perhaps I have too many samples or not enough therefore the encode function is going where nothing is allocated...Probably i have to use some resampling methods but i have no clue.

    Is anyone ever try to encode in mp3 from an input device using the ffmpeg C API and to mux it in a mp3 file or even an avi file ? ( from a microphone)

    The ffmpeg command line works perfectly : ffmpeg -f alsa -i default out.mp3

    Here is my ffmpeg compilation setup with preinstalled stuffs :

    sudo apt-get install libasound2-dev      
    sudo apt-get install libmp3lame-dev

    ./configure --disable-static --enable-shared --enable-gpl --enable-libx264 --enable-libv4l2 --enable-gpl --enable-swscale --enable-libmp3lame

    sudo make install

    export LD_LIBRARY_PATH=/usr/local/lib

    Thank you guys !

    Here is the code is used, this is run with pthread after (see main()) :

    #define DEFAULT_AUDIO_INPUT_DRIVER_NAME         "alsa"
    #define DEFAULT_AUDIO_INPUT_DEVICE_NAME         "default"
    #define DEFAULT_USED_AUDIO_CODEC                AV_CODEC_ID_MP3
    #define DEFAULT_OUTPUT_AUDIO_FRAMERATE          44100
    #define DEFAULT_AUDIO_OUTPUT_FILE_NAME          "audioTest.mp3"



    /* Input and Output audio format.*/
    static AVFormatContext *ifmt_ctx = NULL;
    static AVFormatContext *ofmt_ctx = NULL; //from video

    /* Codec contexts used to encode input and output. */
    static AVCodecContext *dec_ctx = NULL;
    static AVCodecContext *enc_ctx = NULL;

    AVPacket audioPacket = { .data = NULL, .size = 0 };
    AVPacket audioEncodedPacket = { .data = NULL, .size = 0 };
    AVFrame *decodedAudioFrame = NULL;
    AVFrame *rescaledAudioFrame = NULL;
    AVStream *streamAudio = NULL;
    AVCodec *audioEncodeCodec = NULL;
    static struct SwrContext *swr_ctx;


    /* Audio configuration */
    char *AUDIO_INPUT_DRIVER_NAME           = {DEFAULT_AUDIO_INPUT_DRIVER_NAME};
    char *AUDIO_INPUT_DEVICE_NAME           = {DEFAULT_AUDIO_INPUT_DEVICE_NAME};
    enum AVCodecID AUDIO_ENCODED_CODEC_ID   = DEFAULT_USED_AUDIO_CODEC;
    int AUDIO_FRAME_RATE                    = DEFAULT_OUTPUT_AUDIO_FRAMERATE;
    char* AUDIO_OUTPUT_FILE_NAME            = {DEFAULT_AUDIO_OUTPUT_FILE_NAME};

    static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
                                     uint64_t channel_layout,
                                     int sample_rate, int nb_samples)
    {
       AVFrame *frame = av_frame_alloc();
       int ret;

       if (!frame) {
           syslog(LOG_ERR, "Error allocating an audio frame\n");
           exit(0);
       }

       frame->format = sample_fmt;
       frame->channel_layout = channel_layout;
       frame->sample_rate = sample_rate;
       frame->nb_samples = nb_samples;

       if (nb_samples) {
           ret = av_frame_get_buffer(frame, 0);
           if (ret < 0) {
               syslog(LOG_ERR, "Error allocating an audio buffer\n");
               exit(0);
           }
       }
       return frame;
    }

    static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
    {
       AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;

      syslog(LOG_INFO, "AUDIO pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
              av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
              av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
              av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base), pkt->stream_index);
    }

    static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
    {
       /* rescale output packet timestamp values from codec to stream timebase */
       //printf("Write Time Rescale\n");
       av_packet_rescale_ts(pkt, *time_base, st->time_base);
       pkt->stream_index = st->index;

       /* Write the compressed frame to the media file. */
       log_packet(fmt_ctx, pkt);
       //printf("Write In File Audio packet size of %d\n", pkt->size);
       //return av_interleaved_write_frame(fmt_ctx, pkt);
       return av_write_frame(fmt_ctx, pkt);
    }

    static void openAudioInput(const char *driverName, const char *deviceName){  
       int i; AVInputFormat *file_iformat = NULL;
       if((file_iformat = av_find_input_format(driverName)) == NULL){
           syslog(LOG_ERR ,"The %s doesn't seem to be registered\n", driverName);
           exit(0);
       }
       /* Open the device, in order to use the audio linux driver. */
       if((avformat_open_input(&ifmt_ctx, deviceName, file_iformat, NULL)) < 0){
           syslog(LOG_ERR ,"Error while trying to open %s.\n", deviceName);
           exit(0);
       }
       if((avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
           syslog(LOG_ERR, "Cannot find stream information\n");
           exit(0);
       }
       /* Open decoder */
       //printf("Number of input stream: %d\n", ifmt_ctx->nb_streams);
       /*if(ifmt_ctx->streams[0]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
           printf("AUDIO_TYPE\n");*/
       for(i = 0; i < ifmt_ctx->nb_streams; i++)
           if(ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO
                   || ifmt_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
               if(avcodec_open2(ifmt_ctx->streams[i]->codec,            
               avcodec_find_decoder(ifmt_ctx->streams[i]->codec->codec_id), NULL) < 0){
                   syslog(LOG_ERR, "Cannot find stream information\n");
                   exit(0);
               }
       av_dump_format(ifmt_ctx, 1, deviceName, 0);
    }


    static void openAudioOutput(const char *deviceName, const char *fileName, enum AVCodecID encodeCodec){
       AVStream *out_stream = NULL, *in_stream = NULL;
       AVCodec *encoder;
       avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, fileName);
       if(!ofmt_ctx){
           syslog(LOG_ERR, "Could not create output context\n");
           exit(0);
       }
       out_stream = avformat_new_stream(ofmt_ctx, NULL);
       if(!out_stream){
           syslog(LOG_ERR, "Failed allocating output stream\n");
           exit(0);
       }
       (ifmt_ctx!=NULL) ? in_stream = ifmt_ctx->streams[0] : exit(0);
       dec_ctx = in_stream->codec;
       enc_ctx = out_stream->codec;
       /* find encoder */
       encoder = avcodec_find_encoder(encodeCodec);
       enc_ctx->codec = encoder;
       /* AUDIO PARAMETERS */
       enc_ctx->sample_fmt = encoder->sample_fmts[0];
       enc_ctx->bit_rate = 128000; //added

           enc_ctx->sample_rate = dec_ctx->sample_rate;
           enc_ctx->channel_layout = AV_CH_LAYOUT_MONO;//dec_ctx->channel_layout;
           out_stream->time_base = enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
           enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout);

       printf("Sample Rate: %d Number Encoded channels: %d\n", dec_ctx->sample_rate, enc_ctx->channels);
       /* Open encoder with the found codec */
       if(avcodec_open2(enc_ctx, encoder, NULL) < 0) {
           syslog(LOG_ERR, "Cannot open audio encoder for stream\n");
           exit(0);
       }
       av_dump_format(ofmt_ctx, 0, fileName, 1);
       if (!(ofmt_ctx->oformat->flags & AVFMT_NOFILE))
           if(avio_open(&ofmt_ctx->pb, fileName, AVIO_FLAG_WRITE) < 0){
               syslog(LOG_ERR, "Could not open output file '%s'", fileName);
               exit(0);
           }
       /* init muxer, write output file header */
       if(avformat_write_header(ofmt_ctx, NULL) < 0){
           syslog(LOG_ERR, "Error occurred when opening output file\n");
           exit(0);
       }


       decodedAudioFrame = av_frame_alloc();
       rescaledAudioFrame = av_frame_alloc();
    }



    void initAudio(void){
       openAudioInput(AUDIO_INPUT_DRIVER_NAME, AUDIO_INPUT_DEVICE_NAME);
       openAudioOutput(AUDIO_INPUT_DEVICE_NAME, AUDIO_OUTPUT_FILE_NAME, AUDIO_ENCODED_CODEC_ID);
    }

    void *audioThread(void){
       int16_t *   samples;
       int gotDecodedFrame, dst_nb_samples, samples_count=0;
       int packetCounter = 0;

       int i = 0, got_packet, got_input, ret;
       float sizeOfFile = 0;

       AVPacket packet = { .data = NULL, .size = 0 };

       struct timespec t0, t1;
       int flags = fcntl(0, F_GETFL);
       flags = fcntl(0, F_SETFL, flags | O_NONBLOCK); //set non-blocking read on stdin
       packetCounter = 0;

       do{
           clock_gettime(CLOCK_REALTIME, &t0);
           if ((av_read_frame(ifmt_ctx, &audioPacket)) < 0){
               break;
           }
           packetCounter++;

           clock_gettime(CLOCK_REALTIME, &t1);
           av_init_packet(&audioEncodedPacket);
           audioEncodedPacket.data = NULL;
           audioEncodedPacket.size = 0;

           if (avcodec_decode_audio4(dec_ctx, decodedAudioFrame, &gotDecodedFrame, &audioPacket) < 0) {
               syslog(LOG_ERR ,"Can't Decode the packet received from the camera.\n");
               exit(0);
           }

           printf("Audio Decoded, Nb Channel %d, Samples per Channel %d, Size %d, PTS %ld\n",
               decodedAudioFrame->channels,
               decodedAudioFrame->nb_samples,
               decodedAudioFrame->pkt_size,
               decodedAudioFrame->pkt_pts);
           /*if((ret = swr_convert(swr_ctx, rescaledAudioFrame->data, rescaledAudioFrame->nb_samples,
           (const uint8_t **)decodedAudioFrame->data, decodedAudioFrame->nb_samples)) < 0){
                   syslog(LOG_ERR, "Error while converting\n");
                   exit(0);
           }*/

           //decodedAudioFrame->pts = audioPacket.pts;//(int64_t)((1.0 / (float)64000) * (float)90 * (float)packetCounter);

           ret = avcodec_encode_audio2(enc_ctx, &audioEncodedPacket, decodedAudioFrame, &got_packet);



           printf("Audio encoded packet size = %d, packet nb = %d, sample rate = %d Ret Value = %d\n", audioEncodedPacket.size, packetCounter, enc_ctx->sample_rate, ret);
           audioPacket.pts = (int64_t)((1.0 / (float)enc_ctx->sample_rate) * (float)90 * (float)packetCounter);
           audioPacket.dts = audioPacket.pts-1;

           ret = write_frame(ofmt_ctx, &enc_ctx->time_base, streamAudio, &audioEncodedPacket);

           av_free_packet(&audioEncodedPacket);

           ssize_t readVal = read(0, &videoAudioThreadExit, 1); // read non-blocking

       }while(videoAudioThreadExit != 'q');

       syslog(LOG_INFO ,"End Audio Thread\n");
       return NULL;
    }






    int main(int argc, char** argv){
       int i=0;

       openlog ("TEST", LOG_CONS | LOG_PERROR | LOG_NDELAY, LOG_USER);
       syslog (LOG_INFO, "Syslog correctly loaded.\n");
       syslog (LOG_INFO, "Program started by user UID %d\n", getuid ());

       av_register_all();
       avdevice_register_all();
       avcodec_register_all();
       avfilter_register_all();

       printf("\n\n\t START GLOBAL INIT\n");
       initAudio();

       pthread_create(&t[0], &ctrl[0], (void*)audioThread, NULL);
       for(i=0;icode>
  • Saying Goodbye To Old Machines

    1er décembre 2014, par Multimedia Mike — General, powerpc, via

    I recently sent a few old machines off for recycling. Both had relevance to the early days of the FATE testing effort. As is my custom, I photographed them (poorly, of course).

    First, there’s the PowerPC-based Mac Mini I procured thanks to a Craigslist ad in late 2006. I had plans to develop automated FFmpeg building and testing and was already looking ahead toward testing multiple CPU architectures. Again, this was 2006 and PowerPC wasn’t completely on the outs yet– although Apple’s MacTel transition was in full swing, the entire new generation of video game consoles was based on PowerPC.


    PPC Mac Mini pieces

    Click for larger image


    I remember trying to find a Mac Mini PPC on Craigslist. Many were to be found, but all asked more than the price of even a new Mac Mini Intel, always because the seller was leaving all of last year’s applications and perhaps including a monitor, neither of which I needed. Fortunately, I found this bare Mac Mini. Also fortunate was the fact that it was far easier to install Linux on it than the first PowerPC machine I owned.

    After FATE operation transitioned away from me, I still kept the machine in service as an edge server and automated backup machine. That is, until the hard drive failed on reboot one day. Thus, when it was finally time to recycle the computer, I felt it necessary to disassemble the machine and remove the hard drive for possible salvage and then for destruction.

    If you’ve ever attempted to upgrade or otherwise service this style of Mac Mini, you will no doubt recognize the pictured paint scraper tool as standard kit. I have had that tool since I first endeavored to upgrade the RAM to 1 GB from the standard 1/2 GB. Performing such activities on a Mac Mini is tedious, but only if you care about putting it back together afterwards.

    The next machine is a bit older. I put it together nearly a decade ago, early in 2005. This machine’s original duty was “download agent”– this would be more specifically called a BitTorrent machine in modern tech parlance. Back then, I placed it on someone else’s woefully underutilized home broadband connection (with their permission, of course) when I was too cheap to upgrade from dialup.


    VIA small form factor front

    Click for larger image


    This is a small form factor system from VIA that was clearly designed with home theater PC (HTPC) use cases in mind. It has a VIA C3 x86-compatible CPU (according to my notes, Centaur VIA Samuel 2 stepping 03, flags : fpu de tsc msr cx8 mtrr pge mmx 3dnow) and 128 MB of RAM (initially ; I upgraded it to 512 MB some years later, just for the sake of doing it). And then there was the 120 GB PATA HD for all that downloaded goodness.


    VIA machine small form factor inside

    Click for larger image


    I have specific memories of a time when my main computer at home wasn’t working correctly for one reason or another. Instead, I logged into this machine remotely via SSH to make several optimizations and fixes on FFmpeg’s VP3/Theora video decoder, all from the terminal, without being able to see the decoded images with my own eyes (which is why I insist that even blind people could work on video codecs).

    By the time I got my own broadband, I had become inspired to attempt the automated build and test system for FFmpeg. This was the machine I used for prototyping early brainstorms of FATE. By the time I put a basic build/test system into place in early 2008, I had much faster computers that could build and test the project– obvious limitation of this machine is that it could take at least 1/2 hour to build the entire codebase, and that was the project from 8 years ago.

    So the machine got stuffed in a closet somewhere along the line. The next time I pulled it out was in 2010 when I wanted to toy with Dreamcast programming once more (the machine appears in one of the photos in this post). This was the only machine I still owned which still had an RS-232 serial port (I didn’t know much about USB serial converters yet), plus it still had a bunch of pre-compiled DC homebrew binaries (I was having trouble getting the toolchain to work right).

    The next time I dusted off this machine was late last year when I was trying some experiments with the Microsoft Xbox’s IDE drive (a photo in that post also shows the machine ; this thing shows up a lot on this blog). The VIA machine was the only machine I still owned which had 40-pin IDE connectors which was crucial to my experiment.

    At this point, I was trying to make the machine more useful which meant replacing the ancient Gentoo Linux distribution as well as simply interacting with it via a keyboard and mouse. I have a long Evernote entry documenting a comedy of errors revolving around this little box. The interaction troubles were due to the fact that I didn’t have any PS/2 keyboards left and I couldn’t make a USB keyboard work with it. Diego was able to explain that I needed to flip a bit in the BIOS to address this which worked. As for upgrading the OS, I tried numerous Linux distributions large and small, mostly focusing on the small. None worked. I eventually learned that, while I was trying to use i686 distributions, this machine did not actually qualify as an i686 CPU ; installations usually booted but failed because the default kernel required the cmov instruction. I was advised to try i386 distros instead. My notes don’t indicate whether I had any luck on this front before I gave up and moved on.

    I just made the connection that this VIA machine has two 40-pin IDE connectors which means that the thing was technically capable of supporting up to 4 IDE devices. Obviously, the computer couldn’t really accommodate that in terms of space or power. When I wanted to try installing a new OS, I needed take off the top and connect a rather bulky IDE CD-ROM drive. This computer’s casing was supposed to be able to support a slimline optical drive (perhaps like the type found in laptops), but I could never quite visualize how that was supposed to work, space-wise. When I disassembled the PowerPC Mac Mini, I realized I might be able to repurpose that machines optical drive for this computer. Obviously, I thought better of trying since both machines are off to the recycle pile.

    I would still like to work on the Xbox project a bit more, but I procured a different, unused, much more powerful yet still old computer that has a motherboard with 1 PATA connector in addition to 6 SATA connectors. If I ever get around to toying with Linux kernel development, this should be a much more appropriate platform to use.

    I thought about turning this machine into an old Windows XP (and lower, down to Windows 3.1) gaming platform ; the capabilities of the machine would probably be perfect for a huge portion of my Windows game collection. But I think the lack of an optical drive renders this idea intractable. External USB drives are likely out of the question since there is very little chance that this motherboard featured USB 2.0 (the specs don’t mention 2.0, so the USB ports are probably 1.1).

    So it is with fond memories that I send off both machines, sans hard drives, to the recycle pile. I’m still deciding on an appropriate course of action for failed hard drives, though.