Recherche avancée

Médias (91)

Autres articles (49)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

Sur d’autres sites (8303)

  • How to add MOV file header to raw data written file with ffmpeg ?

    10 janvier 2018, par gstream79

    I am going to record H264 encoded video stream data in iOS using swift.
    I am not familiar with video codec formats so don’t know how to do this. But I’ve tried to write the H264 raw video data to the file sequently and see its file Info. I am surprised that it has almost video file info (compared with standard mp4, MOV file). The only missing info is video duration, file size, overall bit rate, encoded data, etc. So I am just wondering if video can play if I add the MOV file header to this file manually. Spent few hours to googling how to add MOV file header with ffmpeg but stacked. Any help would be appreciated. Thanks

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

  • How to find currently streaming file in ffmpeg stream that uses a file list

    27 février 2021, par DigitalDisaster

    I am using ffmpeg to stream to an RTMP server. I am using the option to provide ffmpeg a text file with a list of files to stream. My file looks like this :

    &#xA;

    ffconcat version 1.0&#xA;file &#x27;stream_file1.flv&#x27;&#xA;file &#x27;stream_file2.flv&#x27;&#xA;file &#x27;stream_file3.flv&#x27;&#xA;

    &#xA;

    It loops through these files while streaming. Is there a way to programmatically find out when ffmpeg switches between each file ? Either from ffmpeg dumping some logs that I can injest, or by using python to check the state of the stream every second ?

    &#xA;