Recherche avancée

Médias (1)

Mot : - Tags -/book

Autres articles (20)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

Sur d’autres sites (1933)

  • Connection reset by peer, ffmpeg

    18 août 2016, par Johnnylin

    I have tried several ways and done a lot of search. I just cannot figure out why this happens.

    This is the thread. I did almost the same thing.

    https://ffmpeg.org/pipermail/libav-user/2014-March/006356.html

    When you use ffmpeg command line together with ffserver, it works. But when you use sample code. It just does not work.

    What is missing ?

    EDIT

    Hi all,

    I took the muxing.c example and modified it in order to send a stream
    through a network socket. I only made few modifications :

    main function now looks like :

    int main()
    {
       AVOutputFormat *fmt;
       AVFormatContext *oc;
       AVStream *audio_st, *video_st;
       AVCodec *audio_codec, *video_codec;
       double audio_time, video_time;
       int flush, ret;

       /* Initialize libavcodec, and register all codecs and formats. */
       av_register_all();
       avformat_network_init();

       /* allocate the output media context */
       avformat_alloc_output_context2(&oc, NULL, "mpegts", NULL);
       if (!oc) {
           printf("Could not deduce output format from file extension: using
    MPEG.\n");
           avformat_alloc_output_context2(&oc, NULL, "mpegts", NULL);
       }
       if (!oc)
           return 1;

       fmt = oc->oformat;
       //fmt->video_codec = AV_CODEC_ID_MPEG2VIDEO;
       //fmt->audio_codec = AV_CODEC_ID_MP3;

       /* Add the audio and video streams using the default format codecs
        * and initialize the codecs. */
       video_st = NULL;
       audio_st = NULL;

       if (fmt->video_codec != AV_CODEC_ID_NONE)
           video_st = add_stream(oc, &video_codec, fmt->video_codec);
       if (fmt->audio_codec != AV_CODEC_ID_NONE)
           audio_st = add_stream(oc, &audio_codec, fmt->audio_codec);

       /* Now that all the parameters are set, we can open the audio and
        * video codecs and allocate the necessary encode buffers. */
       if (video_st)
           open_video(oc, video_codec, video_st);
       if (audio_st)
           open_audio(oc, audio_codec, audio_st);

      av_dump_format(oc, 0, "http://localhost:8090/feed1.ffm", 1);

       /* open the output file, if needed */
       if (!(fmt->flags & AVFMT_NOFILE)) {
           ret = avio_open(&oc->pb, "http://localhost:8090/feed1.ffm",
    AVIO_FLAG_WRITE);
           if (ret < 0) {
               fprintf(stderr, "Could not open '%s': %s\n", "
    http://localhost:8090/feed1.ffm",
                       av_err2str(ret));
               return 1;
           }
       }

       /* Write the stream header, if any. */
       ret = avformat_write_header(oc, NULL);
       if (ret < 0) {
           fprintf(stderr, "Error occurred when opening output file: %s\n",
                   av_err2str(ret));
           return 1;
       }

       flush = 0;
       while ((video_st && !video_is_eof) || (audio_st && !audio_is_eof)) {
           /* Compute current audio and video time. */
           audio_time = (audio_st && !audio_is_eof) ? audio_st->pts.val *
    av_q2d(audio_st->time_base) : INFINITY;
           video_time = (video_st && !video_is_eof) ? video_st->pts.val *
    av_q2d(video_st->time_base) : INFINITY;

           if (!flush &&
               (!audio_st || audio_time >= STREAM_DURATION) &&
               (!video_st || video_time >= STREAM_DURATION)) {
               flush = 1;
           }

           /* write interleaved audio and video frames */
           if (audio_st && !audio_is_eof && audio_time <= video_time) {
               write_audio_frame(oc, audio_st, flush);
           } else if (video_st && !video_is_eof && video_time < audio_time) {
               write_video_frame(oc, video_st, flush);
           }
       }

       /* Write the trailer, if any. The trailer must be written before you
        * close the CodecContexts open when you wrote the header; otherwise
        * av_write_trailer() may try to use memory that was freed on
        * av_codec_close(). */
       av_write_trailer(oc);

       /* Close each codec. */
       if (video_st)
           close_video(oc, video_st);
       if (audio_st)
           close_audio(oc, audio_st);

       if (!(fmt->flags & AVFMT_NOFILE))
           /* Close the output file. */
           avio_close(oc->pb);

       /* free the stream */
       avformat_free_context(oc);

       return 0;
    }  

    and, in order to avoid a warning about channel layout not specified, I
    added :

    c->channel_layout = av_get_default_channel_layout(c->channels);

    in function AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,
                           enum AVCodecID codec_id)

    just under the row c->channels = 2 ;

    I also raised a ffserver with the following configuration (showing only
    feed lines) :

    <feed>
           File /tmp/feed1.ffm
           FileMaxSize 1GB
           ACL allow 127.0.0.1
           ACL allow 192.168.0.0 192.168.255.255
    </feed>

    ffserver is working fine if I feed it with a ffmpeg commandline, e.g :

    ffmpeg -r 25 -i movie.mp4 -acodec libfdk_aac  -ab 128k -vcodec libx264 -fpre libx264-fast.ffpreset http://localhost:8090/feed1.ffm

    But with my example, I can write only few frames and after that may muxing
    modified program ends with :

    Error while writing video frame : Connection reset by peer

    I tried also different codecs (h264) and format (flv), turning out in a
    different number of frames written, but eventually I got the same error
    above.

    ffserver do not reports errors at all, only write:
    Tue Mar  4 12:55:10 2014 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 4096
    confirming that the communication socket was open

    What am i missing ??

    Thanks

  • av_interleaved_write_frame() : Connection reset by peer when streaming to RTMP

    17 mai 2023, par Loc Bui Nhien

    I'm trying to stream to an RTMP server using a Python subprocess with FFmpeg. When I wanted to stream it to localhost, everything worked fine. But when I tried to stream it to my designated RMTP server using nginx, now and then, this error will crash the program :

    &#xA;

    av_interleaved_write_frame(): Broken pipe    &#xA;Error writing trailer of rtmp://.../live: Broken pipe&#xA;

    &#xA;

    I checked the connection to the server it was fine. Here are my settings for my RTMP server using nginx :

    &#xA;

    rtmp {&#xA;    server {&#xA;        listen 1935;&#xA;        chunk_size 4096;&#xA;&#xA;        application live {&#xA;            live on;&#xA;            record off;&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    And here is my code for FFmpeg code to stream :

    &#xA;

    command = [&#x27;ffmpeg&#x27;,&#xA;           &#x27;-y&#x27;,&#xA;           &#x27;-f&#x27;, &#x27;rawvideo&#x27;,&#xA;           &#x27;-vcodec&#x27;, &#x27;rawvideo&#x27;,&#xA;           &#x27;-pix_fmt&#x27;, &#x27;bgr24&#x27;,&#xA;           &#x27;-s&#x27;, "{}x{}".format(width, height),&#xA;           &#x27;-re&#x27;,&#xA;           &#x27;-r&#x27;, str(fps),&#xA;           &#x27;-i&#x27;, &#x27;pipe:&#x27;,&#xA;           &#x27;-c:v&#x27;, &#x27;libx264&#x27;,&#xA;           &#x27;-pix_fmt&#x27;, &#x27;yuv420p&#x27;,&#xA;           &#x27;-preset&#x27;, &#x27;medium&#x27;,&#xA;           &#x27;-vsync&#x27;,&#x27;vfr&#x27;,&#xA;           &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;           &#x27;-flvflags&#x27;, &#x27;no_duration_filesize&#x27;,&#xA;           rtmp_url]&#xA;&#xA;p = subprocess.Popen(command, stdin=subprocess.PIPE)&#xA;

    &#xA;

    I'm pretty sure that it has something to do with how the RTMP server is setup and its settings, but I provide the ffmpeg code just in case.

    &#xA;

    Thank you in advance.

    &#xA;

  • av_interleaved_write_frame() : Connection reset by peer - Using ffmpeg connected to local nginx

    10 avril 2019, par haxpor

    I have a local nginx web server installed with nginx-rtmp-module.

    I have 2 RTMP sources that are fed into local network at rtmp://127.0.0.1/live-video, and rtmp://127.0.0.1/live-audio. Then these twos will be combined and fed into rtmp://127.0.0.1/live again. The latter one will be the one that I will be using.

    The reason I did just that is I want to do noise reduction via sox.

    The setup is as follows

    1. rtmp://127.0.0.1/live-video - it uses ffmpeg to capture only screen (video) then output to such URL with command

      ffmpeg -analyzeduration 0 -video_size 1280x1080 -framerate 25 -f x11grab -i :0.0 -vcodec libx264 -flags +global_header -preset ultrafast -minrate 7200 -maxrate 8k -vsync 1 -f flv -metadata streamName=ZombieHeroLiveStream rtmp://127.0.0.1/live-video
    2. rtmp://127.0.0.1/live-audio - it uses sox to do noise reduction then uses ffmpeg to feed into such URL with command

      ffmpeg -f alsa -ac 1 -i default -preset ultrafast -f flac - | sox - -p noisered /tmp/noise.prof 0.21 | ffmpeg -analyzeduration 0 -thread_queue_size 2 -i - -f flv -preset ultrafast rtmp://127.0.0.1/live-audio
    3. rtmp://127.0.0.1/live - it uses ffmpeg to combine the above two sources then output into such URL, this is the one I tested viewing via VLC (which is works fine) with command

      ffmpeg -analyzeduration 0 -thread_queue_size 512 -rtmp_live live -flags +global_header -i "rtmp://127.0.0.1/live-video" -analyzeduration 0 -thread_queue_size 512 -rtmp_live live -flags +global_header -i "rtmp://127.0.0.1/live-audio" -c:v copy -c:a copy -map 0:v -map 1:a -async 1 -vsync 1 -video_size 1280x1080 -fflags +genpts -framerate 30 -preset ultrafast -minrate 7200 -maxrate 8k -flags +global_header -segment_list_flags +live -rtmp_live live -f flv -metadata streamName=ZombieHeroLiveStream "rtmp://127.0.0.1/live"

    The setup works fine, I tested and confirmed viewing via VLC targeting to URL of 3. The problem is that for some times after all threes above up and running, 1. will exit and thus make the whole encoding stop. The error shown is

    av_interleaved_write_frame(): Connection reset by peer29.88 bitrate=2021.8kbits/s dup=1791 drop=0 speed=0.998x    
       Last message repeated 2 times
    ...

    Error writing trailer of rtmp://127.0.0.1/live-video: Connection reset by peer

    No matter how I change and modify command line’s flags/options, it will end up like error above. Please note, I’ve modified flags quite a lot thus a certain flags might be possibly not needed.

    Full error log from 1. is here.

    Configuration of nginx server is here. It’s pretty much basic, but I will further use it to relay to multiple target RTMP servers later.

    I’m on Ubuntu 18.04, 4.18.0-17-generic with 8 GB of RAM, 4 CPU Cores with ffmpeg

    ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)

    , and with Nginx

    nginx version: nginx/1.14.2
    built by gcc 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
    built with OpenSSL 1.1.0g  2 Nov 2017 (running with OpenSSL 1.1.1b  26 Feb 2019)
    TLS SNI support enabled
    configure arguments: --with-http_ssl_module --add-module=../nginx-rtmp-module-1.2.1

    So again the question is how can I fix such issue ?
    Any suggestion would be appreciated.

    Important edit : I just found out I entered a wrong duplicated command for 3. Now it has been corrected ! Sorry about that.

    Update : I’m able to record audio with ffmpeg then do noise filter with sox, then stream to target rtmp with ffmpeg. But noise reduction doesn’t satisfy me yet. See above at 2. for its updated command. And according to this, sox has problem in understand a few bytes so I use flac format in piping instead. Still my question remained as this update is for improvement for command in 2.