Recherche avancée

Médias (91)

Autres articles (52)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

Sur d’autres sites (14684)

  • Add 2 pictures to video with durations ? [duplicate]

    24 juin 2013, par jesper

    This question already has an answer here :

    I am trying to add 2 different images into a video with ffmpeg.

    image1.jpg should show the first 10 seconds of the movie and youtubeLOL.png should show the next 6 minutes of the video.

    So the command should tell us also to repeat the pictures to get a length for 6 minutes and 10 seconds. How can i do this ? I have tried this :

    (It's not even working)

    passthru("ffmpeg -f image2 -loop 1 -vframes 100 -i /home/psafari/public_html/youtube_images/movie_" . $id . ".jpg -vcodec mpeg4 /home/psafari/public_html/youtube_videos/movie_" . time().".avi");

    Here is output :

    FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2 / 52.64. 2 libavdevice 52. 2. 0 / 52. 2. 0 libavfilter 1.19. 0 / 1.19. 0 libswscale 0.11. 0 / 0.11. 0 libpostproc 51. 2. 0 / 51. 2. 0

    Invalid value '1' for option 'loop'

    output memcode

    MEncoder SVN-r31628-4.4.6 (C) 2000-2010 MPlayer Team
    get_path("config") problem
    success: format: 0  data: 0x0 - 0x1251b
    libavformat file format detected.
    [lavf] stream 0: video (h264), -vid 0
    VIDEO:  [H264]  540x800  24bpp  25.000 fps  116.3 kbps (14.2 kbyte/s)
    [V] filefmt:44  fourcc:0x34363248  size:540x800  fps:25.000  ftime:=0.0400
    videocodec: framecopy (540x800 24bpp fourcc=34363248)
    Writing header...
    ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
    Writing header...
    ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
    Pos:   0.0s      1f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.1s      2f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.1s      3f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.2s      4f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.2s      5f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.2s      6f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.3s      7f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.3s      8f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.4s      9f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.4s     10f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.4s     11f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.5s     12f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.5s     13f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.6s     14f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.6s     15f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.6s     16f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.7s     17f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.7s     18f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.8s     19f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.8s     20f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.8s     21f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.9s     22f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   0.9s     23f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   1.0s     24f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
         Pos:   1.0s     25f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
    Pos:   1.0s     26f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [538:0]
    Pos:   1.1s     27f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [518:0]
    Pos:   1.1s     28f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [500:0]
    Pos:   1.2s     29f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [483:0]
    Pos:   1.2s     30f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [467:0]
    Pos:   1.2s     31f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [452:0]
    Pos:   1.3s     32f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [438:0]
    Pos:   1.3s     33f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [425:0]
    Pos:   1.4s     34f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [413:0]
    Pos:   1.4s     35f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [401:0]
    Pos:   1.4s     36f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [390:0]
    Pos:   1.5s     37f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [380:0]
    Pos:   1.5s     38f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [370:0]
    Pos:   1.6s     39f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [360:0]
    Pos:   1.6s     40f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [351:0]
    Pos:   1.6s     41f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [343:0]
    Pos:   1.7s     42f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [335:0]
    Pos:   1.7s     43f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [327:0]
    Pos:   1.8s     44f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [320:0]
    Pos:   1.8s     45f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [313:0]
    Pos:   1.8s     46f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [306:0]
    Pos:   1.9s     47f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [300:0]
    Pos:   1.9s     48f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [294:0]
    Pos:   2.0s     49f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [288:0]
    Pos:   2.0s     50f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [282:0]
    Pos:   2.0s     51f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [277:0]
    Pos:   2.1s     52f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [272:0]
    Pos:   2.1s     53f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [266:0]
    Pos:   2.2s     54f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [262:0]
    Pos:   2.2s     55f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [257:0]
    Pos:   2.2s     56f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [252:0]
    Pos:   2.3s     57f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [248:0]
    Pos:   2.3s     58f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [244:0]
    Pos:   2.4s     59f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [240:0]
    Pos:   2.4s     60f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [236:0]
    Pos:   2.4s     61f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [232:0]
    Pos:   2.5s     62f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [229:0]
    Pos:   2.5s     63f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [225:0]
    Pos:   2.6s     64f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [222:0]
    Pos:   2.6s     65f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [218:0]
    Pos:   2.6s     66f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [215:0]
    Pos:   2.7s     67f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [212:0]
    Pos:   2.7s     68f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [209:0]
    Pos:   2.8s     69f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [206:0]
    Pos:   2.8s     70f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [203:0]
    Pos:   2.8s     71f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [200:0]
    Pos:   2.9s     72f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [197:0]
    Pos:   2.9s     73f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [195:0]
    Pos:   3.0s     74f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [192:0]
    Pos:   3.0s     75f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [190:0]
    Pos:   3.0s     76f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [187:0]
    Pos:   3.1s     77f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [185:0]
    Pos:   3.1s     78f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [183:0]
    Pos:   3.2s     79f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [180:0]
    Pos:   3.2s     80f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [178:0]
    Pos:   3.2s     81f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [176:0]
    Pos:   3.3s     82f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [174:0]
    Pos:   3.3s     83f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [172:0]
    Pos:   3.4s     84f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [170:0]
    Pos:   3.4s     85f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [168:0]
    Pos:   3.4s     86f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [166:0]
    Pos:   3.5s     87f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [164:0]
    Pos:   3.5s     88f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [162:0]
    Pos:   3.6s     89f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [161:0]
    Pos:   3.6s     90f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [159:0]
    Pos:   3.6s     91f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [157:0]
    Pos:   3.7s     92f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [156:0]
    Pos:   3.7s     93f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [154:0]
    Pos:   3.8s     94f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [152:0]
    Pos:   3.8s     95f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [151:0]
    Pos:   3.8s     96f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [149:0]
    Pos:   3.9s     97f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [148:0]
    Pos:   3.9s     98f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [146:0]
    Pos:   4.0s     99f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [145:0]
    Pos:   4.0s    100f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [144:0]
    Pos:   4.0s    101f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [142:0]
    Pos:   4.1s    102f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [141:0]
    Pos:   4.1s    103f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [140:0]
    Pos:   4.2s    104f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [138:0]
    Pos:   4.2s    105f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [137:0]
    Pos:   4.2s    106f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [136:0]
    Pos:   4.3s    107f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [135:0]
    Pos:   4.3s    108f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [133:0]
    Pos:   4.4s    109f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [132:0]
    Pos:   4.4s    110f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [131:0]
    Pos:   4.4s    111f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [130:0]
    Pos:   4.5s    112f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [129:0]
    Pos:   4.5s    113f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [128:0]
    Pos:   4.6s    114f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [127:0]
    Pos:   4.6s    115f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [126:0]
    Pos:   4.6s    116f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [124:0]
    Pos:   4.7s    117f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [123:0]
    Pos:   4.7s    118f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [122:0]
    Pos:   4.8s    119f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [121:0]
    Pos:   4.8s    120f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [120:0]
    Pos:   4.8s    121f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [119:0]
    Pos:   4.9s    122f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [119:0]
    Pos:   4.9s    123f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [118:0]
    Pos:   5.0s    124f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [117:0]
    Pos:   5.0s    125f (100%)  0.00fps Trem:   0min   0mb  A-V:0.000 [116:0]
    success: format: 0  data: 0x0 - 0x9daf8
    libavformat file format detected.
    [lavf] stream 0: video (h264), -vid 0
    VIDEO:  [H264]  640x400  24bpp  25.000 fps   21.8 kbps ( 2.7 kbyte/s)
    [V] filefmt:44  fourcc:0x34363248  size:640x400  fps:25.000  ftime:=0.0400
    videocodec: framecopy (540x800 24bpp fourcc=34363248)
    videocodec: framecopy (640x400 24bpp fourcc=34363248)

    All video files must have identical fps, resolution, and codec for -ovc copy.

    Exiting...
  • FFmpeg : audio synchronization with audioqueue

    21 août 2013, par juanramoney

    I have a video player in my aplication. I have no problem with avi files and mp3 audio, but when I play mpg or wmv, and I have to use avcodec_decode_audio3. The first seconds plays and then when the buffer refill, I get a silence for a few seconds and then the audio continues from the same place, this happen each time the buffer refill.

    This is the AudioQueue Format :

           playState.format.mSampleRate = _av->audio.sample_rate;
           playState.format.mFormatID = kAudioFormatLinearPCM;
           playState.format.mFormatFlags =  kAudioFormatFlagsCanonical;
           playState.format.mChannelsPerFrame = _av->audio.channels_per_frame;
           playState.format.mBytesPerPacket = sizeof(AudioSampleType) *_av->audio.channels_per_frame;
           playState.format.mBytesPerFrame = sizeof(AudioSampleType) *_av->audio.channels_per_frame;
           playState.format.mBitsPerChannel = 8 * sizeof(AudioSampleType);

           playState.format.mFramesPerPacket = 1;
           playState.format.mReserved = 0;

    fillAudioBuffer :

    static void fillAudioBuffer(AudioQueueRef queue, AudioQueueBufferRef buffer){

    int lengthCopied = INT32_MAX;
    int dts= 0;
    int isDone = 0;

    buffer->mAudioDataByteSize = 0;
    buffer->mPacketDescriptionCount = 0;

    OSStatus err = 0;
    AudioTimeStamp bufferStartTime;

    AudioQueueGetCurrentTime(queue, NULL, &bufferStartTime, NULL);

    while(buffer->mPacketDescriptionCount < numPacketsToRead && lengthCopied > 0){

       lengthCopied = getNextAudio(_av,buffer->mAudioDataBytesCapacity-buffer->mAudioDataByteSize, (uint8_t*)buffer->mAudioData+buffeg->mAudioDataByteSize,&dts,&isDone);
       if(!lengthCopied || isDone) break;

       if(aqStartDts < 0) aqStartDts = dts;
       if(buffer->mPacketDescriptionCount ==0){
           bufferStartTime.mFlags = kAudioTimeStampSampleTimeValid;
           bufferStartTime.mSampleTime = (Float64)(dts-aqStartDts);
       }
       buffer->mPacketDescriptions[buffer->mPacketDescriptionCount].mStartOffset = buffer->mAudioDataByteSize;
       buffer->mPacketDescriptions[buffer->mPacketDescriptionCount].mDataByteSize = lengthCopied;
       buffer->mPacketDescriptions[buffer->mPacketDescriptionCount].mVariableFramesInPacket = _av->audio.frame_size;
       buffer->mPacketDescriptionCount++;
       buffer->mAudioDataByteSize += lengthCopied;

    }
    if(buffer->mAudioDataByteSize){
       if((err=AudioQueueEnqueueBufferWithParameters(queue, buffer, 0, NULL, 0, 0, 0, NULL, &bufferStartTime, NULL)))
       {

       }
    }


    int   getNextAudio(video_data_t* vInst, int maxlength, uint8_t* buf, int* pts, int* isDone) {
    struct video_context_t  *ctx = vInst->context;
    int    datalength            = 0;
    while(ctx->audio_ring.lock || ((ctx->audio_ring.count <= 0 && ((ctx->play_state & STATE_DIE) != STATE_DIE))&&((ctx->play_state & STATE_EOF) != STATE_EOF))){
       PMSG1(stdout,"die get audio %d", ctx->play_state);
       if((ctx->play_state & STATE_STOP) != STATE_STOP){
           PMSG1(stdout,"die NO CARGADO %d",ctx->play_state);
           return 0;
       }
       usleep(100);
    }
    *pts = 0;
    ctx->audio_ring.lock = kLocked;

    if(ctx->audio_ring.count>0 && maxlength > ctx->audio_buffer[ctx->audio_ring.read].size){
       memcpy(buf, ctx->audio_buffer[ctx->audio_ring.read].data, ctx->audio_buffer[ctx->audio_ring.read].size);
       datalength = ctx->audio_buffer[ctx->audio_ring.read].size;
       *pts = ctx->audio_buffer[ctx->audio_ring.read].pts;
       ctx->audio_ring.read++;
       ctx->audio_ring.read %= ABUF_SIZE;
       ctx->audio_ring.count--;
    }
    ctx->audio_ring.lock = kUnlocked;

    if((ctx->play_state & STATE_EOF) == STATE_EOF && ctx->audio_ring.count == 0) *isDone = 1;
    return datalength;

    This is a log playing a mpg file :

    Input #0, mpeg, '1.MPG':
     Duration: 00:03:14.74, start: 3370.475789, bitrate: 2489 kb/s
       Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 544x576 [SAR 24:17 DAR 4:3], 9000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
       Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
    mpeg2video  MPEG-2 video
    aspect 1.333333
    startPlayback
    DTS: 0.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 303347520
    Video Buffer: 157/1024 Audio Buffer: 33/1024
    Bytes copied for buffer 0xc292ac0: 1046016
    DTS: 490320.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 303837840
    Video Buffer: 276/1024 Audio Buffer: 2/1024
    Bytes copied for buffer 0x1225f8b0: 1046016
    DTS: 980640.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 304328160
    Video Buffer: 411/1024 Audio Buffer: 1/1024
    Bytes copied for buffer 0x13380840: 1046016
    DTS: 1470960.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 304818480
    Video Buffer: 885/1024 Audio Buffer: 797/1024
    Bytes copied for buffer 0xc292ac0: 1046016
    -----Here the audio stop for 4 or 5 seconds
    -----then continues for 4 or 5 seconds
    DTS: 1961280.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 305308800
    Video Buffer: 765/1024 Audio Buffer: 797/1024
    Bytes copied for buffer 0x1225f8b0: 1046016
    -----Here the audio stop for 4 or 5 seconds
    -----then continues for 4 or 5 seconds
    DTS: 2451600.000000 time base: 0.000011 StartDTS: 303347520 Orig DTS: 305799120
    Video Buffer: 644/1024 Audio Buffer: 798/1024
    Bytes copied for buffer 0x13380840: 1046016
    ...

    if I reduce the buffer, the silence and sound time is reduced.
    So I want to know how to fix it ? Thanks !!

  • Getting Error during executin native android code

    3 avril 2013, par dilipkaklotar

    Error on my console

    bash : cannot set terminal process group (-1) : Inappropriate ioctl for device
    bash : no job control in this shell
    Your group is currently "mkpasswd". This indicates that your
    gid is not in /etc/group and your uid is not in /etc/passwd.

    The /etc/passwd (and possibly /etc/group) files should be rebuilt.
    See the man pages for mkpasswd and mkgroup then, for example, run

    mkpasswd -l [-d] > /etc/passwd
    mkgroup -l [-d] > /etc/group

    Note that the -d switch is necessary for domain users.
    - ]0 ; -
    - [32mDILIP@DILIP-PC -[33m -[0m
    $

    public class VideoBrowser extends ListActivity implements ListView.OnScrollListener {

    /*this part communicates with native code through jni (java native interface)*/
    //load the native library
    static {
       System.loadLibrary("ffmpeg");
       System.loadLibrary("ffmpeg-test-jni");
    }
    //declare the jni functions
    private static native void naInit(String _videoFileName);
    private static native int[] naGetVideoResolution();
    private static native String naGetVideoCodecName();
    private static native String naGetVideoFormatName();
    private static native void naClose();

    private void showVideoInfo(final File _file) {
       String videoFilename = _file.getAbsolutePath();
       naInit(videoFilename);
       int[] prVideoRes = naGetVideoResolution();
       String prVideoCodecName = naGetVideoCodecName();
       String prVideoFormatName = naGetVideoFormatName();
       naClose();
       String displayText = "Video: " + videoFilename + "\n";
       displayText += "Video Resolution: " + prVideoRes[0] + "x" + prVideoRes[1] + "\n";
       displayText += "Video Codec: " + prVideoCodecName + "\n";
       displayText += "Video Format: " + prVideoFormatName + "\n";
       text_titlebar_text.setText(displayText);
    }


    /*the rest of the file deals with UI and other stuff*/
    private Context mContext;
    public static VideoBrowser self;

    /**
    * activity life cycle: this part of the source code deals with activity life cycle
    */
    @Override
    public void onCreate(Bundle icicle) {
       super.onCreate(icicle);
       mContext = this.getApplicationContext();
       self = this;
       initUI();
    }

    @Override
    protected void onDestroy() {
       super.onDestroy();
       unbindDisplayEntries();
    }

    public void unbindDisplayEntries() {
       if (displayEntries!=null) {
           int l_count = displayEntries.size();
           for (int i = 0; i < l_count; ++i) {
               IconifiedTextSelected l_its = displayEntries.get(i);
               if (l_its != null) {
                   Drawable l_dr = l_its.getIcon();
                   if (l_dr != null) {
                       l_dr.setCallback(null);
                       l_dr = null;
                   }
               }
           }
       }
       if (l_displayEntries!=null) {
           int l_count = l_displayEntries.size();
           for (int i = 0; i < l_count; ++i) {
               IconifiedTextSelected l_its = l_displayEntries.get(i);
               if (l_its != null) {
                   Drawable l_dr = l_its.getIcon();
                   if (l_dr != null) {
                       l_dr.setCallback(null);
                       l_dr = null;
                   }
               }
           }
       }
    }

    /**
    * Data: this part of the code deals with data processing
    */
    public List<iconifiedtextselected> displayEntries = new ArrayList<iconifiedtextselected>();
    public static List<iconifiedtextselected> l_displayEntries = new ArrayList<iconifiedtextselected>();;

    /**load images
    * this part of code deals with loading of images
    */
    private File currentDirectory;
    public int media_browser_load_option = 2;
    private static int last_media_browser_load_option = 2;
    private static int number_of_icons = 0;
    private static final String upOneLevel = "..";

    LoadVideoTask loadTask;
    private void loadVideosFromDirectory(String _dir) {
       try {
           loadTask = new LoadVideoTask();
           loadTask.execute(_dir);
       } catch (Exception e) {
           Toast.makeText(this, "Load media fail!", Toast.LENGTH_SHORT).show();
       }
    }

    private void getVideosFromDirectoryNonRecurAddParent(File _dir) {
       //add the upper one level data
       if (_dir.getParent()!=null) {
           this.displayEntries.add(new IconifiedTextSelected(
                   upOneLevel,
                   getResources().getDrawable(R.drawable.folderback),
                   false, false, 0));
       }
    }

    private void getVideosFromDirectoryNonRecur(File _dir) {
       Drawable folderIcon = this.getResources().getDrawable(R.drawable.normalfolder);
       //add the
       if (!_dir.isDirectory()) {
           return;
       }
       File[] files = _dir.listFiles();
       if (files == null) {
           return;
       }
       Drawable videoIcon = null;
       int l_iconType = 0;
       for (File currentFile : files) {
           if (currentFile.isDirectory()) {
               //if it&#39;s a directory
               this.displayEntries.add(new IconifiedTextSelected(
                       currentFile.getPath(),
                       folderIcon, false, false, 0));
           } else {
               String l_filename = currentFile.getName();
               if (checkEndsWithInStringArray(l_filename,
                           getResources().getStringArray(R.array.fileEndingVideo))) {
                   if (number_of_icons &lt; 10) {
                       videoIcon = null;
                       ++number_of_icons;
                       l_iconType = 22;
                   } else {
                       videoIcon = null;
                       l_iconType = 2;
                   }
                   this.displayEntries.add(new IconifiedTextSelected(
                           currentFile.getPath(),
                           videoIcon, false, false, l_iconType));
               }
           }
       }
    }

    private void getVideosFromDirectoryRecur(File _dir) {
       Drawable videoIcon = null;
       File[] files = _dir.listFiles();
       int l_iconType = 2;
       if (files == null) {
           return;
       }
       for (File currentFile : files) {
           if (currentFile.isDirectory()) {
               getVideosFromDirectoryRecur(currentFile);
               continue;
           } else {
               String l_filename = currentFile.getName();
               //if it&#39;s an image file
               if (checkEndsWithInStringArray(l_filename,
                       getResources().getStringArray(R.array.fileEndingVideo))) {
                   if (number_of_icons &lt; 10) {
                       videoIcon = null;
                       ++number_of_icons;
                       l_iconType = 22;
                   } else {
                       videoIcon = null;
                       l_iconType = 2;
                   }
                   this.displayEntries.add(new IconifiedTextSelected(
                           currentFile.getPath(),
                           videoIcon, false, false, l_iconType));
               }
           }
       }
    }

    private void getVideosFromGallery() {
       Drawable videoIcon = null;
       Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
       String[] projection = {MediaStore.Video.Media.DATA};
       Cursor l_cursor = this.managedQuery(uri, projection, null, null, null);
       int videoNameColumnIndex;
       String videoFilename;
       File videoFile;
       int l_iconType = 2;
       if (l_cursor!=null) {
           if (l_cursor.moveToFirst()) {
               do {
                   videoNameColumnIndex = l_cursor.getColumnIndexOrThrow(
                           MediaStore.Images.Media.DATA);
                   videoFilename = l_cursor.getString(videoNameColumnIndex);
                   videoFile = new File(videoFilename);
                   if (!videoFile.exists()) {
                       continue;
                   }
                   if (number_of_icons &lt;= 10) {
                       videoIcon = null;
                       ++number_of_icons;
                       l_iconType = 22;
                   } else {
                       videoIcon = null;
                       l_iconType = 2;
                   }
                   this.displayEntries.add(new IconifiedTextSelected(
                           videoFile.getAbsolutePath(),
                           videoIcon, false, false, l_iconType));
               } while (l_cursor.moveToNext());
           }
       }
       if (l_cursor!=null) {
           l_cursor.close();
       }
    }

    private boolean checkEndsWithInStringArray(String checkItsEnd,
           String[] fileEndings){
       for(String aEnd : fileEndings){
           if(checkItsEnd.endsWith(aEnd))
               return true;
       }
       return false;
    }

    private class LoadVideoTask extends AsyncTask {
       @Override
       protected void onPreExecute() {
           System.gc();
           displayEntries.clear();
           showDialog(DIALOG_LOAD_MEDIA);
       }
       @Override
       protected Void doInBackground(String... params) {
           File l_root = new File(params[0]);
           if (l_root.isDirectory()) {
               number_of_icons = 0;
               currentDirectory = l_root;
               if (media_browser_load_option == 0) {
                   //list all videos in the root directory without going into sub folder
                   getVideosFromDirectoryNonRecurAddParent(l_root);
                   getVideosFromDirectoryNonRecur(l_root);
               } else if (media_browser_load_option == 1) {
                   //list all videos in the root folder recursively
                   getVideosFromDirectoryRecur(l_root);
               } else if (media_browser_load_option == 2) {
                   //list all videos in the gallery
                   getVideosFromGallery();
               }
           }
           return null;
       }
       @Override
       protected void onPostExecute(Void n) {
           refreshUI();
           dismissDialog(DIALOG_LOAD_MEDIA);
       }
    }

    /**
    * UI: this part of the source code deals with UI
    */
    //bottom menu
    private int currentFocusedBtn = 1;
    private Button btn_bottommenu1;
    private Button btn_bottommenu2;
    private Button btn_bottommenu3;
    //private Button btn_bottommenu4;
    //title bar
    private TextView text_titlebar_text;

    private void initUI() {
       this.requestWindowFeature(Window.FEATURE_NO_TITLE);
       this.setContentView(R.layout.video_browser);
       //title bar
       text_titlebar_text = (TextView) findViewById(R.id.titlebar_text);
       text_titlebar_text.setText("Click a video to display info");

       //bottom menu
       int l_btnWidth = this.getWindowManager().getDefaultDisplay().getWidth()/4;
       btn_bottommenu1 = (Button) findViewById(R.id.video_browser_btn1);
       //btn_bottommenu1 = (ActionMenuButton) findViewById(R.id.main_topsecretimport_btn1);
       btn_bottommenu1.setWidth(l_btnWidth);
       btn_bottommenu1.setOnClickListener(new View.OnClickListener() {
           public void onClick(View v) {
               btn_bottommenu1.setEnabled(false);
               btn_bottommenu2.setEnabled(true);
               btn_bottommenu3.setEnabled(true);
               currentFocusedBtn = 1;
               last_list_view_pos = 0;
               media_browser_load_option = 2;
               last_media_browser_load_option = media_browser_load_option;
               loadVideosFromDirectory("/sdcard/");
           }
       });
       btn_bottommenu2 = (Button) findViewById(R.id.video_browser_btn2);
       btn_bottommenu2.setWidth(l_btnWidth);
       btn_bottommenu2.setOnClickListener(new View.OnClickListener() {
           public void onClick(View v) {
               btn_bottommenu1.setEnabled(true);
               btn_bottommenu2.setEnabled(false);
               btn_bottommenu3.setEnabled(true);
               currentFocusedBtn = 2;
               last_list_view_pos = 0;
               media_browser_load_option = 0;
               last_media_browser_load_option = media_browser_load_option;
               loadVideosFromDirectory("/sdcard/");
           }
       });
       btn_bottommenu3 = (Button) findViewById(R.id.video_browser_btn3);
       btn_bottommenu3.setWidth(l_btnWidth);
       btn_bottommenu3.setOnClickListener(new View.OnClickListener() {
           public void onClick(View v) {
               btn_bottommenu1.setEnabled(true);
               btn_bottommenu2.setEnabled(true);
               btn_bottommenu3.setEnabled(false);
               currentFocusedBtn = 3;
               last_list_view_pos = 0;
               media_browser_load_option = 1;
               last_media_browser_load_option = media_browser_load_option;
               loadVideosFromDirectory("/sdcard/");
           }
       });
       media_browser_load_option = last_media_browser_load_option;
       if (media_browser_load_option==2) {
           btn_bottommenu1.setEnabled(false);
       } else if (media_browser_load_option==0) {
           btn_bottommenu2.setEnabled(false);
       } else if (media_browser_load_option==1){
           btn_bottommenu3.setEnabled(false);
       }
       loadVideosFromDirectory("/sdcard/");
    }
    //refresh the UI when the directoryEntries changes
    private static int last_list_view_pos = 0;
    public void refreshUI() {
       int l_btnWidth = this.getWindowManager().getDefaultDisplay().getWidth()/4;
       btn_bottommenu1.setWidth(l_btnWidth);
       btn_bottommenu2.setWidth(l_btnWidth);
       btn_bottommenu3.setWidth(l_btnWidth);
       //btn_bottommenu4.setWidth(l_btnWidth);

       SlowAdapter itla = new SlowAdapter(this);
       itla.setListItems(this.displayEntries);    
       this.setListAdapter(itla);
       getListView().setOnScrollListener(this);
       int l_size = this.displayEntries.size();
       if (l_size > 50) {
           getListView().setFastScrollEnabled(true);
       } else {
           getListView().setFastScrollEnabled(false);
       }
       if (l_size > 0) {
           if (last_list_view_pos &lt; l_size) {
               getListView().setSelection(last_list_view_pos);
           } else {
               getListView().setSelection(l_size-1);
           }
       }
       registerForContextMenu(getListView());
    }

    @Override
    public void onConfigurationChanged (Configuration newConfig) {
       super.onConfigurationChanged(newConfig);
       refreshUI();
    }

    static final int DIALOG_LOAD_MEDIA = 1;
    static final int DIALOG_HELP = 2;
    @Override
    protected Dialog onCreateDialog(int id) {
       switch(id) {
       case DIALOG_LOAD_MEDIA:
           ProgressDialog dialog = new ProgressDialog(this);
           dialog.setTitle("Load Files");
           dialog.setMessage("Please wait while loading...");
           dialog.setIndeterminate(true);
           dialog.setCancelable(true);
           return dialog;
       default:
           return null;
       }
    }
    /**
    * scroll events methods: this part of the source code contain the control source code
    * for handling scroll events
    */
    private boolean mBusy = false;
    private void disableButtons() {
       btn_bottommenu1.setEnabled(false);
       btn_bottommenu2.setEnabled(false);
       btn_bottommenu3.setEnabled(false);
    }

    private void enableButtons() {
       if (currentFocusedBtn!=1) {
           btn_bottommenu1.setEnabled(true);
       }
       if (currentFocusedBtn!=2) {
           btn_bottommenu2.setEnabled(true);
       }
       if (currentFocusedBtn!=3) {
           btn_bottommenu3.setEnabled(true);
       }
    }
    public void onScroll(AbsListView view, int firstVisibleItem,
           int visibleItemCount, int totalItemCount) {
       last_list_view_pos = view.getFirstVisiblePosition();
    }

    //private boolean mSaveMemory = false;
    public void onScrollStateChanged(AbsListView view, int scrollState) {      
       switch (scrollState) {
       case OnScrollListener.SCROLL_STATE_IDLE:
           enableButtons();
           mBusy = false;
           int first = view.getFirstVisiblePosition();
           int count = view.getChildCount();
           int l_releaseTarget;
           for (int i=0; i/if outofmemory, we try to clean up 10 view image resources,
                       //and try again
                       for (int j = 0; j &lt; 10; ++j) {
                           l_releaseTarget = first - count - j;
                           if (l_releaseTarget > 0) {
                               IconifiedTextSelected l_its = displayEntries.get(l_releaseTarget);
                               IconifiedTextSelectedView l_itsv = (IconifiedTextSelectedView)
                                   this.getListView().getChildAt(l_releaseTarget);
                               if (l_itsv!=null) {
                                   l_itsv.setIcon(null);
                               }
                               if (l_its != null) {
                                   Drawable l_dr = l_its.getIcon();
                                   l_its.setIcon(null);
                                   if (l_dr != null) {
                                       l_dr.setCallback(null);
                                       l_dr = null;
                                   }
                               }
                           }
                       }
                       System.gc();
                       //after clean up, we try again
                       if (l_type == 1) {
                           l_icon = null;
                       } else if (l_type == 2) {
                           l_icon = null;
                       }
                   }
                   this.displayEntries.get(first+i).setIcon(l_icon);
                   if (l_icon != null) {
                       t.setIcon(l_icon);
                       t.setTag(null);
                   }
               }
           }
           //System.gc();
           break;
       case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
           disableButtons();
           mBusy = true;
           break;
       case OnScrollListener.SCROLL_STATE_FLING:
           disableButtons();
           mBusy = true;
           break;
       }
    }

    /**
    * List item click action
    */
    private File currentFile;
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
       super.onListItemClick(l, v, position, id);
       last_list_view_pos = position;
       String selectedFileOrDirName = this.displayEntries.get((int)id).getText();
       if (selectedFileOrDirName.equals(upOneLevel)) {
           if (this.currentDirectory.getParent()!=null) {
               last_list_view_pos = 0;
               browseTo(this.currentDirectory.getParentFile());
           }
       } else {
           File l_clickedFile = new File(this.displayEntries.get((int)id).getText());
           if (l_clickedFile != null) {
               if (l_clickedFile.isDirectory()) {
                   last_list_view_pos = 0;
                   browseTo(l_clickedFile);
               } else {
                   showVideoInfo(l_clickedFile);
               }
           }
       }
    }

    private void browseTo(final File _dir) {
       if (_dir.isDirectory()) {
           this.currentDirectory = _dir;
           loadVideosFromDirectory(_dir.getAbsolutePath());
       }
    }

    /**
    * Slow adapter: this part of the code implements the list adapter
    * Will not bind views while the list is scrolling
    */
    private class SlowAdapter extends BaseAdapter {
       /** Remember our context so we can use it when constructing views. */
       private Context mContext;

       private List<iconifiedtextselected> mItems = new ArrayList<iconifiedtextselected>();

       public SlowAdapter(Context context) {
           mContext = context;
       }

       public void setListItems(List<iconifiedtextselected> lit)
       { mItems = lit; }

       /** @return The number of items in the */
       public int getCount() { return mItems.size(); }

       public Object getItem(int position)
       { return mItems.get(position); }

       /** Use the array index as a unique id. */
       public long getItemId(int position) {
           return position;
       }

       /** @param convertView The old view to overwrite, if one is passed
        * @returns a IconifiedTextSelectedView that holds wraps around an IconifiedText */
       public View getView(int position, View convertView, ViewGroup parent) {
           IconifiedTextSelectedView btv;
           if (convertView == null) {
               btv = new IconifiedTextSelectedView(mContext, mItems.get(position));
           } else { // Reuse/Overwrite the View passed
               // We are assuming(!) that it is castable!
               btv = (IconifiedTextSelectedView) convertView;
               btv.setText(mItems.get(position).getText());
           }
           if (position==0) {
               if (VideoBrowser.self.media_browser_load_option==0) {
                   btv.setIcon(R.drawable.folderback);
               } else if (mItems.get(0).getIcon()!=null) {
                   btv.setIcon(mItems.get(position).getIcon());
               } else {
                   btv.setIcon(R.drawable.video);
               }
           }
           //in busy mode
           else if (mBusy){
               //if icon is NULL: the icon is not loaded yet; load default icon
               if (mItems.get(position).getIcon()==null) {
                   btv.setIcon(R.drawable.video);
                   //mark this view, indicates the icon is not loaded
                   btv.setTag(this);
               } else {
                   //if icon is not null, just display the icon
                   btv.setIcon(mItems.get(position).getIcon());
                   //mark this view, indicates the icon is loaded
                   btv.setTag(null);
               }
           } else {
               //if not busy
               Drawable d = mItems.get(position).getIcon();
               if (d == null) {
                   //icon is not loaded, load now
                   btv.setIcon(R.drawable.video);
                   btv.setTag(this);
               } else {
                   btv.setIcon(mItems.get(position).getIcon());
                   btv.setTag(null);
               }
           }
           return btv;
       }
    }
    </iconifiedtextselected></iconifiedtextselected></iconifiedtextselected></iconifiedtextselected></iconifiedtextselected></iconifiedtextselected></iconifiedtextselected>

    }