Recherche avancée

Médias (1)

Mot : - Tags -/ogv

Autres articles (48)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • Les statuts des instances de mutualisation

    13 mars 2010, par

    Pour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
    Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...)

Sur d’autres sites (8251)

  • Pipe FFMPEG MPEG-DASH livestream to AWS S3

    17 août 2019, par Alexander

    So I’m currently trying to livestream the rendering of a GPU-heavy video (renders about 1fps), encode it to a 30fps MPEG-DASH livestream and output this to AWS S3 so Shaka Player can display the live rendering.

    The first issue is that the livestream keeps looping, it doesn’t stop after the rendering for loop is done.

    I use a python script to pipe the output of the rendering to FFMPEG, and pipe the output of FFMPEG to the aws s3 cli like this :

    p1 = Popen(['ffmpeg', '-y', '-hwaccel', 'cuvid', '-f', 'image2pipe', '-r', '24', '-i', '-', '-c:v', 'h264_nvenc', '-b:v', '5M', '-f', 'dash', '-movflags', 'frag_keyframe+empty_moov', '-'], stdin=PIPE)#, shell=True) #'-method', 'PUT', 'https://example.s3.amazonaws.com/test1/test1.mpd'], stdin=PIPE)

    p2 = Popen(['aws', 's3', 'cp', '-', 's3://example/test1/test1.mpd'], stdin=p1.stdout)


    #The following commented aws s3 sync command uploads successfully to S3
    #but the issue here is that it stops after the syncing is done and its hacky
    #p1 = Popen(['ffmpeg', '-y', '-vsync', '0', '-hwaccel', 'cuvid', '-f', 'image2pipe', '-r', '24', '-i', '-', '-c:v', 'h264_nvenc', '-b:v', '5M', '-f', 'dash', '-movflags', 'frag_keyframe+empty_moov', 'test2.mpd'], stdin=PIPE)#, shell=True) #'-method', 'PUT', 'https://teststream.s3.amazonaws.com/test1/test1.mpd'], stdin=PIPE)
    #p2 = Popen(['aws', 's3', 'sync', '.', 's3://teststream/test1', '--exclude', '"*"', '--include', '"*.m4s"', '--include', '"*.mpd"'], stdin=PIPE)

    #pseudocode
    for ci,(content,contentName) in enumerate(content_loader):
       im = renderframe(content)
       im.save(p1.stdin, 'PNG')

    p1.stdin.close()
    p1.wait()
    p2.stdin.close()
    p2.wait()
  • Problem using ffmpeg in python to decode video stream to yuv stream and send to a pipe

    30 août 2019, par 瓦达所多阿萨德阿萨德

    This command works nice and fast in shell :

    ffmpeg -c:v h264_cuvid -i ./myvideo.mp4 -f null -pix-fmt yuv420p -

    It was about 13x speed or 300 frames/sec.
    Then I tried to send the yuv stream to pipe and catch it the main process using the following code in python :

    cmd = ['ffmpeg', '-c:v', 'h264_cuvid', '-i', './myvideo.mp4', '-f', 'image2pipe', '-pix_fmt', 'yuv420p', '-']
    p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr=subprocess.PIPE)
    size_Y = int(height * width)
    size_UV = int(size_Y / 4)
    s = time.time()
    Y = p.stdout.read(size_Y)
    U = p.stdout.read(size_UV)
    V = p.stdout.read(size_UV)
    print('read time: ', time.time() - s)

    However, this took seconds to read just one yuv frame. What wronged here ? Im not sure what ffmpeg was sending into the pipe, the yuv planar frames or just the pointers to data planes ?

    the console output :

    [('Number of Frames', 61137), ('FPS', 25.0), ('Frame Shape', (1920, 1080))]
    --Number of Frames: 61137
    --FPS: 25.0
    --Frame Shape: (1920, 1080)
    cmd:  ['ffmpeg', '-c:v', 'h264_cuvid', '-i', './myvideo.mp4', '-f', 'image2pipe', '-pix_fmt', 'yuv420p', '-']
    read time:  5.251002073287964
    1/61137 (0.00%)read time:  2.290238618850708
    2/61137 (0.00%)read time:  1.2984871864318848
    3/61137 (0.00%)read time:  2.2100613117218018
    4/61137 (0.01%)read time:  2.3444178104400635
  • Prevent FFmpeg from closing when a named pipe has been read completely

    21 octobre 2019, par Werther Berselli

    I’m doing a C++ application for a university project that takes a video file (e.g. matroska) and using FFmpeg (embedding commands inside std::system() instructions) apply these steps :

    • Extract chunks of frames (e.g. 10 seconds per chunk) and chunks of .aac audio

    • Apply some filters to frames

    • Encode video chunk and audio chunk with x264 and send it to a listening client using RTSP. This step is achieved using two named pipes, one for video and one for audio.

    • Receive the stream into another process and play it using ffplay (on localhost or lan).

    I need to divide my stream in chunks because I need eventually to satisfy real-time constraints, so I can’t apply filters before to my entire input video file and only then start streaming to client.
    My primary problem here is that once FFmpeg has emptied the two pipes, it close ; but other chunks of video and audio have still to be piped and streamed. I need FFmpeg to listen to the pipes waiting for new data.

    In bash I achieved this with the following commands.

    Start to listen in a prompt for a RTSP stream :

    ffplay -rtsp_flags listen rtsp://127.0.0.1@127.0.0.1:8090

    Create a video named pipe and an audio named pipe :

    mkfifo video_pipe
    mkfifo audio_pipe

    Use this command to prevent FFmpeg to close when video pipe is emptied :

    exec 7<>video_pipe

    (it is sufficient to apply it to the pipe video and neither will the audio pipe give problems)

    Activate FFmpeg command

    ffmpeg -probesize 2147483647 -re -s 1280x720 -pix_fmt rgb24 -i pipe:0 -vsync 0 -i audio_pipe -r 25 -vcodec libx264 -crf 23 -preset ultrafast -f rtsp -rtsp_transport tcp rtsp://127.0.0.1@127.0.0.1:8090 < video_pipe

    And then feed the pipes in another prompt :

    cat audiochunk.aac > audio_pipe & cat frame*.bmp > video_pipe

    These commands work well using 3 prompts, then I tried them in C++ embedding commands in std::system() instructions (using different threads) ; everything works, but once ffmpeg command empty the video pipe (finishing first chunk), it closes.
    exec command seems to be uneffective here.
    How could I prevent FFmpeg from closing ?

    Two days struggling on that problem, viewing all possible internet solution. I hope I was clear despite a great headache, thanks for your suggestions in advance.

    UPDATE :
    My C++ code is something like this ; I putted it in a single function on a single thread, but it doesn’t change it’s behaviour.
    I’m on Ubuntu 18.04.2

    void CameraThread::ffmpegJob()
    {
       std::string strvideo_length, command, timing;
       long video_length, begin_chunk, end_chunk;
       int begin_h, begin_m, begin_s, end_h, end_m, end_s;

       command = "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 " + Configurations::file_name;
       strvideo_length = execCmd(command.c_str());
       strvideo_length.pop_back(); // remove \n character
       video_length = strToPositiveDigit(strvideo_length);

       if(video_length == -1)
       {
           std::cout << "Invalid input file";
           return;
       }

       std::system("bash -c \"rm mst-temp/mst_video_pipe\"");
       std::system("bash -c \"rm mst-temp/mst_audio_pipe\"");
       std::system("bash -c \"mkfifo mst-temp/mst_video_pipe\"");
       std::system("bash -c \"mkfifo mst-temp/mst_audio_pipe\"");
       // Keep video pipe opened
       std::system("bash -c \"exec 7<>mst-temp/mst_video_pipe\"");

       std::string rtsp_url = "rtsp://" + Configurations::my_own_used_ip + "@" + Configurations::client_ip +
               ":" + std::to_string(Configurations::port + 1);

       command = "ffmpeg -probesize 2147483647 -re -s 1280x720 -pix_fmt rgb24 -i pipe:0 "
                 "-i mst-temp/mst_audio_pipe -r 25 -vcodec libx264 -crf 23 -preset ultrafast -f rtsp "
                 "-rtsp_transport tcp " + rtsp_url + " < mst-temp/mst_video_pipe &"; // Using & to continue without block on command
       std::system(command.c_str());

       begin_chunk = -1 * VIDEO_CHUNK;
       end_chunk = 0;

       // Extract the complete audio track
       command = "bash -c \"ffmpeg -i " + Configurations::file_name + " -vn mst-temp/audio/complete.aac -y\"";
       std::system(command.c_str());

       while(true)
       {
           // Define the actual video chunk (in seconds) to use, if EOF is reached, exit
           begin_chunk += (end_chunk - begin_chunk);
           if(begin_chunk == video_length)
               break;
           if(end_chunk + VIDEO_CHUNK <= video_length)
               end_chunk += VIDEO_CHUNK;
           else
               end_chunk += (video_length - end_chunk);

           // Set begin and end H, M, S variables
           begin_h = static_cast<int>(begin_chunk / 3600);
           begin_chunk -= (begin_h * 3600);
           begin_m = static_cast<int>(begin_chunk / 60);
           begin_chunk -= (begin_m * 60);
           begin_s = static_cast<int>(begin_chunk);
           end_h = static_cast<int>(end_chunk / 3600);
           end_chunk -= (end_h * 3600);
           end_m = static_cast<int>(end_chunk / 60);
           end_chunk -= (end_m * 60);
           end_s = static_cast<int>(end_chunk);

           // Extract bmp frames and audio from video chunk
           // Extract frames
           timing = " -ss " + std::to_string(begin_h) + ":" + std::to_string(begin_m) +
                   ":" + std::to_string(begin_s) + " -to " + std::to_string(end_h) +
                   ":" + std::to_string(end_m) + ":" + std::to_string(end_s);
           command = "bash -c \"ffmpeg -i " + Configurations::file_name + timing +
                   " -compression_algo raw -pix_fmt rgb24 mst-temp/frames/output%03d.bmp\"";
           std::system(command.c_str());
           // Extract audio
           command = "bash -c \"ffmpeg -i mst-temp/audio/complete.aac" + timing +
                   " -vn mst-temp/audio/audiochunk.aac -y\"";
           std::system(command.c_str());

           // Apply elaborations on audio and frames.........................

           // Write modified audio and frames to streaming pipes
           command = "bash -c \"cat mst-temp/audio/audiochunk.aac > mst-temp/mst_audio_pipe &amp; "
                     "cat mst-temp/frames/output*.bmp > mst-temp/mst_video_pipe\"";
           std::system(command.c_str());
       }
    }
    </int></int></int></int></int></int>