Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (52)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

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

  • Play video using HTML5 video tag

    21 janvier 2014, par user3217695

    Hi i need to display video in all the browsers using html5.

    I am uploading the file and creating html structure and it plays only mp4 format video, but not other uploaded formats, and i use command line to convert files but the converted files doesn't play in video tag.

    For conversion I use ffmpeg video conversion from one to webm format. Conversion works, but viedos don't play.

    Please find me ffmpeg code, which converts all videos to webm, so i can play the converted video using html5.

  • rtmp : Support play method in listen mode

    15 septembre 2013, par Luca Barbato
    rtmp : Support play method in listen mode
    
    • [DBH] libavformat/rtmpproto.c
  • How to play audio using libao and FFmpeg in C ?

    12 mars 2024, par OmegaLol21

    I am trying to create a simple prototype application that opens a video file and plays its audio. I am using the FFmpeg libraries (libavcodec, libavformat, etc) to open and decode the video, and I am attempting to use libao to play the audio. I tried looking up code examples but a lot of them either don't work or use deprecated functions.

    


    So far, I managed to come up with this :

    


    #include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswresample></libswresample>swresample.h>&#xA;#include <ao></ao>ao.h>&#xA;&#xA;int main(int argc, char** argv) {&#xA;    AVFormatContext* format_ctx = avformat_alloc_context();&#xA;    int audio_stream_index = -1;&#xA;    AVCodecContext* codec_ctx = NULL;&#xA;    AVCodec* codec = NULL;&#xA;    AVPacket packet;&#xA;    AVFrame* frame = NULL;&#xA;    ao_device* device = NULL;&#xA;    ao_sample_format sample_format;&#xA;    uint8_t* output_buffer = NULL;&#xA;    int output_linesize;&#xA;&#xA;    avformat_open_input(&amp;format_ctx, "test.mp4", NULL, NULL);&#xA;    avformat_find_stream_info(format_ctx, NULL);&#xA;&#xA;    for (int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            audio_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    codec_ctx = avcodec_alloc_context3(NULL);&#xA;    avcodec_parameters_to_context(codec_ctx, format_ctx->streams[audio_stream_index]->codecpar);&#xA;    codec = avcodec_find_decoder(codec_ctx->codec_id);&#xA;    avcodec_open2(codec_ctx, codec, NULL);&#xA;&#xA;    // Initialize libao&#xA;    ao_initialize();&#xA;    int driver_id = ao_default_driver_id();&#xA;&#xA;    sample_format.bits = 16;&#xA;    sample_format.channels = 2;&#xA;    sample_format.rate = 44100;&#xA;    sample_format.byte_format = AO_FMT_NATIVE;&#xA;    sample_format.matrix = 0;&#xA;    device = ao_open_live(driver_id, &amp;sample_format, NULL);&#xA;    if (!device) {&#xA;        fprintf(stderr, "Could not open audio device\n");&#xA;        return 1;&#xA;    }&#xA;&#xA;    frame = av_frame_alloc();&#xA;&#xA;    while (av_read_frame(format_ctx, &amp;packet) >= 0) {&#xA;        if (packet.stream_index == audio_stream_index) {&#xA;            int ret = avcodec_send_packet(codec_ctx, &amp;packet);&#xA;            if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error sending packet for decoding\n");&#xA;                break;&#xA;            }&#xA;&#xA;            while (ret >= 0) {&#xA;                ret = avcodec_receive_frame(codec_ctx, frame);&#xA;                if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                    break;&#xA;                }&#xA;                else if (ret &lt; 0) {&#xA;                    fprintf(stderr, "Error during decoding\n");&#xA;                    break;&#xA;                }&#xA;&#xA;                ao_play(device, (char*)frame->data[0], frame->nb_samples * 2 * frame->channels);&#xA;            }&#xA;        }&#xA;        av_packet_unref(&amp;packet);&#xA;    }&#xA;&#xA;    // Clean up&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_close_input(&amp;format_ctx);&#xA;    ao_close(device);&#xA;    ao_shutdown();&#xA;    av_freep(&amp;output_buffer);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    This is the closest I have gotten to play audio. It plays audio but there is a lot of static sound in the background. I did try using using frame->linesize[0] for num_bytes in ao_play but that didn't produce a sound that sounded at all like the video.

    &#xA;

    Is there something I am doing wrong or missing ?

    &#xA;

    EDIT : While doing more testing, I managed to find out that the above code sample outputs pure static in the left speaker, however, in the right speaker, it does play the audio, albeit heavily distorted ?

    &#xA;