Recherche avancée

Médias (91)

Autres articles (28)

  • Changer son thème graphique

    22 février 2011, par

    Le thème graphique ne touche pas à la disposition à proprement dite des éléments dans la page. Il ne fait que modifier l’apparence des éléments.
    Le placement peut être modifié effectivement, mais cette modification n’est que visuelle et non pas au niveau de la représentation sémantique de la page.
    Modifier le thème graphique utilisé
    Pour modifier le thème graphique utilisé, il est nécessaire que le plugin zen-garden soit activé sur le site.
    Il suffit ensuite de se rendre dans l’espace de configuration du (...)

  • MediaSPIP v0.2

    21 juin 2013, par

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

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

Sur d’autres sites (3833)

  • How can I fix a segmentation fault in a C program ? [duplicate]

    31 mars 2023, 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 without any warnings, although I am getting a segmentation fault error.

    


    How can I fix the issue ? And / or, what is 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 :)

    


    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

    


    /*&#xA; * Copyright (c) 2009 Chase Douglas&#xA; *&#xA; * This program is free software; you can redistribute it and/or&#xA; * modify it under the terms of the GNU General Public License version 2&#xA; * as published by the Free Software Foundation.&#xA; *&#xA; * This program is distributed in the hope that it will be useful,&#xA; * but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&#xA; * GNU General Public License for more details.&#xA; *&#xA; * You should have received a copy of the GNU General Public License&#xA; * along with this program; if not, write to the Free Software&#xA; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.&#xA; */&#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;#include "libavformat/avformat.h"&#xA;&#xA;#include "libavformat/avio.h"&#xA;&#xA;#include <sys></sys>stat.h>&#xA;&#xA;#include "segmenter.h"&#xA;#include "libavformat/avformat.h"&#xA;&#xA;#define IMAGE_ID3_SIZE 9171&#xA;&#xA;void printUsage() {&#xA;    fprintf(stderr, "\nExample: segmenter --i infile --d baseDir --f baseFileName --o playListFile.m3u8 --l 10 \n");&#xA;    fprintf(stderr, "\nOptions: \n");&#xA;    fprintf(stderr, "--i <infile>.\n");&#xA;    fprintf(stderr, "--o <outfile>.\n");&#xA;    fprintf(stderr, "--d basedir, the base directory for files.\n");&#xA;    fprintf(stderr, "--f baseFileName, output files will be baseFileName-#.\n");&#xA;    fprintf(stderr, "--l segment length, the length of each segment.\n");&#xA;    fprintf(stderr, "--a,  audio only decode for &lt; 64k streams.\n");&#xA;    fprintf(stderr, "--v,  video only decode for &lt; 64k streams.\n");&#xA;    fprintf(stderr, "--version, print version details and exit.\n");&#xA;    fprintf(stderr, "\n\n");&#xA;}&#xA;&#xA;void ffmpeg_version() {&#xA;    // output build and version numbers&#xA;    fprintf(stderr, "  libavutil version:   %s\n", AV_STRINGIFY(LIBAVUTIL_VERSION));&#xA;    fprintf(stderr, "  libavutil build:     %d\n", LIBAVUTIL_BUILD);&#xA;    fprintf(stderr, "  libavcodec version:  %s\n", AV_STRINGIFY(LIBAVCODEC_VERSION));&#xA;    fprintf(stdout, "  libavcodec build:    %d\n", LIBAVCODEC_BUILD);&#xA;    fprintf(stderr, "  libavformat version: %s\n", AV_STRINGIFY(LIBAVFORMAT_VERSION));&#xA;    fprintf(stderr, "  libavformat build:   %d\n", LIBAVFORMAT_BUILD);&#xA;    fprintf(stderr, "  built on " __DATE__ " " __TIME__);&#xA;#ifdef __GNUC__&#xA;    fprintf(stderr, ", gcc: " __VERSION__ "\n");&#xA;#else&#xA;    fprintf(stderr, ", using a non-gcc compiler\n");&#xA;#endif&#xA;}&#xA;&#xA;&#xA;static AVStream *add_output_stream(AVFormatContext *output_format_context, AVStream *input_stream) {&#xA;    AVCodecContext *input_codec_context;&#xA;    AVCodecContext *output_codec_context;&#xA;    AVStream *output_stream;&#xA;&#xA;    output_stream = avformat_new_stream(output_format_context, 0);&#xA;    if (!output_stream) {&#xA;        fprintf(stderr, "Segmenter error: Could not allocate stream\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    input_codec_context = input_stream->codec;&#xA;    output_codec_context = output_stream->codec;&#xA;&#xA;    output_codec_context->codec_id = input_codec_context->codec_id;&#xA;    output_codec_context->codec_type = input_codec_context->codec_type;&#xA;    output_codec_context->codec_tag = input_codec_context->codec_tag;&#xA;    output_codec_context->bit_rate = input_codec_context->bit_rate;&#xA;    output_codec_context->extradata = input_codec_context->extradata;&#xA;    output_codec_context->extradata_size = input_codec_context->extradata_size;&#xA;&#xA;    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) {&#xA;        output_codec_context->time_base = input_codec_context->time_base;&#xA;        output_codec_context->time_base.num *= input_codec_context->ticks_per_frame;&#xA;    } else {&#xA;        output_codec_context->time_base = input_stream->time_base;&#xA;    }&#xA;&#xA;    switch (input_codec_context->codec_type) {&#xA;#ifdef USE_OLD_FFMPEG&#xA;        case CODEC_TYPE_AUDIO:&#xA;#else&#xA;        case AVMEDIA_TYPE_AUDIO:&#xA;#endif&#xA;            output_codec_context->channel_layout = input_codec_context->channel_layout;&#xA;            output_codec_context->sample_rate = input_codec_context->sample_rate;&#xA;            output_codec_context->channels = input_codec_context->channels;&#xA;            output_codec_context->frame_size = input_codec_context->frame_size;&#xA;            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) {&#xA;                output_codec_context->block_align = 0;&#xA;            } else {&#xA;                output_codec_context->block_align = input_codec_context->block_align;&#xA;            }&#xA;            break;&#xA;#ifdef USE_OLD_FFMPEG&#xA;        case CODEC_TYPE_VIDEO:&#xA;#else&#xA;        case AVMEDIA_TYPE_VIDEO:&#xA;#endif&#xA;            output_codec_context->pix_fmt = input_codec_context->pix_fmt;&#xA;            output_codec_context->width = input_codec_context->width;&#xA;            output_codec_context->height = input_codec_context->height;&#xA;            output_codec_context->has_b_frames = input_codec_context->has_b_frames;&#xA;&#xA;            if (output_format_context->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;                output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;            }&#xA;            break;&#xA;        default:&#xA;            break;&#xA;    }&#xA;&#xA;    return output_stream;&#xA;}&#xA;&#xA;int write_index_file(const char index[], const char tmp_index[], const unsigned int planned_segment_duration, const unsigned int actual_segment_duration[],&#xA;        const char output_directory[], const char output_prefix[], const char output_file_extension[],&#xA;        const unsigned int first_segment, const unsigned int last_segment) {&#xA;    FILE *index_fp;&#xA;    char *write_buf;&#xA;    unsigned int i;&#xA;&#xA;    index_fp = fopen(tmp_index, "w");&#xA;    if (!index_fp) {&#xA;        fprintf(stderr, "Could not open temporary m3u8 index file (%s), no index file will be created\n", tmp_index);&#xA;        return -1;&#xA;    }&#xA;&#xA;    write_buf = malloc(sizeof (char) * 1024);&#xA;    if (!write_buf) {&#xA;        fprintf(stderr, "Could not allocate write buffer for index file, index file will be invalid\n");&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    unsigned int maxDuration = planned_segment_duration;&#xA;&#xA;    for (i = first_segment; i &lt;= last_segment; i&#x2B;&#x2B;)&#xA;        if (actual_segment_duration[i] > maxDuration)&#xA;            maxDuration = actual_segment_duration[i];&#xA;&#xA;&#xA;&#xA;    snprintf(write_buf, 1024, "#EXTM3U\n#EXT-X-TARGETDURATION:%u\n", maxDuration);&#xA;&#xA;    if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;        fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");&#xA;        free(write_buf);&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    for (i = first_segment; i &lt;= last_segment; i&#x2B;&#x2B;) {&#xA;        snprintf(write_buf, 1024, "#EXTINF:%u,\n%s-%u%s\n", actual_segment_duration[i], output_prefix, i, output_file_extension);&#xA;        if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;            fprintf(stderr, "Could not write to m3u8 index file, will not continue writing to index file\n");&#xA;            free(write_buf);&#xA;            fclose(index_fp);&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    snprintf(write_buf, 1024, "#EXT-X-ENDLIST\n");&#xA;    if (fwrite(write_buf, strlen(write_buf), 1, index_fp) != 1) {&#xA;        fprintf(stderr, "Could not write last file and endlist tag to m3u8 index file\n");&#xA;        free(write_buf);&#xA;        fclose(index_fp);&#xA;        return -1;&#xA;    }&#xA;&#xA;    free(write_buf);&#xA;    fclose(index_fp);&#xA;&#xA;    return rename(tmp_index, index);&#xA;}&#xA;&#xA;int main(int argc, const char *argv[]) {&#xA;    //input parameters&#xA;    char inputFilename[MAX_FILENAME_LENGTH], playlistFilename[MAX_FILENAME_LENGTH], baseDirName[MAX_FILENAME_LENGTH], baseFileName[MAX_FILENAME_LENGTH];&#xA;    char baseFileExtension[5]; //either "ts", "aac" or "mp3"&#xA;    int segmentLength, outputStreams, verbosity, version;&#xA;&#xA;&#xA;&#xA;    char currentOutputFileName[MAX_FILENAME_LENGTH];&#xA;    char tempPlaylistName[MAX_FILENAME_LENGTH];&#xA;&#xA;&#xA;    //these are used to determine the exact length of the current segment&#xA;    double prev_segment_time = 0;&#xA;    double segment_time;&#xA;    unsigned int actual_segment_durations[2048];&#xA;    double packet_time = 0;&#xA;&#xA;    //new variables to keep track of output size&#xA;    double output_bytes = 0;&#xA;&#xA;    unsigned int output_index = 1;&#xA;    AVOutputFormat *ofmt;&#xA;    AVFormatContext *ic = NULL;&#xA;    AVFormatContext *oc;&#xA;    AVStream *video_st = NULL;&#xA;    AVStream *audio_st = NULL;&#xA;    AVCodec *codec;&#xA;    int video_index;&#xA;    int audio_index;&#xA;    unsigned int first_segment = 1;&#xA;    unsigned int last_segment = 0;&#xA;    int write_index = 1;&#xA;    int decode_done;&#xA;    int ret;&#xA;    int i;&#xA;&#xA;    unsigned char id3_tag[128];&#xA;    unsigned char * image_id3_tag;&#xA;&#xA;    size_t id3_tag_size = 73;&#xA;    int newFile = 1; //a boolean value to flag when a new file needs id3 tag info in it&#xA;&#xA;    if (parseCommandLine(inputFilename, playlistFilename, baseDirName, baseFileName, baseFileExtension, &amp;outputStreams, &amp;segmentLength, &amp;verbosity, &amp;version, argc, argv) != 0)&#xA;        return 0;&#xA;&#xA;    if (version) {&#xA;        ffmpeg_version();&#xA;        return 0;&#xA;    }&#xA;&#xA;&#xA;    fprintf(stderr, "%s %s\n", playlistFilename, tempPlaylistName);&#xA;&#xA;&#xA;    image_id3_tag = malloc(IMAGE_ID3_SIZE);&#xA;    if (outputStreams == OUTPUT_STREAM_AUDIO)&#xA;        build_image_id3_tag(image_id3_tag);&#xA;    build_id3_tag((char *) id3_tag, id3_tag_size);&#xA;&#xA;    snprintf(tempPlaylistName, strlen(playlistFilename) &#x2B; strlen(baseDirName) &#x2B; 1, "%s%s", baseDirName, playlistFilename);&#xA;    strncpy(playlistFilename, tempPlaylistName, strlen(tempPlaylistName));&#xA;    strncpy(tempPlaylistName, playlistFilename, MAX_FILENAME_LENGTH);&#xA;    strncat(tempPlaylistName, ".", 1);&#xA;&#xA;    //decide if this is an aac file or a mpegts file.&#xA;    //postpone deciding format until later&#xA;    /*    ifmt = av_find_input_format("mpegts");&#xA;    if (!ifmt)&#xA;    {&#xA;    fprintf(stderr, "Could not find MPEG-TS demuxer.\n");&#xA;    exit(1);&#xA;    } */&#xA;&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;&#xA;    av_register_all();&#xA;    ret = avformat_open_input(&amp;ic, inputFilename, NULL, NULL);&#xA;    if (ret != 0) {&#xA;        fprintf(stderr, "Could not open input file %s. Error %d.\n", inputFilename, ret);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(ic, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not read stream information.\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    oc = avformat_alloc_context();&#xA;    if (!oc) {&#xA;        fprintf(stderr, "Could not allocate output context.");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    video_index = -1;&#xA;    audio_index = -1;&#xA;&#xA;    for (i = 0; i &lt; ic->nb_streams &amp;&amp; (video_index &lt; 0 || audio_index &lt; 0); i&#x2B;&#x2B;) {&#xA;        switch (ic->streams[i]->codec->codec_type) {&#xA;&#xA;#ifdef USE_OLD_FFMPEG&#xA;            case CODEC_TYPE_VIDEO:&#xA;#else&#xA;            case AVMEDIA_TYPE_VIDEO:&#xA;#endif&#xA;                video_index = i;&#xA;                ic->streams[i]->discard = AVDISCARD_NONE;&#xA;                if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;                    video_st = add_output_stream(oc, ic->streams[i]);&#xA;                break;&#xA;#ifdef USE_OLD_FFMPEG&#xA;            case CODEC_TYPE_AUDIO:&#xA;#else&#xA;            case AVMEDIA_TYPE_AUDIO:&#xA;#endif&#xA;                audio_index = i;&#xA;                ic->streams[i]->discard = AVDISCARD_NONE;&#xA;                if (outputStreams &amp; OUTPUT_STREAM_AUDIO)&#xA;                    audio_st = add_output_stream(oc, ic->streams[i]);&#xA;                break;&#xA;            default:&#xA;                ic->streams[i]->discard = AVDISCARD_ALL;&#xA;                break;&#xA;        }&#xA;    }&#xA;&#xA;    if (video_index == -1) {&#xA;        fprintf(stderr, "Stream must have video component.\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    //now that we know the audio and video output streams&#xA;    //we can decide on an output format.&#xA;    if (outputStreams == OUTPUT_STREAM_AUDIO) {&#xA;        //the audio output format should be the same as the audio input format&#xA;        switch (ic->streams[audio_index]->codec->codec_id) {&#xA;            case CODEC_ID_MP3:&#xA;                fprintf(stderr, "Setting output audio to mp3.");&#xA;                strncpy(baseFileExtension, ".mp3", strlen(".mp3"));&#xA;                ofmt = av_guess_format("mp3", NULL, NULL);&#xA;                break;&#xA;            case CODEC_ID_AAC:&#xA;                fprintf(stderr, "Setting output audio to aac.");&#xA;                ofmt = av_guess_format("adts", NULL, NULL);&#xA;                break;&#xA;            default:&#xA;                fprintf(stderr, "Codec id %d not supported.\n", ic->streams[audio_index]->id);&#xA;        }&#xA;        if (!ofmt) {&#xA;            fprintf(stderr, "Could not find audio muxer.\n");&#xA;            exit(1);&#xA;        }&#xA;    } else {&#xA;        ofmt = av_guess_format("mpegts", NULL, NULL);&#xA;        if (!ofmt) {&#xA;            fprintf(stderr, "Could not find MPEG-TS muxer.\n");&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;    oc->oformat = ofmt;&#xA;&#xA;    if (outputStreams &amp; OUTPUT_STREAM_VIDEO &amp;&amp; oc->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;        oc->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;&#xA;    /*  Deprecated: pass the options to avformat_write_header directly.&#xA;        if (av_set_parameters(oc, NULL) &lt; 0) {&#xA;            fprintf(stderr, "Invalid output format parameters.\n");&#xA;            exit(1);&#xA;        }&#xA;     */&#xA;&#xA;    av_dump_format(oc, 0, baseFileName, 1);&#xA;&#xA;&#xA;    //open the video codec only if there is video data&#xA;    if (video_index != -1) {&#xA;        if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;            codec = avcodec_find_decoder(video_st->codec->codec_id);&#xA;        else&#xA;            codec = avcodec_find_decoder(ic->streams[video_index]->codec->codec_id);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Could not find video decoder, key frames will not be honored.\n");&#xA;        }&#xA;&#xA;        if (outputStreams &amp; OUTPUT_STREAM_VIDEO)&#xA;            ret = avcodec_open2(video_st->codec, codec, NULL);&#xA;        else&#xA;            avcodec_open2(ic->streams[video_index]->codec, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open video decoder, key frames will not be honored.\n");&#xA;        }&#xA;    }&#xA;&#xA;    snprintf(currentOutputFileName, strlen(baseDirName) &#x2B; strlen(baseFileName) &#x2B; strlen(baseFileExtension) &#x2B; 10, "%s%s-%u%s", baseDirName, baseFileName, output_index&#x2B;&#x2B;, baseFileExtension);&#xA;&#xA;    if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {&#xA;        fprintf(stderr, "Could not open &#x27;%s&#x27;.\n", currentOutputFileName);&#xA;        exit(1);&#xA;    }&#xA;    newFile = 1;&#xA;&#xA;    int r = avformat_write_header(oc,NULL);&#xA;    if (r) {&#xA;        fprintf(stderr, "Could not write mpegts header to first output file.\n");&#xA;        debugReturnCode(r);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    //no segment info is written here. This just creates the shell of the playlist file&#xA;    write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;&#xA;    do {&#xA;        AVPacket packet;&#xA;&#xA;        decode_done = av_read_frame(ic, &amp;packet);&#xA;&#xA;        if (decode_done &lt; 0) {&#xA;            break;&#xA;        }&#xA;&#xA;        if (av_dup_packet(&amp;packet) &lt; 0) {&#xA;            fprintf(stderr, "Could not duplicate packet.");&#xA;            av_free_packet(&amp;packet);&#xA;            break;&#xA;        }&#xA;&#xA;        //this time is used to check for a break in the segments&#xA;        //    if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))&#xA;        //    {&#xA;        //    segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;&#xA;        //    }&#xA;#if USE_OLD_FFMPEG&#xA;        if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; PKT_FLAG_KEY))&#xA;#else&#xA;        if (packet.stream_index == video_index &amp;&amp; (packet.flags &amp; AV_PKT_FLAG_KEY))&#xA;#endif&#xA;        {&#xA;            segment_time = (double) packet.pts * ic->streams[video_index]->time_base.num / ic->streams[video_index]->time_base.den;&#xA;        }&#xA;        //  else if (video_index &lt; 0)&#xA;        //    {&#xA;        //        segment_time = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;&#xA;        //    }&#xA;&#xA;        //get the most recent packet time&#xA;        //this time is used when the time for the final segment is printed. It may not be on the edge of&#xA;        //of a keyframe!&#xA;        if (packet.stream_index == video_index)&#xA;            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;&#xA;        else if (outputStreams &amp; OUTPUT_STREAM_AUDIO)&#xA;            packet_time = (double) audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;&#xA;        else&#xA;            continue;&#xA;        //start looking for segment splits for videos one half second before segment duration expires. This is because the&#xA;        //segments are split on key frames so we cannot expect all segments to be split exactly equally.&#xA;        if (segment_time - prev_segment_time >= segmentLength - 0.5) {&#xA;            fprintf(stderr, "looking to print index file at time %lf\n", segment_time);&#xA;            avio_flush(oc->pb);&#xA;            avio_close(oc->pb);&#xA;&#xA;            if (write_index) {&#xA;                actual_segment_durations[&#x2B;&#x2B;last_segment] = (unsigned int) rint(segment_time - prev_segment_time);&#xA;                write_index = !write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;                fprintf(stderr, "Writing index file at time %lf\n", packet_time);&#xA;            }&#xA;&#xA;            struct stat st;&#xA;            stat(currentOutputFileName, &amp;st);&#xA;            output_bytes &#x2B;= st.st_size;&#xA;&#xA;            snprintf(currentOutputFileName, strlen(baseDirName) &#x2B; strlen(baseFileName) &#x2B; strlen(baseFileExtension) &#x2B; 10, "%s%s-%u%s", baseDirName, baseFileName, output_index&#x2B;&#x2B;, baseFileExtension);&#xA;            if (avio_open(&amp;oc->pb, currentOutputFileName, URL_WRONLY) &lt; 0) {&#xA;                fprintf(stderr, "Could not open &#x27;%s&#x27;\n", currentOutputFileName);&#xA;                break;&#xA;            }&#xA;&#xA;            newFile = 1;&#xA;            prev_segment_time = segment_time;&#xA;        }&#xA;&#xA;        if (outputStreams == OUTPUT_STREAM_AUDIO &amp;&amp; packet.stream_index == audio_index) {&#xA;            if (newFile &amp;&amp; outputStreams == OUTPUT_STREAM_AUDIO) {&#xA;                //add id3 tag info&#xA;                //fprintf(stderr, "adding id3tag to file %s\n", currentOutputFileName);&#xA;                //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) );&#xA;                fill_id3_tag((char*) id3_tag, id3_tag_size, packet.dts);&#xA;                avio_write(oc->pb, id3_tag, id3_tag_size);&#xA;                avio_write(oc->pb, image_id3_tag, IMAGE_ID3_SIZE);&#xA;                avio_flush(oc->pb);&#xA;                newFile = 0;&#xA;            }&#xA;&#xA;            packet.stream_index = 0; //only one stream in audio only segments&#xA;            ret = av_interleaved_write_frame(oc, &amp;packet);&#xA;        } else if (outputStreams &amp; OUTPUT_STREAM_VIDEO) {&#xA;            if (newFile) {&#xA;                //fprintf(stderr, "New File: %lld %lld %lld\n", packet.pts, video_st->pts.val, audio_st->pts.val);&#xA;                //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) );&#xA;                newFile = 0;&#xA;            }&#xA;            if (outputStreams == OUTPUT_STREAM_VIDEO)&#xA;                ret = av_write_frame(oc, &amp;packet);&#xA;            else&#xA;                ret = av_interleaved_write_frame(oc, &amp;packet);&#xA;        }&#xA;&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Warning: Could not write frame of stream.\n");&#xA;        } else if (ret > 0) {&#xA;            fprintf(stderr, "End of stream requested.\n");&#xA;            av_free_packet(&amp;packet);&#xA;            break;&#xA;        }&#xA;&#xA;        av_free_packet(&amp;packet);&#xA;    } while (!decode_done);&#xA;&#xA;    //make sure all packets are written and then close the last file.&#xA;    avio_flush(oc->pb);&#xA;    av_write_trailer(oc);&#xA;&#xA;    if (video_st &amp;&amp; video_st->codec)&#xA;        avcodec_close(video_st->codec);&#xA;&#xA;    if (audio_st &amp;&amp; audio_st->codec)&#xA;        avcodec_close(audio_st->codec);&#xA;&#xA;    for (i = 0; i &lt; oc->nb_streams; i&#x2B;&#x2B;) {&#xA;        av_freep(&amp;oc->streams[i]->codec);&#xA;        av_freep(&amp;oc->streams[i]);&#xA;    }&#xA;&#xA;    avio_close(oc->pb);&#xA;    av_free(oc);&#xA;&#xA;    struct stat st;&#xA;    stat(currentOutputFileName, &amp;st);&#xA;    output_bytes &#x2B;= st.st_size;&#xA;&#xA;&#xA;    if (write_index) {&#xA;        actual_segment_durations[&#x2B;&#x2B;last_segment] = (unsigned int) rint(packet_time - prev_segment_time);&#xA;&#xA;        //make sure that the last segment length is not zero&#xA;        if (actual_segment_durations[last_segment] == 0)&#xA;            actual_segment_durations[last_segment] = 1;&#xA;&#xA;        write_index_file(playlistFilename, tempPlaylistName, segmentLength, actual_segment_durations, baseDirName, baseFileName, baseFileExtension, first_segment, last_segment);&#xA;&#xA;    }&#xA;&#xA;    write_stream_size_file(baseDirName, baseFileName, output_bytes * 8 / segment_time);&#xA;&#xA;    return 0;&#xA;}&#xA;</outfile></infile>

    &#xA;

  • What is Audience Segmentation ? The 5 Main Types & Examples

    16 novembre 2023, par Erin — Analytics Tips

    The days of mass marketing with the same message for millions are long gone. Today, savvy marketers instead focus on delivering the most relevant message to the right person at the right time.

    They do this at scale by segmenting their audiences based on various data points. This isn’t an easy process because there are many types of audience segmentation. If you take the wrong approach, you risk delivering irrelevant messages to your audience — or breaking their trust with poor data management.

    In this article, we’ll break down the most common types of audience segmentation, share examples highlighting their usefulness and cover how you can segment campaigns without breaking data regulations.

    What is audience segmentation ?

    Audience segmentation is when you divide your audience into multiple smaller specific audiences based on various factors. The goal is to deliver a more targeted marketing message or to glean unique insights from analytics.

    It can be as broad as dividing a marketing campaign by location or as specific as separating audiences by their interests, hobbies and behaviour.

    Illustration of basic audience segmentation

    Audience segmentation inherently makes a lot of sense. Consider this : an urban office worker and a rural farmer have vastly different needs. By targeting your marketing efforts towards agriculture workers in rural areas, you’re honing in on a group more likely to be interested in farm equipment. 

    Audience segmentation has existed since the beginning of marketing. Advertisers used to select magazines and placements based on who typically read them. They would run a golf club ad in a golf magazine, not in the national newspaper.

    How narrow you can make your audience segments by leveraging multiple data points has changed.

    Why audience segmentation matters

    In a survey by McKinsey, 71% of consumers said they expected personalisation, and 76% get frustrated when a vendor doesn’t deliver.

    Illustrated statistics that show the importance of personalisation

    These numbers reflect expectations from consumers who have actively engaged with a brand — created an account, signed up for an email list or purchased a product.

    They expect you to take that data and give them relevant product recommendations — like a shoe polishing kit if you bought nice leather loafers.

    If you don’t do any sort of audience segmentation, you’re likely to frustrate your customers with post-sale campaigns. If, for example, you just send the same follow-up email to all customers, you’d damage many relationships. Some might ask : “What ? Why would you think I need that ?” Then they’d promptly opt out of your email marketing campaigns.

    To avoid that, you need to segment your audience so you can deliver relevant content at all stages of the customer journey.

    5 key types of audience segmentation

    To help you deliver the right content to the right person or identify crucial insights in analytics, you can use five types of audience segmentation : demographic, behavioural, psychographic, technographic and transactional.

    Diagram of the main types of audience segmentation

    Demographic segmentation 

    Demographic segmentation is when you segment a larger audience based on demographic data points like location, age or other factors.

    The most basic demographic segmentation factor is location, which is easy to leverage in marketing efforts. For example, geographic segmentation can use IP addresses and separate marketing efforts by country. 

    But more advanced demographic data points are becoming increasingly sensitive to handle. Especially in Europe, GDPR makes advanced demographics a more tentative subject. Using age, education level and employment to target marketing campaigns is possible. But you need to navigate this terrain thoughtfully and responsibly, ensuring meticulous adherence to privacy regulations.

    Potential data points :

    • Location
    • Age
    • Marital status
    • Income
    • Employment 
    • Education

    Example of effective demographic segmentation :

    A clothing brand targeting diverse locations needs to account for the varying weather conditions. In colder regions, showcasing winter collections or insulated clothing might resonate more with the audience. Conversely, in warmer climates, promoting lightweight or summer attire could be more effective. 

    Here are two ads run by North Face on Facebook and Instagram to different audiences to highlight different collections :

    Each collection is featured differently and uses a different approach with its copy and even the media. With social media ads, targeting people based on advanced demographics is simple enough — you can just single out the factors when making your campaign. But if you don’t want to rely on these data-mining companies, that doesn’t mean you have no options for segmentation.

    Consider allowing people to self-select their interests or preferences by incorporating a short survey within your email sign-up form. This simple addition can enhance engagement, decrease bounce rates, and ultimately improve conversion rates, offering valuable insights into audience preferences.

    This is a great way to segment ethically and without the need of data-mining companies.

    Behavioural segmentation

    Behavioural segmentation segments audiences based on their interaction with your website or app.

    You use various data points to segment your target audience based on their actions.

    Potential data points :

    • Page visits
    • Referral source
    • Clicks
    • Downloads
    • Video plays
    • Goal completion (e.g., signing up for a newsletter or purchasing a product)

    Example of using behavioural segmentation to improve campaign efficiency :

    One effective method involves using a web analytics tool such as Matomo to uncover patterns. By segmenting actions like specific clicks and downloads, pinpoint valuable trends—identifying actions that significantly enhance visitor conversions. 

    Example of a segmented behavioral analysis in Matomo

    For instance, if a case study video substantially boosts conversion rates, elevate its prominence to capitalise on this success.

    Then, you can set up a conditional CTA within the video player. Make it pop up after the user has watched the entire video. Use a specific form and sign them up to a specific segment for each case study. This way, you know the prospect’s ideal use case without surveying them.

    This is an example of behavioural segmentation that doesn’t rely on third-party cookies.

    Psychographic segmentation

    Psychographic segmentation is when you segment audiences based on your interpretation of their personality or preferences.

    Potential data points :

    • Social media patterns
    • Follows
    • Hobbies
    • Interests

    Example of effective psychographic segmentation :

    Here, Adidas segments its audience based on whether they like cycling or rugby. It makes no sense to show a rugby ad to someone who’s into cycling and vice versa. But to rugby athletes, the ad is very relevant.

    If you want to avoid social platforms, you can use surveys about hobbies and interests to segment your target audience in an ethical way.

    Technographic segmentation

    Technographic segmentation is when you single out specific parts of your audience based on which hardware or software they use.

    Potential data points :

    • Type of device used
    • Device model or brand
    • Browser used

    Example of segmenting by device type to improve user experience :

    Upon noticing a considerable influx of tablet users accessing their platform, a leading news outlet decided to optimise their tablet browsing experience. They overhauled the website interface, focusing on smoother navigation and better readability for tablet users. These changes offered tablet users a seamless and enjoyable reading experience tailored precisely to their device.

    Transactional segmentation

    Transactional segmentation is when you use your customers’ purchase history to better target your marketing message to their needs.

    When consumers prefer personalisation, they typically mean based on their actual transactions, not their social media profiles.

    Potential data points :

    • Average order value
    • Product categories purchased within X months
    • X days since the last purchase of a consumable product

    Example of effective transactional segmentation :

    A pet supply store identifies a segment of customers consistently purchasing cat food but not other pet products. They create targeted email campaigns offering discounts or loyalty rewards specifically for cat-related items to encourage repeat purchases within this segment.

    If you want to improve customer loyalty and increase revenue, the last thing you should do is send generic marketing emails. Relevant product recommendations or coupons are the best way to use transactional segmentation.

    B2B-specific : Firmographic segmentation

    Beyond the five main segmentation types, B2B marketers often use “firmographic” factors when segmenting their campaigns. It’s a way to segment campaigns that go beyond the considerations of the individual.

    Potential data points :

    • Company size
    • Number of employees
    • Company industry
    • Geographic location (office)

    Example of effective firmographic segmentation :

    Companies of different sizes won’t need the same solution — so segmenting leads by company size is one of the most common and effective examples of B2B audience segmentation.

    The difference here is that B2B campaigns are often segmented through manual research. With an account-based marketing approach, you start by researching your potential customers. You then separate the target audience into smaller segments (or even a one-to-one campaign).

    Start segmenting and analysing your audience more deeply with Matomo

    Segmentation is a great place to start if you want to level up your marketing efforts. Modern consumers expect to get relevant content, and you must give it to them.

    But doing so in a privacy-sensitive way is not always easy. You need the right approach to segment your customer base without alienating them or breaking regulations.

    That’s where Matomo comes in. Matomo champions privacy compliance while offering comprehensive insights and segmentation capabilities. With robust privacy controls and cookieless configuration, it ensures GDPR and other regulations are met, empowering data-driven decisions without compromising user privacy.

    Take advantage of our 21-day free trial to get insights that can help you improve your marketing strategy and better reach your target audience. No credit card required.

  • Web Analytics Reports : 10 Key Types and How to Use Them

    29 janvier 2024, par Erin

    You can’t optimise your website to drive better results if you don’t know how visitors are engaging with your site.

    But how do you correctly analyse data and identify patterns ? With the right platform, you can use a wide range of web analytics reports to dive deep into the data.

    In this article, we’ll discuss what website analytics reports are, different types, why you need them, and how to use reports to find the insights you need.

    What is web analytics ?

    Website analytics is the process of gathering, processing, and analysing data that shows what users are doing when they visit your website. 

    You typically achieve this with web analytics tools by adding a tracking code that shares data with the analytics platform when someone visits the site.

    Illustration of how website analytics works

    The visitors trigger the tracking code, which collects data on how they act while on your site and then sends that information to the analytics platform. You can then see the data in your analytics solution and create reports based on this data.

    While there are a lot of web analytics solutions available, this article will specifically demonstrate reports using Matomo.

    What are web analytics reports ?

    Web analytics reports are analyses that focus on specific data points within your analytics platform. 

    For example, this channel report in Matomo shows the top referring channels of a website.

    Channel types report in Matomo analytics

    Your marketing team can use this report to determine which channels drive the best results. In the example above, organic search drives almost double the visits and actions of social campaigns. 

    If you’re investing the same amount of money, you’d want to move more of your budget from social to search.

    Why you need to get familiar with specific web analytics reports

    The default web analytics dashboard offers an overview of high-level trends in performance. However, it usually does not give you specific insights that can help you optimise your marketing campaigns.

    For example, you can see that your conversions are down month over month. But, at a glance, you do not understand why that is.

    To understand why, you need to go granular and wider — looking into qualifying data that separates different types of visitors from each other.

    Gartner predicts that 70% of organisations will focus on “small and wide” data by 2025 over “big data.” Most companies lack the data volume to simply let big data and algorithms handle the optimising.

    What you can do instead is dive deep into each visitor. Figure out how they engage with your site, and then you can adjust your campaigns and page content accordingly.

    Common types of web analytics reports

    There are dozens of different web analytics reports, but they usually fall into four separate categories :

    Diagram that illustrates the main types of web analytics reports
    • Referral sources : These reports show where your visitors come from. They range from channel reports — search, social media — to specific campaigns and ads.
    • Engagement (on-site actions) : These reports dive into what visitors are doing on your site. They break down clicks, scrolling, completed conversion goals, and more.
    • E-commerce performance : These reports show the performance of your e-commerce store. They’ll help you dive into the sales of individual products, trends in cart abandonment and more.
    • Demographics : These reports help you understand more about your visitors — where they’re visiting from, their browser language, device, and more.

    You can even combine insights across all four using audience segmentation and custom reports. (We’ll cover this in more detail later.)

    How to use 10 important website analytics reports

    The first step is to install the website analytics code on your website. (We include more detailed information in our guide on how to track website visitors.)

    Then, you need to wait until you have a few days (or, if you have limited traffic, a few weeks) of data. Without sufficient website visitor data, none of the reports will be meaningful.

    Visitor Overview report

    First, let’s take a look at the Visitor Overview report. It’s a general report that breaks down the visits over a given time period.

    Visitor overview report in Matomo

    What this report shows :

    • Trends in unique visits month over month
    • Basic engagement trends like the average visit length and bounce rate
    • The number of actions taken per page

    In general, this report is more of a high-level indicator you can use to explore certain areas more thoroughly. For example, if most of your traffic comes from organic traffic or social media, you can dive deeper into those channels.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    Location report

    Next up, we have the most basic type of demographic report — the Location report. It shows where your visitors tend to access your website from.

    Location report in Matomo

    What this report shows :

    • The country, state or city your visitors access your website from

    This report is most useful for identifying regional trends. You may notice that your site is growing in popularity in a country. You can take advantage of this by creating a regional campaign to double down on a high performing audience.

    Device report

    Next, we have the Device report, which breaks down your visitors’ devices.

    Device report in Matomo analytics

    What this report shows :

    • Overall device types used by your visitors
    • Specific device models used

    Today, most websites are responsive or use mobile-first design. So, just seeing that many people access your site through smartphones probably isn’t all that surprising.

    But you should ensure your responsive design doesn’t break down on popular devices. The design may not work effectively because many phones have different screen resolutions. 

    Users Flow report

    The Users Flow report dives deeper into visitor engagement — how your visitors act on your site. It shows common landing pages — the first page visitors land on — and how they usually navigate your site from there.

    Users flow report in Matomo analytics

    What this report shows :

    • Popular landing pages
    • How your visitors most commonly navigate your site

    You can use this report to determine which intermediary pages are crucial to keeping visitors engaged. For example, you can prioritise optimisation and rewriting for case study pages that don’t get a lot of direct search or campaign traffic.

    Improving this flow can improve conversion rates and the impact of your marketing efforts.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    Exit Pages report

    The Exit Pages report complements the Users Flow report well. It highlights the most common pages visitors leave your website from.

    Exit pages report in Matomo analytics

    What this report shows :

    • The most common exit pages on your website
    • The exit rates of these pages

    Pages with high exit rates fall into two categories. The first are pages where it makes sense that visitors leave, like a post-purchase thank-you page. The second are pages where you’d want your visitors to stay and keep flowing down the funnel. When the rates are unusually high on product pages, category pages, or case study pages, you may have found a problem.

    By combining insights from the Users Flow and Exit Pages reports, you can find valuable candidates for optimisation. This is a key aspect of effective conversion rate optimisation.

    Traffic Acquisition Channel report

    The Acquisition Channels report highlights the channels that drive the most visitors to your site.

    Acquisition report in Matomo analytics

    What this report shows :

    • Top referring traffic sources by channel type
    • The average time on site, bounce rates, and actions taken by the source

    Because of increasingly privacy-sensitive browsers and apps, the best way to reliably track traffic sources is to use campaign tracking URL. Matomo offers an easy-to-use campaign tracking URL builder to simplify this process.

    Search Engines and Keywords report

    The Search Engines and Keywords report shows which keywords are driving the most organic search traffic and from what search engines.

    Search engine keyword report in Matomo analytics

    What this report shows :

    • Search engine keywords that drive traffic
    • The different search engines that refer visitors

    One of the best ways to use this report is to identify low-hanging fruit. You want to find keywords driving some traffic where your page isn’t ranked in the top three results. If the keyword has high traffic potential, you should then work to optimise that page to rank higher and get more traffic. This technique is an efficient way to improve your SEO performance.

    Ecommerce Products report

    If you sell products directly on your website, the Ecommerce Products report is a lifesaver. It shows you exactly how all your products are performing.

    Ecommerce product report in Matomo analytics

    What this report shows :

    • How your products are selling
    • The average sale price (with coupons) and quantity

    This report could help an online retailer identify top-selling items, adjust pricing based on average sale prices, and strategically allocate resources to promote or restock high-performing products for maximum profitability.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    Ecommerce Log report

    If you want to explore every single ecommerce interaction, the Ecommerce Log report is for you. It breaks down the actions of visitors who add products to their cart in real time.

    Ecommerce log report in Matomo analytics

    What this report shows :

    • The full journey of completed purchases and abandoned carts
    • The exact actions your potential customers take and how long their journeys last

    If you suspect that the user experience of your online store isn’t perfect, this report helps you confirm or deny that suspicion. By closely examining individual interactions, you can identify common exit pages or other issues.