Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (46)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (8965)

  • FFmpeg encoding live audio to aac issue

    12 juillet 2015, par Ruurd Adema

    I’m trying to encode live raw audio coming from a Blackmagic Decklink input card to a mov file with AAC encoding.

    The issue is that the audio sounds distorted and plays to fast.

    I created the software based on a couple of examples/tutorials including the Dranger tutorial and examples on Github (and of course the examples in the FFmpeg codebase).

    Honestly, at this moment I don’t exactly know what the cause of the problem is. I’m thinking about PTS/DTS values or a timebase mismatch (because of the too fast playout), I tried a lot of things, including working with an av_audio_fifo.

    • When outputting to the mov file with the AV_CODEC_ID_PCM_S16LE codec, everything works well
    • When outputting to the mov file with the AV_CODEC_ID_AAC codec, the problems occur
    • When writing RAW audio VLC media info shows :
      Type : Audio, Codec : PCM S16 LE (sowt), Language : English, Channels : Stereo, Sample rate : 48000 Hz, Bits per sample.
    • When writing with AAC codec VLC media info shows :
      Type : Audio, Codec : MPEG AAC Audio (mp4a), Language : English, Channels : Stereo, Sample rate : 48000 Hz.

    Any idea(s) of what’s causing the problems ?

    Code

    // Create output context

    output_filename = "/root/movies/encoder_debug.mov";
    output_format_name = "mov";
    if (avformat_alloc_output_context2(&output_fmt_ctx, NULL, output_format_name, output_filename) < 0)
    {
       printf("[ERROR] Unable to allocate output format context for output: %s\n", output_filename);
    }

    // Create audio output stream

    static AVStream *encoder_add_audio_stream(AVFormatContext *oc, enum AVCodecID codec_id)
    {
       AVCodecContext  *c;
       AVCodec         *codec;
       AVStream        *st;

       st = avformat_new_stream(oc, NULL);
       if (!st)
       {
           printf("[ERROR] Could not allocate new audio stream!\n");
           exit(-1);
       }

       c                 = st->codec;
       c->codec_id       = codec_id;
       c->codec_type     = AVMEDIA_TYPE_AUDIO;
       c->sample_fmt     = AV_SAMPLE_FMT_S16;
       c->sample_rate    = decklink_config()->audio_samplerate;
       c->channels       = decklink_config()->audio_channel_count;
       c->channel_layout = av_get_default_channel_layout(decklink_config()->audio_channel_count);
       c->time_base.den  = decklink_config()->audio_samplerate;
       c->time_base.num  = 1;

       if (codec_id == AV_CODEC_ID_AAC)
       {
           c->bit_rate       = 96000;  
           //c->profile = FF_PROFILE_AAC_MAIN; //FIXME Generates error: "Unable to set the AOT 1: Invalid config"
           // Allow the use of the experimental AAC encoder
           c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
       }

       // Some formats want stream headers to be seperate (global?)
       if (oc->oformat->flags & AVFMT_GLOBALHEADER)
       {
           c->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }

       codec = avcodec_find_encoder(c->codec_id);
       if (!codec)
       {
           printf("[ERROR] Audio codec not found\n");
           exit(-1);
       }

       if (avcodec_open2(c, codec, NULL) < 0)
       {
           printf("[ERROR] Could not open audio codec\n");
           exit(-1);
       }

       return st;
    }

    // En then, at every incoming frame this function gets called:

    void encoder_handle_incoming_frame(IDeckLinkVideoInputFrame *videoframe, IDeckLinkAudioInputPacket *audiopacket)
    {
       void *pixels = NULL;
       int   pitch = 0;
       int got_packet = 0;

       void *audiopacket_data          = NULL;
       long  audiopacket_sample_count  = 0;
       long  audiopacket_size          = 0;
       long  audiopacket_channel_count = 2;

       if (audiopacket)
       {  
           AVPacket pkt = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
           AVFrame *frame;
           BMDTimeValue audio_pts;
           int requested_size;
           static int last_pts1, last_pts2 = 0;

           audiopacket_sample_count  = audiopacket->GetSampleFrameCount();
           audiopacket_channel_count = decklink_config()->audio_channel_count;
           audiopacket_size          = audiopacket_sample_count * (decklink_config()->audio_sampletype/8) * audiopacket_channel_count;

           audiopacket->GetBytes(&audiopacket_data);

           av_init_packet(&pkt);    

           printf("\n=== Audiopacket: %d ===\n", audio_stream->codec->frame_number);

           if (AUDIO_TYPE == AV_CODEC_ID_PCM_S16LE)
           {
               audiopacket->GetPacketTime(&audio_pts, audio_stream->time_base.den);

               pkt.pts          = audio_pts;
               pkt.dts          = pkt.pts;
               pkt.flags       |= AV_PKT_FLAG_KEY;                 // TODO: Make sure if this still applies
               pkt.stream_index = audio_stream->index;
               pkt.data         = (uint8_t *)audiopacket_data;
               pkt.size         = audiopacket_size;

               printf("[PACKET] size:              %d\n", pkt.size);
               printf("[PACKET] pts:               %li\n", pkt.pts);
               printf("[PACKET] pts delta:         %li\n", pkt.pts - last_pts2);
               printf("[PACKET] duration:          %d\n", pkt.duration);
               last_pts2 = pkt.pts;

               av_interleaved_write_frame(output_fmt_ctx, &pkt);
           }
           else if (AUDIO_TYPE == AV_CODEC_ID_AAC)
           {
               frame = av_frame_alloc();
               frame->format = audio_stream->codec->sample_fmt;
               frame->channel_layout = audio_stream->codec->channel_layout;
               frame->sample_rate = audio_stream->codec->sample_rate;
               frame->nb_samples = audiopacket_sample_count;

               requested_size = av_samples_get_buffer_size(NULL, audio_stream->codec->channels, audio_stream->codec->frame_size, audio_stream->codec->sample_fmt, 1);

               audiopacket->GetPacketTime(&audio_pts, audio_stream->time_base.den);

               printf("[DEBUG] Sample format:      %d\n", frame->format);
               printf("[DEBUG] Channel layout:     %li\n", frame->channel_layout);
               printf("[DEBUG] Sample rate:        %d\n", frame->sample_rate);
               printf("[DEBUG] NB Samples:         %d\n", frame->nb_samples);
               printf("[DEBUG] Datasize:           %li\n", audiopacket_size);
               printf("[DEBUG] Requested datasize: %d\n", requested_size);
               printf("[DEBUG] Too less/much:      %li\n", audiopacket_size - requested_size);
               printf("[DEBUG] Framesize:          %d\n", audio_stream->codec->frame_size);
               printf("[DEBUG] Audio pts:          %li\n", audio_pts);
               printf("[DEBUG] Audio pts delta:    %li\n", audio_pts - last_pts1);
               last_pts1 = audio_pts;

               frame->pts = audio_pts;

               if (avcodec_fill_audio_frame(frame, audiopacket_channel_count, audio_stream->codec->sample_fmt, (const uint8_t *)audiopacket_data, audiopacket_size, 0) < 0)
               {
                   printf("[ERROR] Filling audioframe failed!\n");
                   exit(-1);
               }

               got_packet = 0;
               if (avcodec_encode_audio2(audio_stream->codec, &pkt, frame, &got_packet) != 0)
               {
                   printf("[ERROR] Encoding audio failed\n");
               }

               if (got_packet)
               {
                   pkt.stream_index = audio_stream->index;
                   pkt.flags       |= AV_PKT_FLAG_KEY;

                   //printf("[PACKET] size:              %d\n", pkt.size);
                   //printf("[PACKET] pts:               %li\n", pkt.pts);
                   //printf("[PACKET] pts delta:         %li\n", pkt.pts - last_pts2);
                   //printf("[PACKET] duration:          %d\n", pkt.duration);
                   //printf("[PACKET] timebase codec:    %d/%d\n", audio_stream->codec->time_base.num, audio_stream->codec->time_base.den);
                   //printf("[PACKET] timebase stream:   %d/%d\n", audio_stream->time_base.num, audio_stream->time_base.den);
                   last_pts2 = pkt.pts;

                   av_interleaved_write_frame(output_fmt_ctx, &pkt);
               }
               av_frame_free(&frame);
           }

           av_free_packet(&pkt);
       }
       else
       {
           printf("[WARNING] No audiopacket received!\n");
       }

       static int count = 0;
       count++;
    }
  • ffmpeg, video Conversion

    7 novembre 2012, par user1805414

    I have 2 video.
    Metadata files :

    Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 30.00 (30/1)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '89.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 0
       compatible_brands: mp41isom
       creation_time   : 2012-10-23 08:10:51
     Duration: 00:00:08.96, start: 0.000000, bitrate: 2017 kb/s
       Stream #0.0(eng): Video: h264 (Baseline), yuv420p, 640x480, 2006 kb/s, 28.53 fps, 30 tbr, 1k tbn, 2k tbc
       Metadata:
         creation_time   : 2012-10-23 08:10:51
       Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 48 kb/s
       Metadata:
         creation_time   : 2012-10-23 08:10:51
    At least one output file must be specified.
    //--------------------------------------------------------------------------------------------------------------//
    Seems stream 1 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '56_1.mp4':
     Metadata:
       major_brand     : 3gp4
       minor_version   : 0
       compatible_brands: isom3gp4
       creation_time   : 1946-11-02 07:14:31
     Duration: 00:00:05.23, start: 0.000000, bitrate: 239 kb/s
       Stream #0.0(eng): Audio: amrnb, 8000 Hz, 1 channels, flt, 5 kb/s
       Metadata:
         creation_time   : 1946-11-02 07:14:31
       Stream #0.1(eng): Video: h264 (Baseline), yuv420p, 480x320, 240 kb/s, PAR 65536:65536 DAR 3:2, 17.63 fps, 90k tbr, 90k tbn, 180k tbc
       Metadata:
         creation_time   : 1946-11-02 07:14:31
    At least one output file must be specified.

    They do not play on my website.
    How to bring them to a form ?

    Seems stream 0 codec frame rate differs from container frame rate: 47.95 (5994/125) -> 23.98 (24000/1001)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'oceans-clip.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 1
       compatible_brands: isomavc1
       creation_time   : 2010-05-18 04:24:00
     Duration: 00:00:46.54, start: 0.000000, bitrate: 3342 kb/s
       Stream #0.0(und): Video: h264 (Constrained Baseline), yuv420p, 640x264 [PAR 132:133 DAR 320:133], 3195 kb/s, PAR 127:128 DAR 635:264, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
       Metadata:
         creation_time   : 2010-05-18 04:24:00
       Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 144 kb/s
       Metadata:
         creation_time   : 2010-05-18 04:24:01
    At least one output file must be specified

    I get the video to android and vinfone devices, and must play it on your site, but the player does not want to play. Metadata files that I get see the beginnings. The latter belongs to the metadata file that correctly reproduced on the site.

  • accurate cutting of video (+ audio) with ffmpeg [migrated]

    4 novembre 2012, par Pete Oakey

    I want my website to allow users to accurately create their own clips from a source video I provide.

    I have a source video file that I first want to convert to something suitable for a website :

    Input #0, matroska,webm, from 'source.mkv':
    Duration: 00:28:18.57, start: 0.000000, bitrate: 10183 kb/s
    Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 48 tbc (default)
    Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s (default)

    So I use ffmpeg to convert it like so :

    ffmpeg -i source.mkv -c:v libx264 -c:a aac -strict experimental -vf scale="960:-1" source.mp4

    Watching this video back it is good enough quality and small enough file size for my needs, and loads/plays on my website.

    So I have a webpage that lets users select a start and endpoint on this video - and create a clip. Here's an example of the ffmpeg command that I use for that :

    -ss 577.920 -i source.mp4 -t 011.980 -codec:v copy -codec:a copy -vf scale="960:-1" clip1.mp4

    The problem is the clip is not always time-accurate enough. Usually the audio is accurate enough but the video stops half a second early or something.

    Is there any way to make this accurate and in-sync to say, 0.2 of a second ?

    EDIT :
    Adding -force_key_frames 00:00:00.2 didn't help.