Recherche avancée

Médias (0)

Mot : - Tags -/presse-papier

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

Autres articles (11)

  • 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 (3408)

  • ffmpeg libz.so dependency

    26 février 2014, par malaprop malaprop

    we are trying to install ffmpeg on our RH linux servers.

    Trouble is that it works on one not on the other and we have no idea why. The working and the non working server have the same config information :

    ffmpeg version 0.10.2 Copyright (c) 2000-2012 the FFmpeg developers
    built on Apr 19 2012 14:00:25 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
    configuration : —enable-gpl —enable-version3 —enable-shared —enable-nonfree —enable-postproc —enable-libfaac —enable-libmp3lame —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libtheora —enable-libvorbis —enable-libvpx —enable-libx264 —enable-libxvid —enable-x11grab —extra-cflags=-I/usr/local/include —extra-ldflags=-L/usr/local/lib
    libavutil 51. 35.100 / 51. 35.100
    libavcodec 53. 61.100 / 53. 61.100
    libavformat 53. 32.100 / 53. 32.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 61.100 / 2. 61.100
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 6.100 / 0. 6.100
    libpostproc 52. 0.100 / 52. 0.100
    Hyper fast Audio and Video encoder

    The error we are getting is :

    ffmpeg version 0.10.2 Copyright (c) 2000-2012 the FFmpeg developers
    built on Apr 19 2012 14:00:25 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
    configuration : —enable-gpl —enable-version3 —enable-shared —enable-nonfree —enable-postproc —enable-libfaac —enable-libmp3lame —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libtheora —enable-libvorbis —enable-libvpx —enable-libx264 —enable-libxvid —enable-x11grab —extra-cflags=-I/usr/local/include —extra-ldflags=-L/usr/local/lib
    libavutil 51. 35.100 / 51. 35.100
    libavcodec 53. 61.100 / 53. 61.100
    libavformat 53. 32.100 / 53. 32.100
    libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 61.100 / 2. 61.100
    libswscale 2. 1.100 / 2. 1.100
    libswresample 0. 6.100 / 0. 6.100
    libpostproc 52. 0.100 / 52. 0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '4598_Testvideo_MP4-H264-6MBit_AAC-44KHz-192KBit_720p.mp4' :
    Metadata :
    major_brand : mp42
    minor_version : 0
    compatible_brands : mp42mp41
    creation_time : 2012-01-25 10:58:21
    Duration : 00:02:13.56, start : 0.000000, bitrate : 5472 kb/s
    Stream #0:0(eng) : Video : h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5280 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc
    Metadata :
    creation_time : 2012-01-25 10:58:21
    handler_name : Mainconcept MP4 Video Media Handler
    Stream #0:1(eng) : Audio : aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 189 kb/s
    Metadata :
    creation_time : 2012-01-25 10:58:21
    handler_name : Mainconcept MP4 Sound Media Handler
    [buffer @ 0x3160ea0] w:1280 h:720 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param :
    [scale @ 0x31629a0] w:1280 h:720 fmt:yuv420p -> w:480 h:270 fmt:yuv420p flags:0x4
    [libvpx @ 0x314ab40] v0.9.6
    [libvpx @ 0x314ab40] Failed to initialize encoder : ABI version mismatch
    Output #0, webm, to 'outputvideo.webm' :
    Metadata :
    major_brand : mp42
    minor_version : 0
    compatible_brands : mp42mp41
    creation_time : 2012-01-25 10:58:21
    Stream #0:0(eng) : Video : vp8, yuv420p, 480x270 [SAR 1:1 DAR 16:9], q=-1—1, 2500 kb/s, 90k tbn, 25 tbc
    Metadata :
    creation_time : 2012-01-25 10:58:21
    handler_name : Mainconcept MP4 Video Media Handler
    Stream #0:1(eng) : Audio : none, 44100 Hz, stereo, s16, 128 kb/s
    Metadata :
    creation_time : 2012-01-25 10:58:21
    handler_name : Mainconcept MP4 Sound Media Handler
    Stream mapping :
    Stream #0:0 -> #0:0 (h264 -> libvpx)
    Stream #0:1 -> #0:1 (aac -> libvorbis)
    Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

    I've looked at the dependent libraries using ldd and did find one differenct. the library libz.so was not listet in the system that doesn't work. ie

    /lib64/ld-linux-x86-64.so.2 (0x00000035a9000000)
    libavcodec.so.53 => /usr/local/lib/libavcodec.so.53 (0x00002ae5189a8000)
    libavdevice.so.53 => /usr/local/lib/libavdevice.so.53 (0x00002ae518204000)
    libavfilter.so.2 => /usr/local/lib/libavfilter.so.2 (0x00002ae51840e000)
    libavformat.so.53 => /usr/local/lib/libavformat.so.53 (0x00002ae51869c000)
    libavutil.so.51 => /usr/local/lib/libavutil.so.51 (0x00002ae519e17000)
    libc.so.6 => /lib64/libc.so.6 (0x00000035a9400000)
    libfaac.so.0 => /usr/lib64/libfaac.so.0 (0x0000003407800000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000035ac000000)
    libmp3lame.so.0 => /usr/lib64/libmp3lame.so.0 (0x0000003407000000)
    libm.so.6 => /lib64/libm.so.6 (0x00000035aa000000)
    libogg.so.0 => /usr/local/lib/libogg.so.0 (0x00002ae51b35b000)
    libopencore-amrnb.so.0 => /usr/lib64/libopencore-amrnb.so.0 (0x0000003409800000)
    libopencore-amrwb.so.0 => /usr/lib64/libopencore-amrwb.so.0 (0x0000003407c00000)
    libpostproc.so.52 => /usr/local/lib/libpostproc.so.52 (0x00002ae5197ba000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00000035a9c00000)
    libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000035aa400000)
    libswresample.so.0 => /usr/local/lib/libswresample.so.0 (0x00002ae5199c6000)
    libswscale.so.2 => /usr/local/lib/libswscale.so.2 (0x00002ae519bce000)
    libtheoradec.so.1 => /usr/local/lib/libtheoradec.so.1 (0x00002ae51b141000)
    libtheoraenc.so.1 => /usr/local/lib/libtheoraenc.so.1 (0x00002ae51af05000)
    libvorbisenc.so.2 => /usr/lib64/libvorbisenc.so.2 (0x00002ae51a8fe000)
    libvorbis.so.0 => /usr/lib64/libvorbis.so.0 (0x00002ae51acd9000)
    libvpx.so.0 => /usr/lib64/libvpx.so.0 (0x00002ae51a687000)
    libx264.so.120 => /usr/local/lib/libx264.so.120 (0x00002ae51a320000)
    libxvidcore.so.4 => /usr/lib64/libxvidcore.so.4 (0x00002ae51a03a000)
    linux-vdso.so.1 => (0x00007ffff63f6000)

    as opposed to

    /lib64/ld-linux-x86-64.so.2 (0x0000003074c00000)
    libavcodec.so.53 => /usr/local/lib/libavcodec.so.53 (0x00002b2038eeb000)
    libavdevice.so.53 => /usr/local/lib/libavdevice.so.53 (0x00002b2038746000)
    libavfilter.so.2 => /usr/local/lib/libavfilter.so.2 (0x00002b2038950000)
    libavformat.so.53 => /usr/local/lib/libavformat.so.53 (0x00002b2038bdf000)
    libavutil.so.51 => /usr/local/lib/libavutil.so.51 (0x00002b203a368000)
    libc.so.6 => /lib64/libc.so.6 (0x0000003075000000)
    libfaac.so.0 => /usr/lib64/libfaac.so.0 (0x00002b203bcef000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003003400000)
    libmp3lame.so.0 => /usr/lib64/libmp3lame.so.0 (0x000000310ae00000)
    libm.so.6 => /lib64/libm.so.6 (0x0000003075c00000)
    libogg.so.0 => /usr/lib64/libogg.so.0 (0x00002b203bf01000)
    libopencore-amrnb.so.0 => /usr/lib64/libopencore-amrnb.so.0 (0x00002b203bac1000)
    libopencore-amrwb.so.0 => /usr/lib64/libopencore-amrwb.so.0 (0x00002b203b8ab000)
    libpostproc.so.52 => /usr/local/lib/libpostproc.so.52 (0x00002b2039d0b000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003075800000)
    libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x000000360ea00000)
    libswresample.so.0 => /usr/local/lib/libswresample.so.0 (0x00002b2039f18000)
    libswscale.so.2 => /usr/local/lib/libswscale.so.2 (0x00002b203a11f000)
    libtheoradec.so.1 => /usr/local/lib/libtheoradec.so.1 (0x00002b203b693000)
    libtheoraenc.so.1 => /usr/local/lib/libtheoraenc.so.1 (0x00002b203b457000)
    libvorbisenc.so.2 => /usr/lib64/libvorbisenc.so.2 (0x00002b203ae50000)
    libvorbis.so.0 => /usr/lib64/libvorbis.so.0 (0x00002b203b22a000)
    libvpx.so.0 => /usr/lib64/libvpx.so.0 (0x00002b203abd9000)
    libx264.so.120 => /usr/local/lib/libx264.so.120 (0x00002b203a871000)`enter code here`
    libxvidcore.so.4 => /usr/lib64/libxvidcore.so.4 (0x00002b203a58c000)
    libz.so.1 => /lib64/libz.so.1 (0x0000003076000000)
    linux-vdso.so.1 => (0x00007fff6adfd000)

    I wanted to ask whether this has something to do with the problem. before i try to figure out how come the libz.so appears i nthe one list and not the other.

    btw the ld.so.conf files are identical.

  • How to fix a segmentaion fault in a C program ? [closed]

    13 janvier 2012, par ipegasus

    Possible Duplicate :
    Segmentation fault

    Currently I am upgrading an open source program used for HTTP streaming. It needs to support the latest FFMPEG.
    The code compiles fine with no warnings although I am getting a segmentation fault error.
    I would like to know how to fix the issue ? and / or the best way to debug ? Please find attached a portion of the code due to size. I will try to add the project to github :) Thanks in advance !

    Sample Usage

    # segmenter --i out.ts --l 10 --o stream.m3u8 --d segments --f stream

    Makefile

    FFLIBS=`pkg-config --libs libavformat libavcodec libavutil`
    FFFLAGS=`pkg-config --cflags libavformat libavcodec libavutil`

    all:
       gcc -Wall -g segmenter.c -o segmenter ${FFFLAGS} ${FFLIBS}

    segmenter.c

    /*
    * Copyright (c) 2009 Chase Douglas
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License version 2
    * as published by the Free Software Foundation.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    */
    #include
    #include
    #include
    #include
    #include
    #include "libavformat/avformat.h"

    #include "libavformat/avio.h"

    #include <sys></sys>stat.h>

    #include "segmenter.h"
    #include "libavformat/avformat.h"

    #define IMAGE_ID3_SIZE 9171

    void printUsage() {
       fprintf(stderr, "\nExample: segmenter --i infile --d baseDir --f baseFileName --o playListFile.m3u8 --l 10 \n");
       fprintf(stderr, "\nOptions: \n");
       fprintf(stderr, "--i <infile>.\n");
       fprintf(stderr, "--o <outfile>.\n");
       fprintf(stderr, "--d basedir, the base directory for files.\n");
       fprintf(stderr, "--f baseFileName, output files will be baseFileName-#.\n");
       fprintf(stderr, "--l segment length, the length of each segment.\n");
       fprintf(stderr, "--a,  audio only decode for &lt; 64k streams.\n");
       fprintf(stderr, "--v,  video only decode for &lt; 64k streams.\n");
       fprintf(stderr, "--version, print version details and exit.\n");
       fprintf(stderr, "\n\n");
    }

    void ffmpeg_version() {
       // output build and version numbers
       fprintf(stderr, "  libavutil version:   %s\n", AV_STRINGIFY(LIBAVUTIL_VERSION));
       fprintf(stderr, "  libavutil build:     %d\n", LIBAVUTIL_BUILD);
       fprintf(stderr, "  libavcodec version:  %s\n", AV_STRINGIFY(LIBAVCODEC_VERSION));
       fprintf(stdout, "  libavcodec build:    %d\n", LIBAVCODEC_BUILD);
       fprintf(stderr, "  libavformat version: %s\n", AV_STRINGIFY(LIBAVFORMAT_VERSION));
       fprintf(stderr, "  libavformat build:   %d\n", LIBAVFORMAT_BUILD);
       fprintf(stderr, "  built on " __DATE__ " " __TIME__);
    #ifdef __GNUC__
       fprintf(stderr, ", gcc: " __VERSION__ "\n");
    #else
       fprintf(stderr, ", using a non-gcc compiler\n");
    #endif
    }


    static AVStream *add_output_stream(AVFormatContext *output_format_context, AVStream *input_stream) {
       AVCodecContext *input_codec_context;
       AVCodecContext *output_codec_context;
       AVStream *output_stream;

       output_stream = avformat_new_stream(output_format_context, 0);
       if (!output_stream) {
           fprintf(stderr, "Segmenter error: Could not allocate stream\n");
           exit(1);
       }

       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) &amp;&amp; av_q2d(input_stream->time_base) &lt; 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) {
    #ifdef USE_OLD_FFMPEG
           case CODEC_TYPE_AUDIO:
    #else
           case AVMEDIA_TYPE_AUDIO:
    #endif
               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 &amp;&amp; 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;
    #ifdef USE_OLD_FFMPEG
           case CODEC_TYPE_VIDEO:
    #else
           case AVMEDIA_TYPE_VIDEO:
    #endif
               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 &amp; AVFMT_GLOBALHEADER) {
                   output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
               }
               break;
           default:
               break;
       }

       return output_stream;
    }

    int write_index_file(const char index[], const char tmp_index[], const unsigned int planned_segment_duration, const unsigned int actual_segment_duration[],
           const char output_directory[], const char output_prefix[], const char output_file_extension[],
           const unsigned int first_segment, const unsigned int last_segment) {
       FILE *index_fp;
       char *write_buf;
       unsigned int i;

       index_fp = fopen(tmp_index, "w");
       if (!index_fp) {
           fprintf(stderr, "Could not open temporary m3u8 index file (%s), no index file will be created\n", tmp_index);
           return -1;
       }

       write_buf = malloc(sizeof (char) * 1024);
       if (!write_buf) {
           fprintf(stderr, "Could not allocate write buffer for index file, index file will be invalid\n");
           fclose(index_fp);
           return -1;
       }

       unsigned int maxDuration = planned_segment_duration;

       for (i = first_segment; i &lt;= last_segment; i++)
           if (actual_segment_duration[i] > maxDuration)
               maxDuration = actual_segment_duration[i];



       snprintf(write_buf, 1024, "#EXTM3U\n#EXT-X-TARGETDURATION:%u\n", maxDuration);

       if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {
           fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");
           free(write_buf);
           fclose(index_fp);
           return -1;
       }

       for (i = first_segment; i &lt;= last_segment; i++) {
           snprintf(write_buf, 1024, "#EXTINF:%u,\n%s-%u%s\n", actual_segment_duration[i], output_prefix, i, output_file_extension);
           if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {
               fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");
               free(write_buf);
               fclose(index_fp);
               return -1;
           }
       }

       snprintf(write_buf, 1024, "#EXT-X-ENDLIST\n");
       if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {
           fprintf(stderr, "Could not write last file and endlist tag to m3u8 index file\n");
           free(write_buf);
           fclose(index_fp);
           return -1;
       }

       free(write_buf);
       fclose(index_fp);

       return rename(tmp_index, index);
    }

    int main(int argc, const char *argv[]) {
       //input parameters
       char inputFilename[MAX_FILENAME_LENGTH], playlistFilename[MAX_FILENAME_LENGTH], baseDirName[MAX_FILENAME_LENGTH], baseFileName[MAX_FILENAME_LENGTH];
       char baseFileExtension[5]; //either "ts", "aac" or "mp3"
       int segmentLength, outputStreams, verbosity, version;



       char currentOutputFileName[MAX_FILENAME_LENGTH];
       char tempPlaylistName[MAX_FILENAME_LENGTH];


       //these are used to determine the exact length of the current segment
       double prev_segment_time = 0;
       double segment_time;
       unsigned int actual_segment_durations[2048];
       double packet_time = 0;

       //new variables to keep track of output size
       double output_bytes = 0;

       unsigned int output_index = 1;
       AVOutputFormat *ofmt;
       AVFormatContext *ic = NULL;
       AVFormatContext *oc;
       AVStream *video_st = NULL;
       AVStream *audio_st = NULL;
       AVCodec *codec;
       int video_index;
       int audio_index;
       unsigned int first_segment = 1;
       unsigned int last_segment = 0;
       int write_index = 1;
       int decode_done;
       int ret;
       int i;

       unsigned char id3_tag[128];
       unsigned char * image_id3_tag;

       size_t id3_tag_size = 73;
       int newFile = 1; //a boolean value to flag when a new file needs id3 tag info in it

       if (parseCommandLine(inputFilename, playlistFilename, baseDirName, baseFileName, baseFileExtension, &amp;outputStreams, &amp;segmentLength, &amp;verbosity, &amp;version, argc, argv) != 0)
           return 0;

       if (version) {
           ffmpeg_version();
           return 0;
       }


       fprintf(stderr, "%s %s\n", playlistFilename, tempPlaylistName);


       image_id3_tag = malloc(IMAGE_ID3_SIZE);
       if (outputStreams == OUTPUT_STREAM_AUDIO)
           build_image_id3_tag(image_id3_tag);
       build_id3_tag((char *) id3_tag, id3_tag_size);

       snprintf(tempPlaylistName, strlen(playlistFilename) + strlen(baseDirName) + 1, "%s%s", baseDirName, playlistFilename);
       strncpy(playlistFilename, tempPlaylistName, strlen(tempPlaylistName));
       strncpy(tempPlaylistName, playlistFilename, MAX_FILENAME_LENGTH);
       strncat(tempPlaylistName, ".", 1);

       //decide if this is an aac file or a mpegts file.
       //postpone deciding format until later
       /*  ifmt = av_find_input_format("mpegts");
       if (!ifmt)
       {
       fprintf(stderr, "Could not find MPEG-TS demuxer.\n");
       exit(1);
       } */

       av_log_set_level(AV_LOG_DEBUG);

       av_register_all();
       ret = avformat_open_input(&amp;ic, inputFilename, NULL, NULL);
       if (ret != 0) {
           fprintf(stderr, "Could not open input file %s. Error %d.\n", inputFilename, ret);
           exit(1);
       }

       if (avformat_find_stream_info(ic, NULL) &lt; 0) {
           fprintf(stderr, "Could not read stream information.\n");
           exit(1);
       }

       oc = avformat_alloc_context();
       if (!oc) {
           fprintf(stderr, "Could not allocate output context.");
           exit(1);
       }

       video_index = -1;
       audio_index = -1;

       for (i = 0; i &lt; ic->nb_streams &amp;&amp; (video_index &lt; 0 || audio_index &lt; 0); i++) {
           switch (ic->streams[i]->codec->codec_type) {

    #ifdef USE_OLD_FFMPEG
               case CODEC_TYPE_VIDEO:
    #else
               case AVMEDIA_TYPE_VIDEO:
    #endif
                   video_index = i;
                   ic->streams[i]->discard = AVDISCARD_NONE;
                   if (outputStreams &amp; OUTPUT_STREAM_VIDEO)
                       video_st = add_output_stream(oc, ic->streams[i]);
                   break;
    #ifdef USE_OLD_FFMPEG
               case CODEC_TYPE_AUDIO:
    #else
               case AVMEDIA_TYPE_AUDIO:
    #endif
                   audio_index = i;
                   ic->streams[i]->discard = AVDISCARD_NONE;
                   if (outputStreams &amp; OUTPUT_STREAM_AUDIO)
                       audio_st = add_output_stream(oc, ic->streams[i]);
                   break;
               default:
                   ic->streams[i]->discard = AVDISCARD_ALL;
                   break;
           }
       }

       if (video_index == -1) {
           fprintf(stderr, "Stream must have video component.\n");
           exit(1);
       }

       //now that we know the audio and video output streams
       //we can decide on an output format.
       if (outputStreams == OUTPUT_STREAM_AUDIO) {
           //the audio output format should be the same as the audio input format
           switch (ic->streams[audio_index]->codec->codec_id) {
               case CODEC_ID_MP3:
                   fprintf(stderr, "Setting output audio to mp3.");
                   strncpy(baseFileExtension, ".mp3", strlen(".mp3"));
                   ofmt = av_guess_format("mp3", NULL, NULL);
                   break;
               case CODEC_ID_AAC:
                   fprintf(stderr, "Setting output audio to aac.");
                   ofmt = av_guess_format("adts", NULL, NULL);
                   break;
               default:
                   fprintf(stderr, "Codec id %d not supported.\n", ic->streams[audio_index]->id);
           }
           if (!ofmt) {
               fprintf(stderr, "Could not find audio muxer.\n");
               exit(1);
           }
       } else {
           ofmt = av_guess_format("mpegts", NULL, NULL);
           if (!ofmt) {
               fprintf(stderr, "Could not find MPEG-TS muxer.\n");
               exit(1);
           }
       }
       oc->oformat = ofmt;

       if (outputStreams &amp; OUTPUT_STREAM_VIDEO &amp;&amp; oc->oformat->flags &amp; AVFMT_GLOBALHEADER) {
           oc->flags |= CODEC_FLAG_GLOBAL_HEADER;
       }


       /*  Deprecated: pass the options to avformat_write_header directly.
           if (av_set_parameters(oc, NULL) &lt; 0) {
               fprintf(stderr, "Invalid output format parameters.\n");
               exit(1);
           }
        */

       av_dump_format(oc, 0, baseFileName, 1);


       //open the video codec only if there is video data
       if (video_index != -1) {
           if (outputStreams &amp; OUTPUT_STREAM_VIDEO)
               codec = avcodec_find_decoder(video_st->codec->codec_id);
           else
               codec = avcodec_find_decoder(ic->streams[video_index]->codec->codec_id);
           if (!codec) {
               fprintf(stderr, "Could not find video decoder, key frames will not be honored.\n");
           }

           if (outputStreams &amp; OUTPUT_STREAM_VIDEO)
               ret = avcodec_open2(video_st->codec, codec, NULL);
           else
               avcodec_open2(ic->streams[video_index]->codec, codec, NULL);
           if (ret &lt; 0) {
               fprintf(stderr, "Could not open video decoder, key frames will not be honored.\n");
           }
       }

       snprintf(currentOutputFileName, strlen(baseDirName) + strlen(baseFileName) + strlen(baseFileExtension) + 10, "%s%s-%u%s", baseDirName, baseFileName, output_index++, baseFileExtension);

       if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {
           fprintf(stderr, "Could not open &#39;%s&#39;.\n", currentOutputFileName);
           exit(1);
       }
       newFile = 1;

       int r = avformat_write_header(oc,NULL);
       if (r) {
           fprintf(stderr, "Could not write mpegts header to first output file.\n");
           debugReturnCode(r);
           exit(1);
       }

       //no segment info is written here. This just creates the shell of the playlist file
       write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);

       do {
           AVPacket packet;

           decode_done = av_read_frame(ic, &amp;packet);

           if (decode_done &lt; 0) {
               break;
           }

           if (av_dup_packet(&amp;packet) &lt; 0) {
               fprintf(stderr, "Could not duplicate packet.");
               av_free_packet(&amp;packet);
               break;
           }

           //this time is used to check for a break in the segments
           //  if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))
           //  {
           //    segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;        
           //  }
    #if USE_OLD_FFMPEG
           if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))
    #else
           if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; AV_PKT_FLAG_KEY))
    #endif
           {
               segment_time = (double) packet.pts * ic->streams[video_index]->time_base.num / ic->streams[video_index]->time_base.den;
           }
           //  else if (video_index &lt; 0)
           //  {
           //      segment_time = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
           //  }

           //get the most recent packet time
           //this time is used when the time for the final segment is printed. It may not be on the edge of
           //of a keyframe!
           if (packet.stream_index == video_index)
               packet_time = (double) packet.pts * ic->streams[video_index]->time_base.num / ic->streams[video_index]->time_base.den; //(double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
           else if (outputStreams &amp; OUTPUT_STREAM_AUDIO)
               packet_time = (double) audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
           else
               continue;
           //start looking for segment splits for videos one half second before segment duration expires. This is because the
           //segments are split on key frames so we cannot expect all segments to be split exactly equally.
           if (segment_time - prev_segment_time >= segmentLength - 0.5) {
               fprintf(stderr, "looking to print index file at time %lf\n", segment_time);
               avio_flush(oc->pb);
               avio_close(oc->pb);

               if (write_index) {
                   actual_segment_durations[++last_segment] = (unsigned int) rint(segment_time - prev_segment_time);
                   write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);
                   fprintf(stderr, "Writing index file at time %lf\n", packet_time);
               }

               struct stat st;
               stat(currentOutputFileName, &amp;st);
               output_bytes += st.st_size;

               snprintf(currentOutputFileName, strlen(baseDirName) + strlen(baseFileName) + strlen(baseFileExtension) + 10, "%s%s-%u%s", baseDirName, baseFileName, output_index++, baseFileExtension);
               if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {
                   fprintf(stderr, "Could not open &#39;%s&#39;\n", currentOutputFileName);
                   break;
               }

               newFile = 1;
               prev_segment_time = segment_time;
           }

           if (outputStreams == OUTPUT_STREAM_AUDIO &amp;&amp; packet.stream_index == audio_index) {
               if (newFile &amp;&amp; outputStreams == OUTPUT_STREAM_AUDIO) {
                   //add id3 tag info
                   //fprintf(stderr, "adding id3tag to file %s\n", currentOutputFileName);
                   //printf("%lf %lld %lld %lld %lld %lld %lf\n", segment_time, audio_st->pts.val, audio_st->cur_dts, audio_st->cur_pkt.pts, packet.pts, packet.dts, packet.dts * av_q2d(ic->streams[audio_index]->time_base) );
                   fill_id3_tag((char*) id3_tag, id3_tag_size, packet.dts);
                   avio_write(oc->pb, id3_tag, id3_tag_size);
                   avio_write(oc->pb, image_id3_tag, IMAGE_ID3_SIZE);
                   avio_flush(oc->pb);
                   newFile = 0;
               }

               packet.stream_index = 0; //only one stream in audio only segments
               ret = av_interleaved_write_frame(oc, &amp;packet);
           } else if (outputStreams &amp; OUTPUT_STREAM_VIDEO) {
               if (newFile) {
                   //fprintf(stderr, "New File: %lld %lld %lld\n", packet.pts, video_st->pts.val, audio_st->pts.val);
                   //printf("%lf %lld %lld %lld %lld %lld %lf\n", segment_time, audio_st->pts.val, audio_st->cur_dts, audio_st->cur_pkt.pts, packet.pts, packet.dts, packet.dts * av_q2d(ic->streams[audio_index]->time_base) );
                   newFile = 0;
               }
               if (outputStreams == OUTPUT_STREAM_VIDEO)
                   ret = av_write_frame(oc, &amp;packet);
               else
                   ret = av_interleaved_write_frame(oc, &amp;packet);
           }

           if (ret &lt; 0) {
               fprintf(stderr, "Warning: Could not write frame of stream.\n");
           } else if (ret > 0) {
               fprintf(stderr, "End of stream requested.\n");
               av_free_packet(&amp;packet);
               break;
           }

           av_free_packet(&amp;packet);
       } while (!decode_done);

       //make sure all packets are written and then close the last file.
       avio_flush(oc->pb);
       av_write_trailer(oc);

       if (video_st &amp;&amp; video_st->codec)
           avcodec_close(video_st->codec);

       if (audio_st &amp;&amp; audio_st->codec)
           avcodec_close(audio_st->codec);

       for (i = 0; i &lt; oc->nb_streams; i++) {
           av_freep(&amp;oc->streams[i]->codec);
           av_freep(&amp;oc->streams[i]);
       }

       avio_close(oc->pb);
       av_free(oc);

       struct stat st;
       stat(currentOutputFileName, &amp;st);
       output_bytes += st.st_size;


       if (write_index) {
           actual_segment_durations[++last_segment] = (unsigned int) rint(packet_time - prev_segment_time);

           //make sure that the last segment length is not zero
           if (actual_segment_durations[last_segment] == 0)
               actual_segment_durations[last_segment] = 1;

           write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);

       }

       write_stream_size_file(baseDirName, baseFileName, output_bytes * 8 / segment_time);

       return 0;
    }
    </outfile></infile>
  • Updated license link and added package information.

    15 décembre 2011, par Sebastian Tschan

    .gitignore m README.md m application.js m gae-go/app/main.go m gae-python/main.py m index.html m jquery.fileupload-ui.css m jquery.fileupload-ui.js m jquery.fileupload.js m jquery.iframe-transport.js m jquery.postmessage-transport.js m jquery.xdr-transport.js + package.json m php/index.php m (...)