Recherche avancée

Médias (91)

Autres articles (66)

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

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

Sur d’autres sites (13921)

  • Streaming a programatically created video to youtube using node and ffmpeg

    23 septembre 2020, par Caltrop

    I've been trying to Livestream a programmatically created image to youtube using node. I've had very limited success using FFmpeg. While I have managed to create and save an image thanks to this insightful thread, I have yet to make the code work for streaming to an RTMP server.

    


    const cp = require('child_process'),
    destination = 'rtmp://a.rtmp.youtube.com/live2/[redacted]', //stream token redacted
    proc = cp.spawn('./ffmpeg/bin/ffmpeg.exe', [
        '-f', 'rawvideo',
        '-pix_fmt', 'rgb24',
        '-s', '426x240',
        '-i', '-', //allow us to insert a buffer through stdin
        '-f', 'flv',
        destination
    ]);

proc.stderr.pipe(process.stdout);

(function loop() {
    setTimeout(loop, 1000 / 30); //run loop at 30 fps
    const data = Array.from({length: 426 * 240 * 4}, () => ~~(Math.random() * 0xff)); //create array with random data
    proc.stdin.write(Buffer.from(data)); //convert array to buffer and send it to ffmpeg
})();


    


    When running this code no errors appear and everything appears to be working, however, YouTube reports that no data is being received. Does anybody know what is going wrong here ?

    


    Update : This is really counter-intuitive but adding a slash to the destination like this 'rtmp://a.rtmp.youtube.com/live2/[redacted]/' causes ffmpeg to throw a generic I/O error. This is really weird to me. Apologies if the answer to this is obvious, I'm really inexperienced with ffmpeg.

    


  • FFmpeg conversion RGB to YUV420 to RGB wrong result

    29 août 2020, par sipwiz

    I'm attempting to sort out a video encoding issue and along the way making sure I can convert between pixel formats with FFmpeg. I'm having a problem converting a dummy RGB24 bitmap to YUV420 and back again.

    


    Below is my test program :

    


    #include "Windows.h"&#xA;&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavformat></libavformat>avio.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>time.h>&#xA;&#xA;#define WIDTH 32&#xA;#define HEIGHT 32&#xA;#define ERROR_LEN 128&#xA;#define SWS_FLAGS SWS_BICUBIC&#xA;&#xA;char _errorLog[ERROR_LEN];&#xA;void CreateBitmapFile(LPCWSTR fileName, long width, long height, WORD bitsPerPixel, BYTE* bitmapData, DWORD bitmapDataLength);&#xA;&#xA;int main()&#xA;{&#xA;  printf("FFmpeg Pixel Conversion Test\n");&#xA;&#xA;  av_log_set_level(AV_LOG_DEBUG);&#xA;&#xA;  int w = WIDTH;&#xA;  int h = HEIGHT;&#xA;&#xA;  struct SwsContext* rgbToI420Context;&#xA;  struct SwsContext* i420ToRgbContext;&#xA;&#xA;  rgbToI420Context = sws_getContext(w, h, AV_PIX_FMT_RGB24, w, h, AV_PIX_FMT_YUV420P, SWS_FLAGS, NULL, NULL, NULL);&#xA;  if (rgbToI420Context == NULL) {&#xA;    fprintf(stderr, "Failed to allocate RGB to I420 conversion context.\n");&#xA;  }&#xA;&#xA;  i420ToRgbContext = sws_getContext(w, h, AV_PIX_FMT_YUV420P, w, h, AV_PIX_FMT_RGB24, SWS_FLAGS, NULL, NULL, NULL);&#xA;  if (i420ToRgbContext == NULL) {&#xA;    fprintf(stderr, "Failed to allocate I420 to RGB conversion context.\n");&#xA;  }&#xA;&#xA;  // Create dummy bitmap.&#xA;  uint8_t rgbRaw[WIDTH * HEIGHT * 3];&#xA;  for (int row = 0; row &lt; 32; row&#x2B;&#x2B;)&#xA;  {&#xA;    for (int col = 0; col &lt; 32; col&#x2B;&#x2B;)&#xA;    {&#xA;      int index = row * WIDTH * 3 &#x2B; col * 3;&#xA;&#xA;      int red = (row &lt; 16 &amp;&amp; col &lt; 16) ? 255 : 0;&#xA;      int green = (row &lt; 16 &amp;&amp; col > 16) ? 255 : 0;&#xA;      int blue = (row > 16 &amp;&amp; col &lt; 16) ? 255 : 0;&#xA;&#xA;      rgbRaw[index] = (byte)red;&#xA;      rgbRaw[index &#x2B; 1] = (byte)green;&#xA;      rgbRaw[index &#x2B; 2] = (byte)blue;&#xA;    }&#xA;  }&#xA;&#xA;  CreateBitmapFile(L"test-reference.bmp", WIDTH, HEIGHT, 24, rgbRaw, WIDTH * HEIGHT * 3);&#xA;&#xA;  printf("Converting RGB to I420.\n");&#xA;&#xA;  uint8_t* rgb[3];&#xA;  uint8_t* i420[3];&#xA;  int rgbStride[3], i420Stride[3];&#xA;&#xA;  rgbStride[0] = w * 3;&#xA;  i420Stride[0] = w * h;&#xA;  i420Stride[1] = w * h / 4;&#xA;  i420Stride[2] = w * h / 4;&#xA;&#xA;  rgb[0] = rgbRaw;&#xA;  i420[0] = (uint8_t*)malloc((size_t)i420Stride[0] * h);&#xA;  i420[1] = (uint8_t*)malloc((size_t)i420Stride[1] * h);&#xA;  i420[2] = (uint8_t*)malloc((size_t)i420Stride[2] * h);&#xA;&#xA;  int toI420Res = sws_scale(rgbToI420Context, rgb, rgbStride, 0, h, i420, i420Stride);&#xA;  if (toI420Res &lt; 0) {&#xA;    fprintf(stderr, "Conversion from RGB to I420 failed, %s.\n", av_make_error_string(_errorLog, ERROR_LEN, toI420Res));&#xA;  }&#xA;&#xA;  printf("Converting I420 to RGB.\n");&#xA;&#xA;  uint8_t* rgbOut[3];&#xA;  int rgbOutStride[3];&#xA;&#xA;  rgbOutStride[0] = w * 3;&#xA;  rgbOut[0] = (uint8_t*)malloc((size_t)rgbOutStride[0] * h);&#xA;&#xA;  int toRgbRes = sws_scale(i420ToRgbContext, i420, i420Stride, 0, h, rgbOut, rgbOutStride);&#xA;  if (toRgbRes &lt; 0) {&#xA;    fprintf(stderr, "Conversion from RGB to I420 failed, %s.\n", av_make_error_string(_errorLog, ERROR_LEN, toRgbRes));&#xA;  }&#xA;&#xA;  CreateBitmapFile(L"test-output.bmp", WIDTH, HEIGHT, 24, rgbOut, WIDTH * HEIGHT * 3);&#xA;&#xA;  free(rgbOut[0]);&#xA;&#xA;  for (int i = 0; i &lt; 3; i&#x2B;&#x2B;) {&#xA;    free(i420[i]);&#xA;  }&#xA;&#xA;  sws_freeContext(rgbToI420Context);&#xA;  sws_freeContext(i420ToRgbContext);&#xA;&#xA;  return 0;&#xA;}&#xA;&#xA;/**&#xA;* Creates a bitmap file and writes to disk.&#xA;* @param[in] fileName: the path to save the file at.&#xA;* @param[in] width: the width of the bitmap.&#xA;* @param[in] height: the height of the bitmap.&#xA;* @param[in] bitsPerPixel: colour depth of the bitmap pixels (typically 24 or 32).&#xA;* @param[in] bitmapData: a pointer to the bytes containing the bitmap data.&#xA;* @param[in] bitmapDataLength: the number of pixels in the bitmap.&#xA;*/&#xA;void CreateBitmapFile(LPCWSTR fileName, long width, long height, WORD bitsPerPixel, BYTE* bitmapData, DWORD bitmapDataLength)&#xA;{&#xA;  HANDLE file;&#xA;  BITMAPFILEHEADER fileHeader;&#xA;  BITMAPINFOHEADER fileInfo;&#xA;  DWORD writePosn = 0;&#xA;&#xA;  file = CreateFile(fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);  //Sets up the new bmp to be written to&#xA;&#xA;  fileHeader.bfType = 19778;                                                                    //Sets our type to BM or bmp&#xA;  fileHeader.bfSize = sizeof(fileHeader.bfOffBits) &#x2B; sizeof(RGBTRIPLE);                         //Sets the size equal to the size of the header struct&#xA;  fileHeader.bfReserved1 = 0;                                                                   //sets the reserves to 0&#xA;  fileHeader.bfReserved2 = 0;&#xA;  fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) &#x2B; sizeof(BITMAPINFOHEADER);                                           //Sets offbits equal to the size of file and info header&#xA;  fileInfo.biSize = sizeof(BITMAPINFOHEADER);&#xA;  fileInfo.biWidth = width;&#xA;  fileInfo.biHeight = height;&#xA;  fileInfo.biPlanes = 1;&#xA;  fileInfo.biBitCount = bitsPerPixel;&#xA;  fileInfo.biCompression = BI_RGB;&#xA;  fileInfo.biSizeImage = width * height * (bitsPerPixel / 8);&#xA;  fileInfo.biXPelsPerMeter = 2400;&#xA;  fileInfo.biYPelsPerMeter = 2400;&#xA;  fileInfo.biClrImportant = 0;&#xA;  fileInfo.biClrUsed = 0;&#xA;&#xA;  WriteFile(file, &amp;fileHeader, sizeof(fileHeader), &amp;writePosn, NULL);&#xA;&#xA;  WriteFile(file, &amp;fileInfo, sizeof(fileInfo), &amp;writePosn, NULL);&#xA;&#xA;  WriteFile(file, bitmapData, bitmapDataLength, &amp;writePosn, NULL);&#xA;&#xA;  CloseHandle(file);&#xA;}&#xA;

    &#xA;

    The source bitmap is :

    &#xA;

    Reference bitmap

    &#xA;

    The output bmp after the two conversions is :

    &#xA;

    Output bitmap

    &#xA;

  • ffmpeg -var_stream_map Invalid keyval "v:0

    22 septembre 2020, par rmrf fly

    the ffmpeg command is correct,

    &#xA;

    use ffmpeg command execute at command line is ok,

    &#xA;

    int windows10 use java exec the command is ok ,

    &#xA;

    by only in linux when i use java exec the ffmpeg command throw expection

    &#xA;

    the command :

    &#xA;

    ffmpeg -i /data/vsftpd/Anchor.mp4 -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" -hls_segment_filename &#x27;file_%v_%03d.ts&#x27; out_%v.m3u8&#xA;

    &#xA;

    enter image description here

    &#xA;

    [hls @ 0xd31b5c0] Invalid keyval "v:0&#xA;[hls @ 0xd31b5c0] Variant stream info update failed with status ffffffea&#xA;Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument&#xA;

    &#xA;

    jar

    &#xA;

    <dependency>&#xA;   <groupid>org.apache.commons</groupid>&#xA;   <artifactid>commons-exec</artifactid>&#xA;   <version>1.3</version>&#xA;</dependency>&#xA;

    &#xA;

    java code

    &#xA;

    public static int exeCommand(String command, OutputStream out) throws ExecuteException, IOException {&#xA;    CommandLine commandLine = CommandLine.parse(command);&#xA;    PumpStreamHandler pumpStreamHandler = null;&#xA;    if (null == out) {&#xA;        pumpStreamHandler = new PumpStreamHandler();&#xA;    } else {&#xA;        pumpStreamHandler = new PumpStreamHandler(out);&#xA;    }&#xA;&#xA;    // time out 10s&#xA;    ExecuteWatchdog watchdog = new ExecuteWatchdog(10000);&#xA;&#xA;    DefaultExecutor executor = new DefaultExecutor();&#xA;    executor.setStreamHandler(pumpStreamHandler);&#xA;    //executor.setWatchdog(watchdog);&#xA;&#xA;    return executor.execute(commandLine);&#xA;}&#xA;

    &#xA;