Recherche avancée

Médias (39)

Mot : - Tags -/audio

Autres articles (23)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

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

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (5870)

  • No Audio in Recorded File from IP Camera using ffmpeg

    26 janvier, par LeXela-ED

    I'm trying to record video and audio from an IP camera equipped with a microphone. Below is a simplified version of my code, which compiles and runs without errors :

    


    #include <libavformat></libavformat>avformat.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include &#xA;#include &#xA;&#xA;#define AUDIO_CODEC "aac"&#xA;&#xA;void log_error(const char *message, int error_code) {&#xA;    char error_buffer[AV_ERROR_MAX_STRING_SIZE];&#xA;    av_strerror(error_code, error_buffer, sizeof(error_buffer));&#xA;    fprintf(stderr, "%s: %s\n", message, error_buffer);&#xA;    exit(1);&#xA;}&#xA;&#xA;int main(int argc, char *argv[]) {&#xA;     const char *input_url = "rtsp://admin:123456@192.168.1.99:554/mode=real&amp;idc=1&amp;ids=1";&#xA;    const char *output_file = "D:/abc.ts"; // MPEG-TS file&#xA;&#xA;    avformat_network_init();&#xA;&#xA;    AVFormatContext *input_ctx = NULL;&#xA;    AVFormatContext *output_ctx = NULL;&#xA;    AVStream *video_stream = NULL, *audio_stream = NULL;&#xA;    AVCodecContext *audio_codec_ctx = NULL;&#xA;    AVCodec *audio_codec = NULL;&#xA;    int ret;&#xA;&#xA;    // Open input stream&#xA;    if ((ret = avformat_open_input(&amp;input_ctx, input_url, NULL, NULL)) &lt; 0) {&#xA;        log_error("Failed to open input", ret);&#xA;    }&#xA;&#xA;    if ((ret = avformat_find_stream_info(input_ctx, NULL)) &lt; 0) {&#xA;        log_error("Failed to find stream info", ret);&#xA;    }&#xA;&#xA;    // Find video and audio streams&#xA;    int video_stream_index = -1, audio_stream_index = -1;&#xA;    for (int i = 0; i &lt; input_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (input_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            video_stream_index = i;&#xA;        } else if (input_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            audio_stream_index = i;&#xA;        }&#xA;    }&#xA;&#xA;    if (video_stream_index == -1) {&#xA;        fprintf(stderr, "No video stream found\n");&#xA;        exit(1);&#xA;    }&#xA;    if (audio_stream_index == -1) {&#xA;        fprintf(stderr, "No audio stream found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Allocate output context&#xA;    avformat_alloc_output_context2(&amp;output_ctx, NULL, NULL, output_file);&#xA;    if (!output_ctx) {&#xA;        fprintf(stderr, "Failed to create output context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Copy video stream&#xA;    video_stream = avformat_new_stream(output_ctx, NULL);&#xA;    if (!video_stream) {&#xA;        fprintf(stderr, "Failed to create video stream\n");&#xA;        exit(1);&#xA;    }&#xA;    avcodec_parameters_copy(video_stream->codecpar, input_ctx->streams[video_stream_index]->codecpar);&#xA;    video_stream->codecpar->codec_tag = 0;&#xA;&#xA;    // Transmux audio stream to AAC&#xA;    audio_codec = avcodec_find_encoder_by_name(AUDIO_CODEC);&#xA;    if (!audio_codec) {&#xA;        fprintf(stderr, "AAC codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    audio_stream = avformat_new_stream(output_ctx, audio_codec);&#xA;    if (!audio_stream) {&#xA;        fprintf(stderr, "Failed to create audio stream\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    audio_codec_ctx = avcodec_alloc_context3(audio_codec);&#xA;    if (!audio_codec_ctx) {&#xA;        fprintf(stderr, "Failed to allocate audio codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    // Set audio codec parameters&#xA;    audio_codec_ctx->sample_fmt = audio_codec->sample_fmts ? audio_codec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;&#xA;    audio_codec_ctx->bit_rate = 64000;&#xA;    audio_codec_ctx->sample_rate = 44100;&#xA;&#xA;    // Use AVChannelLayout for channel configuration&#xA;    AVChannelLayout stereo_layout = AV_CHANNEL_LAYOUT_STEREO;&#xA;    av_channel_layout_copy(&amp;audio_codec_ctx->ch_layout, &amp;stereo_layout);&#xA;&#xA;    if (output_ctx->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;        audio_codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;    if ((ret = avcodec_open2(audio_codec_ctx, audio_codec, NULL)) &lt; 0) {&#xA;        log_error("Failed to open audio codec", ret);&#xA;    }&#xA;&#xA;    avcodec_parameters_from_context(audio_stream->codecpar, audio_codec_ctx);&#xA;&#xA;    // Open output file&#xA;    if (!(output_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        if ((ret = avio_open(&amp;output_ctx->pb, output_file, AVIO_FLAG_WRITE)) &lt; 0) {&#xA;            log_error("Failed to open output file", ret);&#xA;        }&#xA;    }&#xA;&#xA;    // Write header&#xA;    if ((ret = avformat_write_header(output_ctx, NULL)) &lt; 0) {&#xA;        log_error("Failed to write header", ret);&#xA;    }&#xA;&#xA;    // Read and write packets&#xA;    AVPacket pkt;&#xA;    int count = 0;&#xA;    while (count&#x2B;&#x2B;, count &lt; 500) {&#xA;        if ((ret = av_read_frame(input_ctx, &amp;pkt)) &lt; 0) {&#xA;            break; // End of stream or error&#xA;        }&#xA;&#xA;        if (pkt.stream_index == video_stream_index) {&#xA;            // Video packet: copy as-is&#xA;            pkt.stream_index = video_stream->index;&#xA;        } else if (pkt.stream_index == audio_stream_index) {&#xA;            // Audio packet: transmux to AAC&#xA;            pkt.stream_index = audio_stream->index;&#xA;        } else {&#xA;            av_packet_unref(&amp;pkt);&#xA;            continue;&#xA;        }&#xA;&#xA;        av_packet_rescale_ts(&amp;pkt, input_ctx->streams[pkt.stream_index]->time_base, output_ctx->streams[pkt.stream_index]->time_base);&#xA;&#xA;        if ((ret = av_interleaved_write_frame(output_ctx, &amp;pkt)) &lt; 0) {&#xA;            log_error("Failed to write frame", ret);&#xA;        }&#xA;&#xA;        av_packet_unref(&amp;pkt);&#xA;    }&#xA;&#xA;    // Write trailer&#xA;    av_write_trailer(output_ctx);&#xA;&#xA;    // Cleanup&#xA;    avcodec_free_context(&amp;audio_codec_ctx);&#xA;    avformat_close_input(&amp;input_ctx);&#xA;    if (output_ctx &amp;&amp; !(output_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        avio_closep(&amp;output_ctx->pb);&#xA;    }&#xA;    avformat_free_context(output_ctx);&#xA;&#xA;    printf("Recording completed successfully.\n");&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    Everything seems to work fine during recording, but when I play back the recorded file, there’s no audio. Here’s the output from ffprobe :

    &#xA;

    Input #0, mpegts, from &#x27;D:/abc.ts&#x27;:&#xA;  Duration: 00:00:11.92, start: 0.000000, bitrate: 1897 kb/s&#xA;  Program 1&#xA;    Metadata:&#xA;      service_name    : Service01&#xA;      service_provider: FFmpeg&#xA;  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn&#xA;  Stream #0:1[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), stereo, fltp, 167 kb/s&#xA;

    &#xA;

    What might I be missing here ? I'd greatly appreciate any guidance or suggestions.&#xA;Thanks in advance for your help !

    &#xA;

  • FFMPEG Corrupt output remuxing MP4 (Using API in C) -First file OK, 2nd file onwards is not

    25 janvier, par RichardP

    I have a simple application written in C - it takes the video from a RTSP camera and just writes to disk in 1 minute segments. The first file created works fine, plays on anlmost anything. The Second file does not play. Programatically, The trace shows they are the same code flows, but I cant seem to find where the problem is to allow the 2nd file to be play exactly the same as the first.

    &#xA;

    There are frames in the 2nd file but they are random. The second file is created EXACTLY the same way as the first.

    &#xA;

    Any help from a guru would be greatly appreciated.

    &#xA;

    EDIT : FIX - The output duration needs to be set before the trailer is written.

    &#xA;

    int actual_duration = (int)difftime(time(NULL), start_time);&#xA;&#xA;for (int i = 0; i &lt; output_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;    output_ctx->streams[i]->duration = actual_duration * AV_TIME_BASE;&#xA;}&#xA;&#xA;output_ctx->duration = actual_duration * AV_TIME_BASE;&#xA;printf("DURATION = %d\r\n",output_ctx->duration);&#xA;&#xA;// Set the start_time for the output context&#xA;output_ctx->start_time = 0;&#xA;&#xA;av_write_trailer(output_ctx);&#xA;

    &#xA;

    Code flow

    &#xA;

       Open RTSP Stream &#xA;A: Create File n context &#xA;   Remux to file n &#xA;   Wait for minute to change &#xA;   Close File n context  &#xA;   increment n Goto A&#xA;

    &#xA;

    Makefile

    &#xA;

    CC = gcc&#xA;CFLAGS = -Wall -g&#xA;LIBS = -lavformat -lavcodec -lavutil -lavdevice -lswscale -lavfilter -lavutil -lm -lz -lpthread&#xA;&#xA;TARGET = rtsp_remux&#xA;&#xA;all: $(TARGET)&#xA;&#xA;$(TARGET): rtsp_remux.o&#xA;        $(CC) -o $(TARGET) rtsp_remux.o $(LIBS)&#xA;&#xA;rtsp_remux.o: rtsp_remux.c&#xA;        $(CC) $(CFLAGS) -c rtsp_remux.c&#xA;&#xA;clean:&#xA;        rm -f $(TARGET) rtsp_remux.o&#xA;&#xA;.PHONY: all clean&#xA;

    &#xA;

    rtsp_remux.c

    &#xA;

    #include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>time.h>&#xA;#include &#xA;#include &#xA;&#xA;#define OUTPUT_PREFIX "output"&#xA;#define OUTPUT_EXTENSION ".mp4"&#xA;#define MAX_FILES 4&#xA;&#xA;int main(int argc, char *argv[]) {&#xA;    if (argc &lt; 2) {&#xA;        fprintf(stderr, "Usage: %s <rtsp url="url">\n", argv[0]);&#xA;        return -1;&#xA;    }&#xA;&#xA;    const char *rtsp_url = argv[1];&#xA;    AVFormatContext *input_ctx = NULL, *output_ctx = NULL;&#xA;    AVOutputFormat *output_fmt = NULL;&#xA;    AVPacket pkt;&#xA;    int ret, file_count = 0;&#xA;    char output_filename[1024];&#xA;    time_t current_time;&#xA;    struct tm *timeinfo;&#xA;    int rename_lock = 0;&#xA;&#xA;    avformat_network_init();&#xA;&#xA;    if ((ret = avformat_open_input(&amp;input_ctx, rtsp_url, NULL, NULL)) &lt; 0) {&#xA;        fprintf(stderr, "Could not open input file &#x27;%s&#x27;\n", rtsp_url);&#xA;        return -1;&#xA;    }&#xA;&#xA;    if ((ret = avformat_find_stream_info(input_ctx, NULL)) &lt; 0) {&#xA;        fprintf(stderr, "Failed to retrieve input stream information\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    av_dump_format(input_ctx, 0, rtsp_url, 0);&#xA;&#xA;    while (file_count &lt; MAX_FILES) {&#xA;        snprintf(output_filename, sizeof(output_filename), "%s_%03d%s", OUTPUT_PREFIX, file_count, OUTPUT_EXTENSION);&#xA;&#xA;        if ((ret = avformat_alloc_output_context2(&amp;output_ctx, NULL, NULL, output_filename)) &lt; 0) {&#xA;            fprintf(stderr, "Could not create output context\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        output_fmt = output_ctx->oformat;&#xA;&#xA;        for (int i = 0; i &lt; input_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;            AVStream *in_stream = input_ctx->streams[i];&#xA;            AVStream *out_stream = avformat_new_stream(output_ctx, NULL);&#xA;            if (!out_stream) {&#xA;                fprintf(stderr, "Failed allocating output stream\n");&#xA;                return -1;&#xA;            }&#xA;&#xA;            if ((ret = avcodec_parameters_copy(out_stream->codecpar, in_stream->codecpar)) &lt; 0) {&#xA;                fprintf(stderr, "Failed to copy codec parameters\n");&#xA;                return -1;&#xA;            }&#xA;            out_stream->codecpar->codec_tag = 0;&#xA;        }&#xA;&#xA;        if (!(output_fmt->flags &amp; AVFMT_NOFILE)) {&#xA;            if ((ret = avio_open(&amp;output_ctx->pb, output_filename, AVIO_FLAG_WRITE)) &lt; 0) {&#xA;                fprintf(stderr, "Could not open output file &#x27;%s&#x27;\n", output_filename);&#xA;                return -1;&#xA;            }&#xA;        }&#xA;&#xA;        if ((ret = avformat_write_header(output_ctx, NULL)) &lt; 0) {&#xA;            fprintf(stderr, "Error occurred when opening output file\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        while (1) {&#xA;            current_time = time(NULL);&#xA;            timeinfo = localtime(&amp;current_time);&#xA;&#xA;            if (timeinfo->tm_sec == 0 &amp;&amp; !rename_lock) {&#xA;                rename_lock = 1;&#xA;                break;&#xA;            } else if (timeinfo->tm_sec != 0) {&#xA;                rename_lock = 0;&#xA;            }&#xA;&#xA;            if ((ret = av_read_frame(input_ctx, &amp;pkt)) &lt; 0)&#xA;                break;&#xA;&#xA;            AVStream *in_stream = input_ctx->streams[pkt.stream_index];&#xA;            AVStream *out_stream = output_ctx->streams[pkt.stream_index];&#xA;&#xA;            pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);&#xA;            pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);&#xA;            pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);&#xA;            pkt.pos = -1;&#xA;&#xA;            if ((ret = av_interleaved_write_frame(output_ctx, &amp;pkt)) &lt; 0) {&#xA;                fprintf(stderr, "Error muxing packet\n");&#xA;                break;&#xA;            }&#xA;&#xA;            av_packet_unref(&amp;pkt);&#xA;        }&#xA;&#xA;        av_write_trailer(output_ctx);&#xA;&#xA;        if (!(output_fmt->flags &amp; AVFMT_NOFILE))&#xA;            avio_closep(&amp;output_ctx->pb);&#xA;&#xA;        avformat_free_context(output_ctx);&#xA;&#xA;        file_count&#x2B;&#x2B;;&#xA;    }&#xA;&#xA;    avformat_close_input(&amp;input_ctx);&#xA;    avformat_network_deinit();&#xA;&#xA;    return 0;&#xA;}&#xA;</rtsp>

    &#xA;

    I have tried changing to pointers, freeing and different things. I was expecting the 2nd file created to behave identically to the first.

    &#xA;

  • Converting HLS Stream to stream supported by old radio

    29 novembre 2024, par Alberto Faenza

    I have an old internet radio that does not support HLS streams.&#xA;Therefore I cannot listen to my favourite radio at this url :&#xA;https://streamcdnf31-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/master_ma.m3u8

    &#xA;

    I found a solution using a paid software https://minimradio.com/ which is based on minimserver and minimstreamer.

    &#xA;

    This solution works if I install mininmserver and minimstreamer on a local computer and use the internet radio to point to the converter stream but I will have to pay if I want to use this.

    &#xA;

    Checking the documentation of minimradio and ministreamer I can see the following :

    &#xA;

    *Some internet radios can play the previous AAC ADTS streams but can't play these new HLS streams&#xA;...

    &#xA;

    If the network stream URL points to an HLS .m3u8 master playlist or media playlist file, MinimStreamer reads this file and uses the HLS protocol to read the stream audio data and send it to the music player as a conventional HTTP stream. This makes the stream playable on music players that don't support the HLS protocol. The audio data in the stream must be encoded in AAC format.*&#xA;and not a single destination receiver I should use a streaming (broadcasting) server. What can I use to do that ?

    &#xA;

    My question is the following :&#xA;Is there a way to replicate what minimstreamer is doing using ffmpeg ?&#xA;I have tried this :

    &#xA;

    &#xA;

    ffmpeg -re -i https://streamcdnf31-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/master_ma.m3u8 -c copy -listen 1 -f mpegts http://192.168.1.9:10000

    &#xA;

    &#xA;

    which is playing corrctly in local vlc on the same computer. But when I stop VLC is got this error in ffmpeg :

    &#xA;

    [https @ 00000291de047400] Cannot reuse HTTP connection for different host: StreamCdnG20-4c4b867c89244861ac216426883d1ad0.msvdn.net:-1 != 4c4b867c89244861ac216426883d1ad0.msvdn.net:-1&#xA;[hls @ 00000291dd96d140] keepalive request failed for &#x27;https://4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/play1.m3u8&#x27; with error: &#x27;Invalid argument&#x27; when parsing playlist&#xA;[hls @ 00000291dd96d140] Opening &#x27;https://4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/play1.m3u8&#x27; for reading&#xA;[hls @ 00000291dd96d140] Skip (&#x27;#EXT-X-DISCONTINUITY-SEQUENCE:0&#x27;)&#xA;[hls @ 00000291dd96d140] Skip (&#x27;#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:36:56.926Z&#x27;)&#xA;[hls @ 00000291dd96d140] Skip (&#x27;#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:37:07.314Z&#x27;)&#xA;[hls @ 00000291dd96d140] Skip (&#x27;#EXT-X-PROGRAM-DATE-TIME:2024-11-29T06:37:17.571Z&#x27;)&#xA;[https @ 00000291de4e00c0] Opening &#x27;https://StreamCdnG20-4c4b867c89244861ac216426883d1ad0.msvdn.net/radiodeejay/radiodeejay/20240722T095729_p1s_001086632.ts&#x27; for reading&#xA;[aost#0:0/copy @ 00000291de1c4f40] Error submitting a packet to the muxer: Error number -10054 occurred&#xA;    Last message repeated 1 times&#xA;[out#0/mpegts @ 00000291deaa7e40] Error muxing a packet&#xA;[out#0/mpegts @ 00000291deaa7e40] Task finished with error code: -10054 (Error number -10054 occurred)&#xA;[out#0/mpegts @ 00000291deaa7e40] Terminating thread with return code -10054 (Error number -10054 occurred)&#xA;[out#0/mpegts @ 00000291deaa7e40] Error writing trailer: Error number -10054 occurred&#xA;[http @ 00000291de8870c0] URL read error: Error number -10054 occurred&#xA;[out#0/mpegts @ 00000291deaa7e40] Error closing file: Error number -10054 occurred&#xA;[out#0/mpegts @ 00000291deaa7e40] video:0KiB audio:797KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 21.849292%&#xA;size=     971KiB time=00:00:50.98 bitrate= 156.0kbits/s speed=1.01x&#xA;Conversion failed!&#xA;

    &#xA;

    And if I try to connect from my internet radio I immediately got this error :

    &#xA;

    [aost#0:0/copy @ 0000027081584a40] Error submitting a packet to the muxer: Error number -10053 occurred&#xA;    Last message repeated 1 times&#xA;[out#0/mpegts @ 0000027081e684c0] Error muxing a packet&#xA;[out#0/mpegts @ 0000027081e684c0] Task finished with error code: -10053 (Error number -10053 occurred)&#xA;[out#0/mpegts @ 0000027081e684c0] Terminating thread with return code -10053 (Error number -10053 occurred)&#xA;[out#0/mpegts @ 0000027081e684c0] Error writing trailer: Error number -10053 occurred&#xA;[http @ 0000027081c47680] URL read error: Error number -10053 occurred&#xA;[out#0/mpegts @ 0000027081e684c0] Error closing file: Error number -10053 occurred&#xA;[out#0/mpegts @ 0000027081e684c0] video:0KiB audio:46KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 13.917515%&#xA;size=      52KiB time=00:00:02.94 bitrate= 145.1kbits/s speed= 1.2x&#xA;Conversion failed!&#xA;

    &#xA;

    What is the correct way to stream this one locally in order to be listened in my internet radio ?&#xA;Shall I use ffmpeg or can be done directly with ngnix ? Or shall I use both ?

    &#xA;