Recherche avancée

Médias (3)

Mot : - Tags -/collection

Autres articles (62)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (5372)

  • 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.

    


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

    


    Any help from a guru would be greatly appreciated.

    


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

    


    int actual_duration = (int)difftime(time(NULL), start_time);

for (int i = 0; i < output_ctx->nb_streams; i++) {
    output_ctx->streams[i]->duration = actual_duration * AV_TIME_BASE;
}

output_ctx->duration = actual_duration * AV_TIME_BASE;
printf("DURATION = %d\r\n",output_ctx->duration);

// Set the start_time for the output context
output_ctx->start_time = 0;

av_write_trailer(output_ctx);


    


    Code flow

    


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


    


    Makefile

    


    CC = gcc
CFLAGS = -Wall -g
LIBS = -lavformat -lavcodec -lavutil -lavdevice -lswscale -lavfilter -lavutil -lm -lz -lpthread

TARGET = rtsp_remux

all: $(TARGET)

$(TARGET): rtsp_remux.o
        $(CC) -o $(TARGET) rtsp_remux.o $(LIBS)

rtsp_remux.o: rtsp_remux.c
        $(CC) $(CFLAGS) -c rtsp_remux.c

clean:
        rm -f $(TARGET) rtsp_remux.o

.PHONY: all clean


    


    rtsp_remux.c

    


    #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;

  • Channel mapping in FFmpeg conversion of Dolby 7.1 mlp file to 8 channel wav file [closed]

    21 avril 2024, par Stan Duncan

    I have a file with 7.1 audio with the following channel mapping (viewed using MediaInfo) : L R C LFE Ls Rs Lb Rb

    &#xA;

    I want to convert it to an 8 channel riff64 wave file, so I'm using the following command :

    &#xA;

    ffmpeg.exe -i "input.mlp" -rf64 auto -c:a pcm_f32le "output.wav"

    &#xA;

    When I do this, the channel mapping in output.wav changes to (viewed using MediaInfo) : L R C LFE Lb Rb Ls Rs

    &#xA;

    I'm not sure if this is just a label that gets slapped on there, or if it actually changes the channel positions (i.e., rear surround come out of side surround speakers and vice versa).

    &#xA;

    Is there a better command I should be using to ensure that the channel mapping is not altered ?

    &#xA;

  • FFMPEG- Duration of audio file is inaccurate

    17 septembre 2015, par Tony Than

    I have video file (mp4). I want to detach audio stream (AAC format) from that file and save in PC.
    With below code, Generated aac file canplay now on KM player, but can not play on VLC player. Information of duration displays on player is wrong.
    Please help me with this problem.

    err = avformat_open_input(input_format_context, filename, NULL, NULL);
    if (err &lt; 0) {
       return err;
    }

    /* If not enough info to get the stream parameters, we decode the
      first frames to get it. (used in mpeg case for example) */
    ret = avformat_find_stream_info(*input_format_context, 0);
    if (ret &lt; 0) {
       av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
       return ret;
    }

    /* dump the file content */
    av_dump_format(*input_format_context, 0, filename, 0);

    for (size_t i = 0; i &lt; (*input_format_context)->nb_streams; i++) {
       AVStream *st = (*input_format_context)->streams[i];
       if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
           *input_codec_context = st->codec;
           *input_audio_stream = st;

           FILE *file = NULL;
           file = fopen("C:\\Users\\MyPC\\Downloads\\Test.aac", "wb");
           AVPacket reading_packet;
           av_init_packet(&amp;reading_packet);
           while (av_read_frame(*input_format_context, &amp;reading_packet) == 0) {
               if (reading_packet.stream_index == (int) i) {

                   uint8_t adts_header[7];
                   unsigned int obj_type = 0;
                   unsigned int num_data_block = (reading_packet.size)/1024;
                   int rate_idx = st->codec->sample_rate, channels = st->codec->channels;

                    uint16_t frame_length;

                   // include the header length also
                    frame_length = reading_packet.size + 7;

                   /* We want the same metadata */
                   /* Generate ADTS header */
                   if(adts_header == NULL) return -1;
                   /* Sync point over a full byte */
                   adts_header[0] = 0xFF;
                   /* Sync point continued over first 4 bits + static 4 bits
                   * (ID, layer, protection)*/
                   adts_header[1] = 0xF1;
                   /* Object type over first 2 bits */
                   adts_header[2] = obj_type &lt;&lt; 6;
                   /* rate index over next 4 bits */
                   adts_header[2] |= (rate_idx &lt;&lt; 2);
                   /* channels over last 2 bits */
                   adts_header[2] |= (channels &amp; 0x4) >> 2;
                   /* channels continued over next 2 bits + 4 bits at zero */
                   adts_header[3] = (channels &amp; 0x3) &lt;&lt; 6;
                   /* frame size over last 2 bits */
                   adts_header[3] |= (frame_length &amp; 0x1800) >> 11;
                   /* frame size continued over full byte */
                   adts_header[4] = (frame_length &amp; 0x1FF8) >> 3;
                   /* frame size continued first 3 bits */
                   adts_header[5] = (frame_length &amp; 0x7) &lt;&lt; 5;
                   /* buffer fullness (0x7FF for VBR) over 5 last bits*/
                   adts_header[5] |= 0x1F;
                   /* buffer fullness (0x7FF for VBR) continued over 6 first bits + 2 zeros
                   * number of raw data blocks */
                   adts_header[6] = 0xFA;
                   adts_header[6] |= num_data_block &amp; 0x03; // Set raw Data blocks.

                   fwrite(adts_header, 1, 7, file);
                   fwrite(reading_packet.data, 1, reading_packet.size, file);
               }
               av_free_packet(&amp;reading_packet);  
           }
           fclose(file);

           return 0;
       }
    }