Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (111)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (5381)

  • How to concat mp4 files using libffmpeg in c program ?

    1er août 2013, par chichien

    I know ffmpeg command line is easy, but how to programmatically implement? I'm not good at this,here is some code from internet, it is used to convert .mp4 to .ts,and i made some changes,but the audio stream problem persists:

    #include
    #include
    #include
    #include

    #include "libavformat/avformat.h"
    #include "libavcodec/avcodec.h"
    #include "libavutil/avutil.h"
    #include "libavutil/rational.h"
    #include "libavdevice/avdevice.h"
    #include "libavutil/mathematics.h"
    #include "libswscale/swscale.h"

    static AVStream* add_output_stream(AVFormatContext* output_format_context, AVStream* input_stream)
    {

       AVCodecContext* input_codec_context = NULL;
       AVCodecContext* output_codec_context = NULL;

       AVStream* output_stream = NULL;
       output_stream = av_new_stream(output_format_context, 0);
       if (!output_stream)
       {
           printf("Call av_new_stream function failed\n");
           return NULL;
       }

       input_codec_context = input_stream->codec;
       output_codec_context = output_stream->codec;

       output_codec_context->codec_id = input_codec_context->codec_id;
       output_codec_context->codec_type = input_codec_context->codec_type;
       output_codec_context->codec_tag = input_codec_context->codec_tag;
       output_codec_context->bit_rate = input_codec_context->bit_rate;
       output_codec_context->extradata = input_codec_context->extradata;
       output_codec_context->extradata_size = input_codec_context->extradata_size;

       if (av_q2d(input_codec_context->time_base) * input_codec_context->ticks_per_frame > av_q2d(input_stream->time_base) && av_q2d(input_stream->time_base) < 1.0 / 1000)
       {
           output_codec_context->time_base = input_codec_context->time_base;
           output_codec_context->time_base.num *= input_codec_context->ticks_per_frame;
       }
       else
       {
           output_codec_context->time_base = input_stream->time_base;
       }
       switch (input_codec_context->codec_type)
       {
       case AVMEDIA_TYPE_AUDIO:
           output_codec_context->channel_layout = input_codec_context->channel_layout;
           output_codec_context->sample_rate = input_codec_context->sample_rate;
           output_codec_context->channels = input_codec_context->channels;
           output_codec_context->frame_size = input_codec_context->frame_size;
           if ((input_codec_context->block_align == 1 && input_codec_context->codec_id == CODEC_ID_MP3) || input_codec_context->codec_id == CODEC_ID_AC3)
           {
               output_codec_context->block_align = 0;
           }
           else
           {
               output_codec_context->block_align = input_codec_context->block_align;
           }
           break;
       case AVMEDIA_TYPE_VIDEO:
           output_codec_context->pix_fmt = input_codec_context->pix_fmt;
           output_codec_context->width = input_codec_context->width;
           output_codec_context->height = input_codec_context->height;
           output_codec_context->has_b_frames = input_codec_context->has_b_frames;
           if (output_format_context->oformat->flags & AVFMT_GLOBALHEADER)
           {
               output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
           }
           break;
       default:
           break;
       }

       return output_stream;
    }

    //[[** from ffmpeg.c
    static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
       int ret;

       while(bsfc){
           AVPacket new_pkt= *pkt;
           int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
                                             &new_pkt.data, &new_pkt.size,
                                             pkt->data, pkt->size,
                                             pkt->flags & AV_PKT_FLAG_KEY);
           if(a>0){
               av_free_packet(pkt);
               new_pkt.destruct= av_destruct_packet;
           } else if(a<0){
               fprintf(stderr, "%s failed for stream %d, codec %s\n",
                       bsfc->filter->name, pkt->stream_index,
                       avctx->codec ? avctx->codec->name : "copy");
               //print_error("", a);
               //if (exit_on_error)
               //    ffmpeg_exit(1);
           }
           *pkt= new_pkt;

           bsfc= bsfc->next;
       }

       ret= av_interleaved_write_frame(s, pkt);
       if(ret < 0){
           //print_error("av_interleaved_write_frame()", ret);
           fprintf(stderr, "av_interleaved_write_frame(%d)\n", ret);
           exit(1);
       }
    }
    //]]**

    int main(int argc, char* argv[])
    {

       const char* input;
       const char* output;
       const char* output_prefix = NULL;
       char* segment_duration_check = 0;
       const char* index = NULL;
       char* tmp_index = NULL;
       const char* http_prefix = NULL;
       long max_tsfiles = NULL;
       double prev_segment_time = 0;
       double segment_duration = 0;

       AVInputFormat* ifmt = NULL;
       AVOutputFormat* ofmt = NULL;
       AVFormatContext* ic = NULL;
       AVFormatContext* oc = NULL;
       AVStream* video_st = NULL;
       AVStream* audio_st = NULL;
       AVCodec* codec = NULL;
       AVDictionary* pAVDictionary = NULL;

       long frame_count = 0;

       if (argc != 3) {
           fprintf(stderr, "Usage: %s inputfile outputfile\n", argv[0]);
           exit(1);
       }

       input = argv[1];
       output = argv[2];

       av_register_all();

       char szError[256] = {0};
       int nRet = avformat_open_input(&ic, input, ifmt, &pAVDictionary);
       if (nRet != 0)
       {
           av_strerror(nRet, szError, 256);
           printf(szError);
           printf("\n");
           printf("Call avformat_open_input function failed!\n");
           return 0;
       }

       if (av_find_stream_info(ic) < 0)
       {
           printf("Call av_find_stream_info function failed!\n");
           return 0;
       }

       ofmt = av_guess_format("mpegts", NULL, NULL);
       if (!ofmt)
       {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }

       oc = avformat_alloc_context();
       if (!oc)
       {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }
       oc->oformat = ofmt;

       int video_index = -1, audio_index = -1;
       for (unsigned int i = 0; i < ic->nb_streams && (video_index < 0 || audio_index < 0); i++)
       {
           switch (ic->streams[i]->codec->codec_type)
           {
           case AVMEDIA_TYPE_VIDEO:
               video_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               video_st = add_output_stream(oc, ic->streams[i]);
               break;
           case AVMEDIA_TYPE_AUDIO:
               audio_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               audio_st = add_output_stream(oc, ic->streams[i]);
               break;
           default:
               ic->streams[i]->discard = AVDISCARD_ALL;
               break;
           }
       }
       codec = avcodec_find_decoder(video_st->codec->codec_id);
       if (codec == NULL)
       {
           printf("Call avcodec_find_decoder function failed!\n");
           return 0;
       }

       if (avcodec_open(video_st->codec, codec) < 0)
       {
           printf("Call avcodec_open function failed !\n");
           return 0;
       }

       if (avio_open(&oc->pb, output, AVIO_FLAG_WRITE) < 0)
       {
           return 0;
       }

       if (avformat_write_header(oc, &pAVDictionary))
       {
           printf("Call avformat_write_header function failed.\n");
           return 0;
       }

       //[[++
       AVBitStreamFilterContext *bsfc = av_bitstream_filter_init("h264_mp4toannexb");
       //AVBitStreamFilterContext *absfc = av_bitstream_filter_init("aac_adtstoasc");
       if (!bsfc) {
           fprintf(stderr, "bsf init error!\n");
           return -1;
       }
       //]]++

       int decode_done = 0;
       do
       {
           double segment_time = 0;
           AVPacket packet;

           decode_done = av_read_frame(ic, &packet);
           if (decode_done < 0)
               break;

           if (av_dup_packet(&packet) < 0)
           {
               printf("Call av_dup_packet function failed\n");
               av_free_packet(&packet);
               break;
           }

           //[[**
           if (packet.stream_index == audio_index) {
               segment_time = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
               nRet = av_interleaved_write_frame(oc, &packet);  
           } else if (packet.stream_index == video_index) {
               if (packet.flags & AV_PKT_FLAG_KEY) {
                   segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
               } else {
                   segment_time = prev_segment_time;
               }
               //nRet = av_interleaved_write_frame(oc, &packet);  
               write_frame(oc, &packet, video_st->codec, bsfc);
           }
           //]]**

           if (nRet < 0)
           {
               printf("Call av_interleaved_write_frame function failed: %d\n", nRet);
           }
           else if (nRet > 0)
           {
               printf("End of stream requested\n");
               av_free_packet(&packet);
               break;
           }
           av_free_packet(&packet);
           frame_count++;
       }while(!decode_done);

       av_write_trailer(oc);
       printf("frame_count = %d\n", frame_count);

       av_bitstream_filter_close(bsfc);  
       avcodec_close(video_st->codec);
       for(unsigned int k = 0; k < oc->nb_streams; k++)
       {
           av_freep(&oc->streams[k]->codec);
           av_freep(&oc->streams[k]);
       }
       av_free(oc);
       //getchar();
       return 0;
    }

    Compile this code, to got an executable file named muxts, and then :

    $ ./muxts vid1.mp4 vid1.ts

    No error message printed,but the audio stream was unsynchronized and noise。Check the .ts file using ffmpeg :

    $ ffmpeg -i vid1.ts
    ffmpeg version 0.8.14-tessus, Copyright (c) 2000-2013 the FFmpeg developers
     built on Jul 29 2013 17:05:18 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
     configuration: --prefix=/usr/local --arch=x86_64 --as=yasm --extra-version=tessus --enable-gpl --enable-nonfree --enable-version3 --disable-ffplay --enable-libvorbis --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-bzlib --enable-zlib --enable-postproc --enable-filters --enable-runtime-cpudetect --enable-debug=3 --disable-optimizations
     libavutil    51.  9. 1 / 51.  9. 1
     libavcodec   53.  8. 0 / 53.  8. 0
     libavformat  53.  5. 0 / 53.  5. 0
     libavdevice  53.  1. 1 / 53.  1. 1
     libavfilter   2. 23. 0 /  2. 23. 0
     libswscale    2.  0. 0 /  2.  0. 0
     libpostproc  51.  2. 0 / 51.  2. 0

    Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
    Input #0, mpegts, from 'vid1.ts':
     Duration: 00:00:03.75, start: 0.000000, bitrate: 3656 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0.0[0x100]: Video: h264 (Baseline), yuv420p, 640x480, 90k tbr, 90k tbn, 180k tbc
       Stream #0.1[0x101]: Audio: aac, 48000 Hz, mono, s16, 190 kb/s
    At least one output file must be specified

    What should i do ?

    If this issue fixed , how can i concat multi .ts files into single .mp4 file ?

  • How can i capture video from a usb camera using c program

    13 août 2013, par Asif

    I'm trying to write an API to record a video from my usb camera.I tried using v4l2,ffmpeg but i can only capture images using those codes.I googled out full to find a v4l2 sample code from the link http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html i'm not able to run.if i run the code it just displays junk values it the screen then i have to break it manually.if i run it i'm not able to record any video.Can any one suggest me a sample code to record a video from an usb camera in c program.
    Thank you...

  • Methods For Retaining State

    26 décembre 2011, par Multimedia Mike — General, evernote, organization

    I jump around between projects. A lot. Over the years, I have employed various methods for retaining state or context as I switch to a different project. Here’s a quick survey and a general classification of their effectiveness.

    Good

    • Evernote : This is a cloud-based note-taking service that has a web client, Mac and Windows clients, and clients for just about ever mobile platform out there. I have an account and access it via the web interface as as the Windows, iOS, and Android clients. I really like it.


    Okay

    • Series of text files : I have been doing this for a very long time. I have many little note-filled directories here and there that are consistently migrated to new machines but generally forgotten about. This isn’t a terrible method but can be unwieldy when you work on lots of different machines. I’m still tracking down all these directories and importing them into Evernote.

    Bad

    • Layout of desktop windows : I have a habit of working on one project in a set of windows on one desktop space and another project in a second set of windows in another space, etc. Oh, this makes me shudder just thinking about it, mostly because of living in constant fear of a power failure or some other inadvertent reset (darn you, default config’d Windows Update) that wipes the state clean (sure, all of the work might have been saved, but I was relying on those windows to be set up in just the right manner to remind me of all the things I was working on). These days, I force myself to reboot at least once a week so I can’t get too deep into this habit. When it’s time to change projects, I write up exactly what I was doing and where I left off and stick it in Evernote.
    • Open browser windows : I guess it’s common to have many, many tabs open in one’s web browser in this day and age. Like many, I use open tabs as a stack of items to read. The state problem comes when a few of the open tabs represent TODO items. Then I start living in fear that the browser might crash or be restarted in an unexpected way and I struggle to recall what 3-5 important TODO items were that I had opened in separate tabs (on top of a stack of less important items). Again, I try to shut down the browser frequently in order to break this tendency. TODO items are better filed in Evernote.
    • Unsaved data in a text editor : Okay, this is just sloppy on my part, shoving temporary data into a text editor window thinking it’s supremely ephemeral. The problem comes when it’s linked to one of the many tasks on my desktop that might be bumped down a few priority levels ; when finally returning to the context-free data, I’m at a loss to explain what it’s for. Evernote gets it, once more, with a more thorough description of what was going on.
    • Email inbox : I make an effort to ensure that my email inbox has the fewest number of messages possible. Once things are dealt with, they get filed away elsewhere. This implies that things in my inbox require action. Some things have a habit of hanging around, though. Longer items now get described in better detail and filed away in Evernote.
    • Classic paper : Thanks to Derek in the comments for reminding me of this one. Paper is a reliable standby but it can get unwieldy when Post-It Notes litter your work area. Further, it can be problematic when you have multiple physical work areas.
    • Shell history : Another method I rely on entirely too often. This is when I count on a recipe of command line incantations living on in the history buffer of my Unix shell (generally Bash). What sequence of git commands allowed me to do XYZ ? Let’s check the shell history– I sure hope it’s still in there.

    Conclusion
    I guess what I’m trying to say here is that I really like Evernote. If you have similar troubles with retaining state, try it out. I hear there are many other services similar to it with slightly varying feature sets (people rave about Microsoft OneNote). So there are plenty of options and something out there is surely a fit.

    Evernote has a free tier and a premium tier. For my meager note-taking needs, I don’t come anywhere close to the free tier’s limit but I decided to pay for a premium subscription simply because I feel like I derive so much value from the service.

    One downside, however, is that I seem to be doing a lot less blogging since I got on Evernote earlier this year (though it is where I author most of these posts nowadays ; I especially like that I have a notebook labeled “Posted” whose incrementing count reminds me that I am getting some stuff out there). I originally started this blog as a sort of technical journal in order to organize notes and projects in a central location. It’s strange to think that if Evernote existed in 2005, I might never have had a reason to start this blog.