Recherche avancée

Médias (91)

Autres articles (46)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

Sur d’autres sites (3183)

  • How to set video duration using python ?

    2 mars 2015, par shoujs

    I write a python program to record streaming video. I can play the recorded video using VLC. I find the duration will be 1 hour whatever how much time I take to record the video.

    Here is the code snippet :

    f = open(filename, 'wb')
    block_size = 1024
    duration = 2 * 60 # 2 mins

    start = datetime.now()
    end = start + timedelta(seconds=duration)

    while datetime.now() < end:
       try:
           buffer = response.read(block_size)
           if not buffer:
               break

           f.write(buffer)

       except:
          pass

    f.close()

    I use ffmpeg to inspect the video. It tells me 1 hour of duration.

    So is there a way to set the correct duration for the streaming video recording ?

    The medata data for the video inspected by ffmpeg
    enter image description here

  • Getting an error when I use live555+ffmpeg to play rtsp (h.264 )

    11 septembre 2011, par moonvan

    This is the debug info .I am a beginner for this. Can you tell me what the error mean ?

    Sending request: OPTIONS rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp RTSP/1.0
    CSeq: 1
    User-Agent: LIVE555 Streaming Media v2010.04.09


    Received OPTIONS response: RTSP/1.0 200 OK
    Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
    Cseq: 1
    Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, OPTIONS, ANNOUNCE, RECORD


    Sending request: DESCRIBE rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp RTSP/1.0
    CSeq: 2
    Accept: application/sdp
    User-Agent: LIVE555 Streaming Media v2010.04.09


    Received DESCRIBE response: RTSP/1.0 200 OK
    Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
    Cseq: 2
    Content-length: 413
    Date: Sun, 11 Sep 2011 13:41:27 GMT
    Expires: Sun, 11 Sep 2011 13:41:27 GMT
    Content-Type: application/sdp
    x-Accept-Retransmit: our-retransmit
    x-Accept-Dynamic-Rate: 1
    Content-Base: rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/


    Need to read 413 extra bytes
    Read 413 extra bytes: v=0
    o=- 1 1 IN IP4 0.0.0.0
    s=RTSP Session
    i=Jabsco Stream(JCO-jy9757acx1eve7nm-a104aea23c1e17bbc776656f5069bbf7)
    c=IN IP4 218.204.223.237
    t=0 0
    a=range:npt=now-
    a=control:*
    m=video 0 RTP/AVP 96
    b=AS:200
    a=rtpmap:96 MP4V-ES/90000
    a=fmtp:96 profile-level-id=1;config=000001b001000001b509000001010000012000844ea628582120a21f;decode_buf=115200
    a=framerate:15
    a=framesize:96 352-288
    a=control:trackID=1

    2011-09-11 21:41:28.344 rtsp[3568:ef03] getSDP: --> v=0
    o=- 1 1 IN IP4 0.0.0.0
    s=RTSP Session
    i=Jabsco Stream(JCO-jy9757acx1eve7nm-a104aea23c1e17bbc776656f5069bbf7)
    c=IN IP4 218.204.223.237
    t=0 0
    a=range:npt=now-
    a=control:*
    m=video 0 RTP/AVP 96
    b=AS:200
    a=rtpmap:96 MP4V-ES/90000
    a=fmtp:96 profile-level-id=1;config=000001b001000001b509000001010000012000844ea628582120a21f;decode_buf=115200
    a=framerate:15
    a=framesize:96 352-288
    a=control:trackID=1
    Sending request: SETUP rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/trackID=1 RTSP/1.0
    CSeq: 3
    Transport: RTP/AVP/TCP;unicast;interleaved=0-1
    User-Agent: LIVE555 Streaming Media v2010.04.09


    Received SETUP response: RTSP/1.0 200 OK
    Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
    Cseq: 3
    Session: 30185030182557
    Date: Sun, 11 Sep 2011 13:41:27 GMT
    Expires: Sun, 11 Sep 2011 13:41:27 GMT
    Transport: RTP/AVP/TCP;unicast;interleaved=0-1


    2011-09-11 21:41:28.495 rtsp[3568:ef03] RTP
    2011-09-11 21:41:28.496 rtsp[3568:ef03] MP4V-ES
    2011-09-11 21:41:28.497 rtsp[3568:ef03] video
    2011-09-11 21:41:28.498 rtsp[3568:ef03] 0
    2011-09-11 21:41:28.499 rtsp[3568:ef03] 0
    Sending request: PLAY rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/ RTSP/1.0
    CSeq: 4
    Session: 30185030182557
    Range: npt=0.000-
    User-Agent: LIVE555 Streaming Media v2010.04.09


    Received PLAY response: RTSP/1.0 200 OK
    Server: PVSS/0.0.1 (Build/20100101; Platform/Win32; Darwin; )
    Cseq: 4
    Session: 30185030182557
    RTP-Info: url=rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp/trackID=1;seq=0;rtptime=0


    2011-09-11 21:41:28.650 rtsp[3568:ef03] error: --> liveMedia4
    2011-09-11 21:41:28.886 rtsp[3568:ef03] Packet size===>8782
    [h264 @ 0x7859800]non-existing PPS 0 referenced
    [h264 @ 0x7859800]decode_slice_header error
    [h264 @ 0x7859800]no frame!
    2011-09-11 21:41:28.886 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:28.887 rtsp[3568:ef03] frame data===>107521264
    2011-09-11 21:41:28.888 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:28.921 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
    2011-09-11 21:41:28.922 rtsp[3568:ef03] Packet size===>1459
    [h264 @ 0x688fc00]no frame!
    2011-09-11 21:41:28.922 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:28.923 rtsp[3568:ef03] frame data===>102427408
    2011-09-11 21:41:28.923 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:28.951 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
    2011-09-11 21:41:28.952 rtsp[3568:ef03] Packet size===>1258
    2011-09-11 21:41:28.952 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:28.953 rtsp[3568:ef03] frame data===>102426080
    2011-09-11 21:41:28.953 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:28.976 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
    2011-09-11 21:41:28.977 rtsp[3568:ef03] Packet size===>2731
       Last message repeated 1 times
    [h264 @ 0x705ce00]no frame!
    2011-09-11 21:41:28.977 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:28.978 rtsp[3568:ef03] frame data===>105438976
    2011-09-11 21:41:28.979 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:29.002 rtsp[3568:ef03] 2011-09-11 13:41:14 +0000
    2011-09-11 21:41:29.012 rtsp[3568:ef03] Packet size===>8782
    [h264 @ 0x705ce00]non-existing PPS 0 referenced
    [h264 @ 0x705ce00]decode_slice_header error
    [h264 @ 0x705ce00]no frame!
    2011-09-11 21:41:29.013 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:29.014 rtsp[3568:ef03] frame data===>105438976
    2011-09-11 21:41:29.014 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:29.043 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
    2011-09-11 21:41:29.044 rtsp[3568:ef03] Packet size===>1459
    [h264 @ 0xb04f000]no frame!
    2011-09-11 21:41:29.044 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:29.045 rtsp[3568:ef03] frame data===>178793376
    2011-09-11 21:41:29.045 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:29.072 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
    2011-09-11 21:41:29.073 rtsp[3568:ef03] Packet size===>1258
    [h264 @ 0x705ce00]no frame!
    2011-09-11 21:41:29.074 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:29.074 rtsp[3568:ef03] frame data===>105438976
    2011-09-11 21:41:29.075 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:29.099 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
    2011-09-11 21:41:29.100 rtsp[3568:ef03] Packet size===>2731
    2011-09-11 21:41:29.101 rtsp[3568:ef03] Res value===>-1
    2011-09-11 21:41:29.101 rtsp[3568:ef03] frame data===>105438976
    2011-09-11 21:41:29.102 rtsp[3568:ef03] Failed to decode frame
    2011-09-11 21:41:29.125 rtsp[3568:ef03] 2011-09-11 13:41:15 +0000
    2011-09-11 21:41:29.126 rtsp[3568:ef03] Packet size===>1224
       Last message repeated 1 times
  • How to convert multiple jpg images to MP4 format using FFmpeg ?

    30 janvier 2024, par PDLAOZEI
      

    • I first used the FFmpeg command line to implement this function.
