Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (12)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

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

Sur d’autres sites (3546)

  • Android : How to play MP3 files with ID3 tags using FFMPEG

    16 juillet 2012, par Vipul Purohit

    I am trying to play various sound files using FFMPEG lib in android. I have managed to play most files but some file Example : MP3 files with ID3 tag are not playing. I tried playing files by taking reference of various example but didn't get any success.

    Here is my native side code :

    #include
    #include
    #include
    #include <android></android>log.h>

    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"

    #define LOG_TAG "mylib"
    #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
    #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)

    #define AUDIO_INBUF_SIZE 20480
    #define AUDIO_REFILL_THRESH 4096

    void Java_ru_dzakhov_ffmpeg_test_MainActivity_createEngine(JNIEnv* env, jclass clazz)
       {
           avcodec_init();

           av_register_all();


       }

       jstring Java_ru_dzakhov_ffmpeg_test_MainActivity_loadFile(JNIEnv* env, jobject obj,jstring file,jbyteArray array)
       {
           {
                   jboolean            isfilenameCopy;
                   const char *        filename = (*env)->GetStringUTFChars(env, file, &amp;isfilenameCopy);
                   int audioStreamIndex;
                   AVCodec *codec;
                   AVCodecContext *c= NULL;
                   AVFormatContext * pFormatCtx;
                   AVCodecContext * aCodecCtx;
                   int out_size, len, audioStream=-1, i, err;
                   FILE *f, *outfile;
                   uint8_t *outbuf;
                   uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
                   AVPacket avpkt;
                   jclass              cls = (*env)->GetObjectClass(env, obj);
                   jmethodID           play = (*env)->GetMethodID(env, cls, "playSound", "([BI)V");//At the begining of your main function

                   LOGE("source file name is %s", filename);

                      avcodec_init();

                      av_register_all();

                      LOGE("Stage 1");
                      /* get format somthing of source file to AVFormatContext */
                      int lError;
                      if ((lError = av_open_input_file(&amp;pFormatCtx, filename, NULL, 0, NULL)) !=0 ) {
                          LOGE("Error open source file: %d", lError);
                          exit(1);
                      }
                      if ((lError = av_find_stream_info(pFormatCtx)) &lt; 0) {
                          LOGE("Error find stream information: %d", lError);
                          exit(1);
                      }
                      LOGE("Stage 1.5");
                      LOGE("audio format: %s", pFormatCtx->iformat->name);
                      LOGE("audio bitrate: %d", pFormatCtx->bit_rate);



                      audioStreamIndex = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &amp;codec, 0);

    //                 audioStreamIndex=-1;
    //                 LOGE("nb_stream %d", pFormatCtx->nb_streams);
    //                     for(i=0; inb_streams; i++)
    //                     {
    //                         LOGE("nb_stream %d", pFormatCtx->nb_streams);
    //                         if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
    //                         {
    //                             audioStream=i;
    //                             break;
    //                         }
    //                     }
    //
    //                     if(audioStream==-1)
    //                     {
    //                         LOGE("Cannot find audio");
    //                     }

                         LOGE("audioStreamIndex %d", audioStreamIndex);
    //                    if (audioStreamIndex == AVERROR_STREAM_NOT_FOUND) {
    //                        LOGE(1, "cannot find a audio stream");
    //                        exit(1);
    //                    } else if (audioStreamIndex == AVERROR_DECODER_NOT_FOUND) {
    //                        LOGE(1, "audio stream found, but no decoder is found!");
    //                        exit(1);
    //                    }
                         LOGE("audio codec: %s", codec->name);

                         /* get codec somthing of audio stream to AVCodecContext */
                         aCodecCtx = pFormatCtx->streams[audioStreamIndex]->codec;
                         if (avcodec_open(aCodecCtx, codec) &lt; 0) {
                         LOGE("cannot open the audio codec!");
                             exit(1);
                         }

                   printf("Audio decoding\n");
                   LOGE("Stage 1.7");
                   LOGE("S");
                   codec = avcodec_find_decoder(aCodecCtx->codec_id);
                   LOGE("Stage 1.8");
                   if (!codec) {
                       LOGE("codec not found\n");
                       exit(1);
                   }
                   LOGE("Stage 2");
    //              c= avcodec_alloc_context();
                   LOGE("Stage 3");
                   /* open it */
                   if (avcodec_open(aCodecCtx, codec) &lt; 0) {
                       LOGE("could upper");
                       fprintf(stderr, "could not open codec\n");
                       LOGE("could not open codec");

                   }
                   LOGE("Stage 4");
                   outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);

                   f = fopen(filename, "rb");
                   if (!f) {
                       fprintf(stderr, "could not open %s\n", filename);
                       LOGE("could not open");
                       exit(1);
                   }

                   /* decode until eof */
                   avpkt.data = inbuf;
                   avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f);
                   LOGE("Stage 5");


                   while (avpkt.size > 0) {
    //                  LOGE("Stage 6");
                       out_size = (AVCODEC_MAX_AUDIO_FRAME_SIZE/3)*2;
                       len = avcodec_decode_audio3(aCodecCtx, (int16_t *)outbuf, &amp;out_size, &amp;avpkt);
                       LOGE("data_size %d len %d", out_size, len);
                       if (len &lt; 0) {
                           fprintf(stderr, "Error while decoding\n");
                           LOGE("DECODING ERROR");
                           LOGE("DECODING ERROR %d", len);
                           exit(1);
                       }
    //                  LOGE("Stage 7");
                       if (out_size > 0) {
                           /* if a frame has been decoded, output it */
    //                      LOGE("Stage 8");
                           jbyte *bytes = (*env)->GetByteArrayElements(env, array, NULL);
                           memcpy(bytes, outbuf, out_size); //
                           (*env)->ReleaseByteArrayElements(env, array, bytes, 0);
                           (*env)->CallVoidMethod(env, obj, play, array, out_size);
    //                      LOGE("DECODING ERROR5");
                       }
                       LOGE("Stage 9");
                       avpkt.size -= len;
                       avpkt.data += len;
                       if (avpkt.size &lt; AUDIO_REFILL_THRESH) {
                           /* Refill the input buffer, to avoid trying to decode
                            * incomplete frames. Instead of this, one could also use
                            * a parser, or use a proper container format through
                            * libavformat. */
                           memmove(inbuf, avpkt.data, avpkt.size);
                           avpkt.data = inbuf;
                           len = fread(avpkt.data + avpkt.size, 1,
                                       AUDIO_INBUF_SIZE - avpkt.size, f);
                           if (len > 0)
                               avpkt.size += len;
                       }
                   }
                   LOGE("Stage 12");
                   fclose(f);
                   free(outbuf);

                   avcodec_close(c);
                   av_free(c);

           }
       }

    Sorry for a rough code but I am testing on this code.

    I found the reason that the mp3 file has ID3 info, but I don't handle this, all the ID3 info data is decode as frame data, so the right frame header sign 0xFFE00000 can't be found and the method "avcodec_decode_audio3" return -1.

    I found this in question mp3 decoding using ffmpeg API (Header missing)

    If anyone can help me handle and play file with ID3 tags in MP3 and similar for other formats.

  • Encoding for HLS using FFMPEG results in have a decreasing DTS

    29 décembre 2014, par Luuk D. Jansen

    I am trying to encode video for HTS live streaming, but am having problems with validating the stream using Apple Media Validator (mediastreamvalidator).
    (my test file : http://dominicansinteractive.idoms.org/media/9536/playlist.m3u8)

    The output is :

    --------------------------------------------------------------------------------
    http://dominicansinteractive.idoms.org/media/9536/199/prog_index.m3u8
    --------------------------------------------------------------------------------

    Playlist Validation:

       OK

    Segments:

    segment_00000.ts:

       ERROR: (-1) Decreasing DTS were detected in track 0
       ERROR: (-1) Decreasing DTS were detected in track 1

       Average segment duration: 8.07 seconds
       Average segment bitrate: 2155094.67 bps
       Average segment structural overhead: 206525.83 bps (9.58 %)

    The second segment doesn’t seem to have the problem :

    [mpegts @ 0x1d78120] Format mpegts probed with size=2048 and score=100
    [mpegts @ 0x1d78120] stream=0 stream_type=1b pid=100 prog_reg_desc=
    [mpegts @ 0x1d78120] stream=1 stream_type=f pid=101 prog_reg_desc=
    [mpegts @ 0x1d78120] File position before avformat_find_stream_info() is 0
    [h264 @ 0x1d7c1c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [h264 @ 0x1d7c1c0] no picture
    [h264 @ 0x1d7c1c0] Current profile doesn't provide more RBSP data in PPS, skipping
      Last message repeated 3 times
    [mpegts @ 0x1d78120] max_analyze_duration 5000000 reached at 5013333
    [mpegts @ 0x1d78120] File position after avformat_find_stream_info() is 0

    This seems to be a serious problem for HLS, so I am looking if there is a way to fix this.

    When looking with FFMPEG at the encoded file I get (encoder output/command at the bottom of the email) :

    ffmpeg -loglevel 99 -i encoded.ts
    ffmpeg version N-37783-gdf3a96c Copyright (c) 2000-2012 the FFmpeg developers
    built on Jul  4 2012 07:44:52 with gcc 4.4.5
    configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libvpx --enable-libfaac --enable-nonfree
    libavutil      51. 63.100 / 51. 63.100
    libavcodec     54. 32.100 / 54. 32.100
    libavformat    54. 14.100 / 54. 14.100
    libavdevice    54.  0.100 / 54.  0.100
    libavfilter     3.  0.101 /  3.  0.101
    libswscale      2.  1.100 /  2.  1.100
    libswresample   0. 15.100 /  0. 15.100
    libpostproc    52.  0.100 / 52.  0.100
    [mpegts @ 0x2023120] Format mpegts probed with size=2048 and score=100
    [mpegts @ 0x2023120] stream=0 stream_type=1b pid=100 prog_reg_desc=
    [mpegts @ 0x2023120] stream=1 stream_type=f pid=101 prog_reg_desc=
    [mpegts @ 0x2023120] File position before avformat_find_stream_info() is 0
    [h264 @ 0x20271c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [h264 @ 0x20271c0] no picture
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 143280 in que
      Last message repeated 6 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 158640 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 175920 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 193200 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 210480 in que
      Last message repeated 7 times
    [h264 @ 0x20271c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 227760 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 245040 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 262320 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 279600 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 296880 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 314160 in que
      Last message repeated 7 times
    [h264 @ 0x20271c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 331440 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 348720 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 366000 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 383280 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 400560 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 417840 in que
      Last message repeated 6 times
    [h264 @ 0x20271c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 433200 in que
      Last message repeated 6 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 448560 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 465840 in que
      Last message repeated 6 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 481200 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 498480 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 515760 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 533040 in que
      Last message repeated 6 times
    [h264 @ 0x20271c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [mpegts @ 0x2023120] first_dts 124080 not matching first dts 548400 in que
      Last message repeated 7 times
    [mpegts @ 0x2023120] max_analyze_duration 5000000 reached at 5000000
    [mpegts @ 0x2023120] File position after avformat_find_stream_info() is 0

    And when at the first segmented file:
    ffmpeg -loglevel 99 -i segment_00000.ts
    ffmpeg version N-37783-gdf3a96c Copyright (c) 2000-2012 the FFmpeg developers
    built on Jul  4 2012 07:44:52 with gcc 4.4.5
    configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libvpx --enable-libfaac --enable-nonfree
    libavutil      51. 63.100 / 51. 63.100
    libavcodec     54. 32.100 / 54. 32.100
    libavformat    54. 14.100 / 54. 14.100
    libavdevice    54.  0.100 / 54.  0.100
    libavfilter     3.  0.101 /  3.  0.101
    libswscale      2.  1.100 /  2.  1.100
    libswresample   0. 15.100 /  0. 15.100
    libpostproc    52.  0.100 / 52.  0.100
    [mpegts @ 0x1a0b120] Format mpegts probed with size=2048 and score=100
    [mpegts @ 0x1a0b120] stream=0 stream_type=1b pid=100 prog_reg_desc=
    [mpegts @ 0x1a0b120] stream=1 stream_type=f pid=101 prog_reg_desc=
    [mpegts @ 0x1a0b120] File position before avformat_find_stream_info() is 0
    [mpegts @ 0x1a0b120] Invalid timestamps stream=0, pts=1920, dts=8589929312, size=2355
    [mpegts @ 0x1a0b120] Invalid timestamps stream=0, pts=16320, dts=8589932912, size=3203
    [h264 @ 0x1a0f1c0] Current profile doesn't provide more RBSP data in PPS, skipping
    [h264 @ 0x1a0f1c0] no picture
    [h264 @ 0x1a0f1c0] Current profile doesn't provide more RBSP data in PPS, skipping
      Last message repeated 3 times
    [mpegts @ 0x1a0b120] max_analyze_duration 5000000 reached at 5013333
    [mpegts @ 0x1a0b120] File position after avformat_find_stream_info() is 0

    This problem does not occur with the BASELINE profile, but does with MAIN.

    The command I use for encoding is :

    ffmpeg, -i, [path]/test.mov, -y, -f, mpegts, -acodec, aac, -strict, -2, -ar, 48000, -b:a, 128000, -s, 960x540, -vcodec, libx264, -b:v, 1200000, -aspect, 960:540, -r, 25, -level, 3.1, -vprofile, main, -flags, +loop, -cmp, +chroma, -partitions, +parti4x4+partp8x8+partb8x8, -subq, 5, -trellis, 1, -refs, 1, -coder, 0, -me_range, 16, -keyint_min, 25, -sc_threshold, 40, -i_qfactor, 0.71, -bt, 200k, -maxrate, 1200000, -bufsize, 1200000, -rc_eq, 'blurCplx^(1-qComp)', -qcomp, 0.6, -qmin, 10, -qmax, 51, -qdiff, 4, -level, 30, -g, 30, -async, 2, [path]/encoded.ts

    08:40:29,843 DEBUG ~ FFMPEG(1):   libavutil      51. 63.100 / 51. 63.100
    08:40:29,843 DEBUG ~ FFMPEG(1):   libavcodec     54. 32.100 / 54. 32.100
    08:40:29,843 DEBUG ~ FFMPEG(1):   libavformat    54. 14.100 / 54. 14.100
    08:40:29,843 DEBUG ~ FFMPEG(1):   libavdevice    54.  0.100 / 54.  0.100
    08:40:29,843 DEBUG ~ FFMPEG(1):   libavfilter     3.  0.101 /  3.  0.101
    08:40:29,844 DEBUG ~ FFMPEG(1):   libswscale      2.  1.100 /  2.  1.100
    08:40:29,844 DEBUG ~ FFMPEG(1):   libswresample   0. 15.100 /  0. 15.100
    08:40:29,844 DEBUG ~ FFMPEG(1):   libpostproc    52.  0.100 / 52.  0.100
    08:40:30,033 DEBUG ~ FFMPEG(1): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '[path]/test.mov':
    08:40:30,033 DEBUG ~ FFMPEG(1):   Metadata:
    08:40:30,033 DEBUG ~ FFMPEG(1):     major_brand     : qt  
    08:40:30,033 DEBUG ~ FFMPEG(1):     minor_version   : 537199360
    08:40:30,035 DEBUG ~ FFMPEG(1):     compatible_brands: qt  
    08:40:30,035 DEBUG ~ FFMPEG(1):     creation_time   : 2011-12-05 10:54:24
    08:40:30,036 DEBUG ~ FFMPEG(1):     timecode        : 00:00:00:00
    08:40:30,036 DEBUG ~ FFMPEG(1):   Duration: 00:00:24.20, start: 0.000000, bitrate: 9912 kb/s
    08:40:30,037 DEBUG ~ FFMPEG(1):     Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 9777 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    08:40:30,037 DEBUG ~ FFMPEG(1):     Metadata:
    08:40:30,037 DEBUG ~ FFMPEG(1):       creation_time   : 2011-12-05 10:56:28
    08:40:30,037 DEBUG ~ FFMPEG(1):       handler_name    : Apple Video Media Handler
    08:40:30,038 DEBUG ~ FFMPEG(1):     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, s16, 129 kb/s
    08:40:30,038 DEBUG ~ FFMPEG(1):     Metadata:
    08:40:30,038 DEBUG ~ FFMPEG(1):       creation_time   : 2011-12-05 10:56:28
    08:40:30,038 DEBUG ~ FFMPEG(1):       handler_name    : Apple Sound Media Handler
    08:40:30,038 DEBUG ~ FFMPEG(1):     Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
    08:40:30,038 DEBUG ~ FFMPEG(1):     Metadata:
    08:40:30,038 DEBUG ~ FFMPEG(1):       creation_time   : 2011-12-05 10:56:28
    08:40:30,039 DEBUG ~ FFMPEG(1):       handler_name    : Time Code Media Handler
    08:40:30,039 DEBUG ~ FFMPEG(1):       timecode        : 00:00:00:00
    08:40:30,092 DEBUG ~ FFMPEG(1): [graph 0 input from stream 0:0 @ 0x1c17180] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
    08:40:30,092 DEBUG ~ FFMPEG(1): [output stream 0:0 @ 0x1c033a0] No opaque field provided
    08:40:30,110 DEBUG ~ FFMPEG(1): [scaler for output stream 0:0 @ 0x1c18040] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:960 h:540 fmt:yuv420p sar:0/1 flags:0x4
    08:40:30,110 DEBUG ~ FFMPEG(1): [graph 1 input from stream 0:1 @ 0x1c53440] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3
    08:40:30,110 DEBUG ~ FFMPEG(1): -async is forwarded to lavfi similarly to -af aresample=min_comp=0.001:min_hard_comp=0.100000:max_soft_comp=0.000042.
    08:40:30,122 DEBUG ~ FFMPEG(1): [graph 1 aresample for input stream 0:1 @ 0x1c36880] chl:stereo fmt:s16 r:48000Hz -> chl:stereo fmt:flt r:48000Hz
    08:40:30,142 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] using SAR=1/1
    08:40:30,142 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] frame MB size (60x34) > level limit (1620)
    08:40:30,142 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] DPB size (4 frames, 3133440 bytes) > level limit (3 frames, 3110400 bytes)
    08:40:30,142 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] MB rate (51000) > level limit (40500)
    08:40:30,170 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] using cpu capabilities: MMX2 SSE2Slow SlowCTZ
    08:40:30,182 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] profile Main, level 3.0
    08:40:30,235 DEBUG ~ FFMPEG(1): [mpegts @ 0x1be3540] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
    08:40:30,235 DEBUG ~ FFMPEG(1): Output #0, mpegts, to '[path]/encoded.ts':
    08:40:30,235 DEBUG ~ FFMPEG(1):   Metadata:
    08:40:30,235 DEBUG ~ FFMPEG(1):     major_brand     : qt  
    08:40:30,235 DEBUG ~ FFMPEG(1):     minor_version   : 537199360
    08:40:30,235 DEBUG ~ FFMPEG(1):     compatible_brands: qt  
    08:40:30,235 DEBUG ~ FFMPEG(1):     timecode        : 00:00:00:00
    08:40:30,235 DEBUG ~ FFMPEG(1):     encoder         : Lavf54.14.100
    08:40:30,235 DEBUG ~ FFMPEG(1):     Stream #0:0(eng): Video: h264, yuv420p, 960x540 [SAR 1:1 DAR 16:9], q=10-51, 1200 kb/s, 90k tbn, 25 tbc
    08:40:30,235 DEBUG ~ FFMPEG(1):     Metadata:
    08:40:30,235 DEBUG ~ FFMPEG(1):       creation_time   : 2011-12-05 10:56:28
    08:40:30,235 DEBUG ~ FFMPEG(1):       handler_name    : Apple Video Media Handler
    08:40:30,236 DEBUG ~ FFMPEG(1):     Stream #0:1(eng): Audio: aac, 48000 Hz, stereo, flt, 128 kb/s
    08:40:30,236 DEBUG ~ FFMPEG(1):     Metadata:
    08:40:30,236 DEBUG ~ FFMPEG(1):       creation_time   : 2011-12-05 10:56:28
    08:40:30,236 DEBUG ~ FFMPEG(1):       handler_name    : Apple Sound Media Handler
    08:40:30,236 DEBUG ~ FFMPEG(1): Stream mapping:
    08:40:30,236 DEBUG ~ FFMPEG(1):   Stream #0:0 -> #0:0 (h264 -> libx264)
    08:40:30,236 DEBUG ~ FFMPEG(1):   Stream #0:1 -> #0:1 (aac -> aac)

    [...]

    08:40:55,398 DEBUG ~ FFMPEG(1): video:3121kB audio:359kB subtitle:0 global headers:0kB muxing overhead 11.132085%
    08:40:55,407 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] frame I:21    Avg QP:21.57  size: 88153
    08:40:55,407 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] frame P:233   Avg QP:22.74  size:  5560
    08:40:55,407 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] frame B:351   Avg QP:27.45  size:   141
    08:40:55,407 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] consecutive B-frames: 21.7%  2.0%  3.0% 73.4%
    08:40:55,407 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] mb I  I16..4: 54.5%  0.0% 45.5%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] mb P  I16..4:  4.7%  0.0%  1.3%  P16..4: 24.6%  3.5%  0.8%  0.0%  0.0%    skip:65.1%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] mb B  I16..4:  0.1%  0.0%  0.1%  B16..8:  0.5%  0.1%  0.0%  direct: 0.6%  skip:98.6%  L0:32.3% L1:47.1% BI:20.6%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] coded y,uvDC,uvAC intra: 59.4% 5.8% 0.4% inter: 5.4% 3.0% 0.0%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] i16 v,h,dc,p: 58% 16% 21%  4%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 21% 17%  5% 10%  7%  5%  5% 10%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] i8c dc,h,v,p: 94%  3%  3%  0%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] Weighted P-Frames: Y:13.7% UV:3.4%
    08:40:55,422 DEBUG ~ FFMPEG(1): [libx264 @ 0x1be3cc0] kb/s:1056.61

    For segmenting is :

    ffmpeg, -i,[path]encoded.ts, -y, -c, copy, -flags, global_header, -map, 0, -f, segment, -segment_time, 10, -segment_list, [path]/fileList.txt, -segment_format, mpegts, [path]/segment_%05d.ts]

    Any help would really be appreciated !

  • Encoding Raw PCM data to AAC using ffmpeg in Android

    10 janvier 2012, par NISHAnT

    Now, i m using libfaac directly to convert raw PCM data to AAC in JNI. Frames Encoded successfully still bytesWritten is always 0 it means there will b some problem in code Here is my Code.

    JNIEXPORT
    jbyteArray JNICALL Java_com_encodePCMFrame(JNIEnv * env,
       jclass clazz,short* data,jint bitRate,jint sampleSize,jint channelConfig)
    {


     faacEncHandle hEncoder;
       unsigned long samplesInput, maxBytesOutput, totalBytesWritten;
       faacEncConfigurationPtr faacPtr;
       char *faac_id_string;
       char *faac_copyright_string;
       unsigned long inputsamples;
       unsigned long maxoutputbytes;
       unsigned char* bitbuf;
       int bytesWritten;
       jbyteArray AACframe;
       jsize size;


       if(faacEncGetVersion(&amp;faac_id_string, &amp;faac_copyright_string) == FAAC_CFG_VERSION)
       {
         __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "\nFAAC_ID_STRING %s\n\n ", faac_id_string);
       }


       hEncoder = faacEncOpen(sampleSize, channelConfig,&amp;inputsamples, &amp;maxoutputbytes);

       if(hEncoder)
       {
          __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "AAC Codec Open (samplesize = %d)\n (channelConfig = %d)\n (input Samples = %d)\n(Max OUTPUT BYTES = %d)\n (bitRate = %d)...",sampleSize,channelConfig,inputsamples,maxoutputbytes,bitRate);
       }


       faacPtr = faacEncGetCurrentConfiguration(hEncoder);

       faacPtr->aacObjectType = MAIN;
       faacPtr->mpegVersion = MPEG2;
       faacPtr->outputFormat = 1; //ADTS
       faacPtr->bitRate = bitRate;
       faacPtr->inputFormat = FAAC_INPUT_16BIT;



       if (faacEncSetConfiguration(hEncoder, faacPtr)==0)
       {
            __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"fail to set");
            faacEncClose ( hEncoder );
            hEncoder =0;
       }



           bitbuf = (unsigned char*)malloc(maxoutputbytes*sizeof(unsigned char));

          bytesWritten = faacEncEncode(hEncoder,(int32_t *)data,inputsamples,bitbuf,maxoutputbytes);


       if(bytesWritten&lt;=0)
       {
               __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Can Not Encode Frame... bytesWritten = %d ",bytesWritten);
               faacEncClose(hEncoder);
       }
       else
       {
              __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Bytes Written = %d ",bytesWritten);

              __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Encoding frame %d ",bitbuf);
       }


       AACframe = (*env)->NewByteArray(env,maxoutputbytes);

       (*env)->SetByteArrayRegion(env,AACframe, 0,maxoutputbytes, bitbuf);

       __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Buffer AAC Frame == %d    Allocated...  Size == %d ",AACframe,maxoutputbytes);


       return AACframe;

       av_free(bitbuf);
       av_free(data);
       (*env)->ReleaseByteArrayElements(env, AACframe, 0, JNI_ABORT);

    }

    Thanks in Advance.