ffmpeg -framerate 1 -pattern_type glob -i "./image/*.jpg" -c:v libx264 -crf 25 -vf format=yuv420p -movflags +faststart test.mp4

      


    • 


    • Then I use FFmpeg's api to convert multiple jpg into MP4 format, the process is probably.

      


    • 


    


      

    1. Find the AV_CODEC_ID_MPEG4 encoder.
    2. 


    3. Turn on the encoder.
    4. 


    5. Set video stream parameters.
    6. 


    7. Open the output file.
    8. 


    9. Write file header.
    10. 


    11. Allocate image frame rate and buffer.
    12. 


    13. Write each jpg image to the video (write in a loop).
7-1. read jpg image.
7-2. Find video stream information.
7-3. Decoded image frame.
7-4. Transcode to yuv420p.
7-5. Encode and write video frames.
    14. 


    15. Finally, free memory.
    16. 


    


    update the reproducible example

    


    #include <iostream>&#xA;#include <vector>&#xA;#include <string>&#xA;#include <chrono>&#xA;#include <thread>&#xA;&#xA;#include <filesystem>&#xA;#include <algorithm>&#xA;#include <iomanip>&#xA;#include <sys></sys>stat.h>&#xA;&#xA;extern "C"&#xA;{&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;}&#xA;&#xA;namespace fs = std::filesystem;&#xA;&#xA;bool compareFilenames(const std::string &amp;str1, const std::string &amp;str2)&#xA;{&#xA;    //ToDo Sort&#xA;}&#xA;&#xA;int main()&#xA;{&#xA;    &#xA;    fs::path folderPath = "" //replace your image foldePath&#xA;&#xA;    std::vector imageFiles;&#xA;    for (const auto &amp;entry : fs::directory_iterator(folderPath))&#xA;    {&#xA;        if (entry.is_regular_file() &amp;&amp; entry.path().extension() == ".jpg")&#xA;        {&#xA;            imageFiles.push_back(entry.path());&#xA;        }&#xA;    }&#xA;&#xA;    std::sort(imageFiles.begin(), imageFiles.end(), compareFilenames);&#xA;&#xA;    std::string outputVideoFile = "output.mp4";&#xA;&#xA;    AVFormatContext *formatContext = nullptr;&#xA;    AVCodecContext *codecContext = nullptr;&#xA;    AVStream *videoStream = nullptr;&#xA;&#xA;    av_register_all();&#xA;    avformat_alloc_output_context2(&amp;formatContext, nullptr, nullptr, outputVideoFile.c_str());&#xA;&#xA;&#xA;    AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);//AV_CODEC_ID_H264&#xA;    videoStream = avformat_new_stream(formatContext, codec);&#xA;    codecContext = avcodec_alloc_context3(codec);&#xA;&#xA;    codecContext->codec_id = codec->id;&#xA;    codecContext->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    codecContext->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    codecContext->width = 1920;&#xA;    codecContext->height = 1080;&#xA;    codecContext->time_base = {1, 2}; &#xA;    codecContext->bit_rate = 100000000;&#xA;    codecContext->gop_size = 1;&#xA;&#xA;    avcodec_open2(codecContext, codec, nullptr);&#xA;    avcodec_parameters_from_context(videoStream->codecpar, codecContext);&#xA;&#xA;    avio_open(&amp;formatContext->pb, outputVideoFile.c_str(), AVIO_FLAG_WRITE);&#xA;    avformat_write_header(formatContext, NULL);&#xA;&#xA;    AVFrame *frame = av_frame_alloc();&#xA;&#xA;    std::vector imageBuffer(codecContext->width * codecContext->height * 3);&#xA;    AVPacket packet;&#xA;&#xA;    for (const std::string &amp;imageFile : imageFiles)&#xA;    {&#xA;&#xA;        AVFormatContext *inputFormatContext = avformat_alloc_context();&#xA;        avformat_open_input(&amp;inputFormatContext, imageFile.c_str(), nullptr, nullptr);&#xA;&#xA;        avformat_find_stream_info(inputFormatContext, nullptr);&#xA;&#xA;        AVCodec *inputCodec = nullptr;&#xA;        AVCodecContext *inputCodecContext = nullptr;&#xA;        int videoStreamIndex = -1;&#xA;&#xA;        for (unsigned int i = 0; i &lt; inputFormatContext->nb_streams; i&#x2B;&#x2B;)&#xA;        {&#xA;            if (inputFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;            {&#xA;                videoStreamIndex = i;&#xA;                inputCodec = avcodec_find_decoder(inputFormatContext->streams[i]->codecpar->codec_id);&#xA;                inputCodecContext = avcodec_alloc_context3(inputCodec);&#xA;                avcodec_parameters_to_context(inputCodecContext, inputFormatContext->streams[i]->codecpar);&#xA;                avcodec_open2(inputCodecContext, inputCodec, NULL);&#xA;                break;&#xA;            }&#xA;        }&#xA;&#xA;        AVFrame *inputFrame = av_frame_alloc();&#xA;        while (av_read_frame(inputFormatContext, &amp;packet) >= 0)&#xA;        {&#xA;            if (packet.stream_index == videoStreamIndex)&#xA;            {&#xA;                int response = avcodec_send_packet(inputCodecContext, &amp;packet);&#xA;&#xA;                while (response >= 0)&#xA;                {&#xA;                    response = avcodec_receive_frame(inputCodecContext, inputFrame);&#xA;                    if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)&#xA;                    {&#xA;                        break;&#xA;                    }&#xA;                    else if (response &lt; 0)&#xA;                    {&#xA;                        std::cerr &lt;&lt; "Failed to receive frame from input decoder" &lt;&lt; std::endl;&#xA;                        break;&#xA;                    }&#xA;&#xA;                                        AVFrame *yuvFrame = av_frame_alloc();&#xA;                    av_image_alloc(yuvFrame->data, yuvFrame->linesize, codecContext->width, codecContext->height, codecContext->pix_fmt, 1);&#xA;&#xA;                    SwsContext *yuvSwsContext = sws_getContext(inputFrame->width, inputFrame->height, AV_PIX_FMT_RGB24,&#xA;                                                               codecContext->width, codecContext->height, codecContext->pix_fmt,&#xA;                                                               0, nullptr, nullptr, nullptr);&#xA;&#xA;                    sws_scale(yuvSwsContext, inputFrame->data, inputFrame->linesize, 0, inputFrame->height,&#xA;                              yuvFrame->data, yuvFrame->linesize);&#xA;&#xA;&#xA;                    memcpy(imageBuffer.data(), yuvFrame->data[0], codecContext->width * codecContext->height);&#xA;                    memcpy(imageBuffer.data() &#x2B; codecContext->width * codecContext->height, yuvFrame->data[1], codecContext->width * codecContext->height / 4);&#xA;                    memcpy(imageBuffer.data() &#x2B; codecContext->width * codecContext->height * 5 / 4, yuvFrame->data[2], codecContext->width * codecContext->height / 4);&#xA;&#xA;                    frame->data[0] = imageBuffer.data();&#xA;                    frame->data[1] = frame->data[0] &#x2B; codecContext->width * codecContext->height;&#xA;                    frame->data[2] = frame->data[1] &#x2B; codecContext->width * codecContext->height / 4;&#xA;                    frame->linesize[0] = codecContext->width;&#xA;                    frame->linesize[1] = codecContext->width / 2;&#xA;                    frame->linesize[2] = codecContext->width / 2;&#xA;                    frame->width = codecContext->width;&#xA;                    frame->height = codecContext->height;&#xA;                    frame->format = codecContext->pix_fmt;&#xA;                    frame->pts = av_rescale_q(videoStream->nb_frames, videoStream->time_base, videoStream->codec->time_base);&#xA;&#xA;                    av_init_packet(&amp;packet);&#xA;                    packet.data = nullptr;&#xA;                    packet.size = 0;&#xA;&#xA;                    avcodec_send_frame(codecContext, frame);&#xA;&#xA;                    while (avcodec_receive_packet(codecContext, &amp;packet) >= 0)&#xA;                    {&#xA;                        av_packet_rescale_ts(&amp;packet, codecContext->time_base, videoStream->time_base);&#xA;                        packet.stream_index = videoStream->index;&#xA;&#xA;                        av_write_frame(formatContext, &amp;packet);&#xA;                        av_packet_unref(&amp;packet);&#xA;                    }&#xA;&#xA;                    av_freep(&amp;yuvFrame->data[0]);&#xA;                    av_freep(&amp;yuvFrame);&#xA;                    sws_freeContext(yuvSwsContext);&#xA;                }&#xA;            }&#xA;&#xA;            av_packet_unref(&amp;packet);&#xA;        }&#xA;&#xA;        av_frame_free(&amp;inputFrame);&#xA;        avcodec_close(inputCodecContext);&#xA;        avformat_close_input(&amp;inputFormatContext);&#xA;    }&#xA;&#xA;    av_write_trailer(formatContext);&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_close(codecContext);&#xA;    av_free(codecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;&#xA;</iomanip></algorithm></filesystem></thread></chrono></string></vector></iostream>

    &#xA;

    But the encoding format is mpeg, which cannot be opened in the player included with windows, and the prompt is an unsupported format.

    &#xA;

    Although the vlc player can be opened and played normally, I need to play it normally on the player that comes with windows, because the output video will be played on the browser.

    &#xA;

    So I changed AV_CODEC_ID_MPEG4 to AV_CODEC_ID_H264, and the result is that although the file size of the output image is very large, only one picture is displayed during playback. I don't know what the problem is.

    &#xA;

    I was thinking about writing a new one, but I had no idea how to write a new one.&#xA;I would appreciate it if someone could write me an example.

    &#xA;