Recherche avancée

Médias (0)

Mot : - Tags -/signalement

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (23)

  • Emballe Médias : Mettre en ligne simplement des documents

    29 octobre 2010, par

    Le plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
    Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
    D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (4878)

  • Format video to upload on instagram API (Nodejs)

    6 octobre 2022, par Rafael de Carvalho

    I'm trying to automate the process of posting photos and videos on instagram but I constantly get errors when uploading to instagram.

    


    I will leave a video duration error here but several others happen, I need to follow the following requirements :

    


      

    • Container : MOV or MP4 (MPEG-4 Part 14), no edit lists, atom moov in front of file
    • 


    • Audio codec : AAC, 48 kHz maximum sampling rate, 1 or 2 channel (mono or stereo)
    • 


    • Video codec : HEVC or H.264, progressive scan, closed GOP, 4:2:0 chroma subsampling
    • 


    • Frame rate : from 23 to 60 FPS
    • 


    • photo size :

        

      • Maximum columns (horizontal pixels) : 1,920
      • 


      • Minimum aspect ratio [columns/rows] : 4/5
      • 


      • Maximum aspect ratio [columns/rows] : 9/16
      • 


      


    • 


    • Video bitrate : 5Mbps maximum VBR
    • 


    • Audio bitrate : 128 kbps
    • 


    • Duration : maximum 60 seconds and minimum 3 seconds
    • 


    • File size : max 100 MB
    • 


    


    My code :

    


    import { S3 } from 'aws-sdk';
import { IgApiClient } from 'instagram-private-api';
import fs from 'fs';

const s3 = new S3();
const ig = new IgApiClient();
const bucket = 'posts';
const { INSTA_USER, INSTA_PASS } = process.env;

ig.state.generateDevice(INSTA_USER);

export const main = async () => {
  try {
    await ig.account.login(INSTA_USER, INSTA_PASS);

    const { Contents } = await s3.listObjectsV2({ Bucket: bucket, MaxKeys: 2, Prefix: 'memes/geral' }).promise();

    const files = await Promise.all(Contents.map(async ({ Key }) => {
      const file = await s3.getObject({
        Bucket: bucket,
        Key,
      }).promise();

      return file.Body;
    }));

    const publishResult = await ig.publish.video({
      video: files[0],
      coverImage: await fs.readFileAsync("../../src/assets/cover.png")
    });

    console.dir({ publishResult }, { depth: null })
  } catch (error) {
    console.error(error);
    throw error;
  }
}


    


    When I get a file from s3, it comes in the following format.
I'm taking the content of the body property and put it in the video property of the publish method.
Is it right ?
I also tried to save the file with fs.writeFile and dps use readFileSync like in the example but it also gave the same error.

    


    {
    AcceptRanges: 'bytes',
    LastModified: 2022-08-04T23:15:24.000Z,
    ContentLength: 3252472,
    ETag: '"c491cfe2fb5bc29777fc34391fc1d56a"',
    ContentType: 'application/octet-stream',
    Body: Buffer(3252472) [Uint8Array] [
        0,   0,   0,  32, 102, 116, 121, 112, 105, 115, 111, 109,
        0,   0,   2,   0, 105, 115, 111, 109, 105, 115, 111,  50,
       97, 118,  99,  49, 109, 112,  52,  49,   0,   0, 209,   0,
      109, 111, 111, 118,   0,   0,   0, 108, 109, 118, 104, 100,
        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        0,   0,   3, 232,   0,   0, 250,  17,   0,   1,   0,   0,
        1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
        0,   0,   0,   0,
      ... 3252372 more items
    ]
  }


    


    Error :

    


    {
    "errorMessage": "POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceDurationCheckException",
    "errorType": "IgUploadVideoError",
    "stackTrace": [
        "IgUploadVideoError: POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceDurationCheckException",
        "    at C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\instagram-private-api\\dist\\services\\publish.service.js:26:1",  
        "    at tryCatcher (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\bluebird\\js\\release\\util.js:16:1)"
}


    


    when I try to post a video under 60 seconds (apparently within the requirements) :

    


    {
    "errorMessage": "POST /api/v1/media/configure/?video=1 - 403 Forbidden; ",
    "errorType": "IgConfigureVideoError",
    "stackTrace": [
        "IgConfigureVideoError: POST /api/v1/media/configure/?video=1 - 403 Forbidden; ",
        "    at PublishService.video (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\instagram-private-api\\dist\\services\\publish.service.js:123:1)",        
        "    at C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\src\\functions\\cronFreefireMemes.js:71:31",
        "    at async Promise.all (index 1)",
        "    at main (C:\\Users\\User\\Desktop\\dev\\Insta\\.webpack\\service\\src\\functions\\webpack:\\src\\functions\\cronFreefireMemes.js:47:5)"
    ]
}


    


    I know that the error above is happening because of the size of the video which is longer than 60 seconds.

    


    But I would like to know if there is any way I can format any video to fit the instagram requirements.

    


    Any nodejs library ?

    


  • FFMPEG(Libav)-Creating AVpackets from Network Packets(TCP) Using av_parser_parse2() Function

    21 août 2022, par Batuhan Zorlu

    I am developing one software that takes frames using OpenCV then sends them over network. I was using RTMP protocol for that, i have created one middle rtmp server and solved it.However, i had to solve the problem using TCP. On the sender side I do not face any problem, i can smoothly convert From cv::Mat-> AVframe->Avpacket and send it over network.
However, on the receiver side, i can not create AVframes.
This is my sender code(dont have any issue, it sends over TCP AS EXPECTED) :

    


    void write_frame(AVCodecContext *codec_ctx, AVFormatContext *fmt_ctx, AVFrame *frame)&#xA;{&#xA;AVPacket pkt = { 0 };&#xA;av_new_packet(&amp;pkt, 0);&#xA;&#xA;int ret = avcodec_send_frame(codec_ctx, frame);&#xA;if (ret &lt; 0)&#xA;{&#xA;    std::cout &lt;&lt; "Error sending frame to codec context!" &lt;&lt; std::endl;&#xA;    exit(1);&#xA;}&#xA;&#xA;ret = avcodec_receive_packet(codec_ctx, &amp;pkt);&#xA;if (ret &lt; 0)&#xA;{&#xA;    std::cout &lt;&lt; "Error receiving packet from codec context!" &lt;&lt; std::endl;&#xA;    exit(1);&#xA;}&#xA;av_interleaved_write_frame(fmt_ctx, &amp;pkt);&#xA;av_packet_unref(&amp;pkt);&#xA;}&#xA;&#xA;void stream_video(double width, double height, int fps, int camID, int bitrate, std::string &#xA;codec_profile, std::string server)&#xA;{&#xA;#if LIBAVCODEC_VERSION_INT &lt; AV_VERSION_INT(58, 9, 100)&#xA;av_register_all();&#xA;#endif&#xA;avformat_network_init();&#xA;&#xA;const char *output = server.c_str();&#xA;int ret;&#xA;auto cam = get_device(camID, width, height);&#xA;std::vector imgbuf(height * width * 3 &#x2B; 16);&#xA;cv::Mat image(height, width, CV_8UC3, imgbuf.data(), width * 3);&#xA;AVFormatContext *ofmt_ctx = nullptr;&#xA;AVCodec *out_codec = nullptr;&#xA;AVStream *out_stream = nullptr;&#xA;AVCodecContext *out_codec_ctx = nullptr;&#xA;&#xA;initialize_avformat_context(ofmt_ctx, "flv");&#xA;initialize_io_context(ofmt_ctx, output);&#xA;&#xA;out_codec = const_cast(avcodec_find_encoder(AV_CODEC_ID_H264));&#xA;out_stream = avformat_new_stream(ofmt_ctx, out_codec);&#xA;out_codec_ctx = avcodec_alloc_context3(out_codec);&#xA;&#xA;set_codec_params(ofmt_ctx, out_codec_ctx, width, height, fps, bitrate);&#xA;initialize_codec_stream(out_stream, out_codec_ctx, (out_codec), codec_profile);&#xA;&#xA;out_stream->codecpar->extradata = out_codec_ctx->extradata;&#xA;out_stream->codecpar->extradata_size = out_codec_ctx->extradata_size;&#xA;&#xA;av_dump_format(ofmt_ctx, 0, output, 1);&#xA;&#xA;auto *swsctx = initialize_sample_scaler(out_codec_ctx, width, height);&#xA;auto *frame = allocate_frame_buffer(out_codec_ctx, width, height);&#xA;&#xA;int cur_size;&#xA;uint8_t *cur_ptr;&#xA;&#xA;ret = avformat_write_header(ofmt_ctx, nullptr);&#xA;if (ret &lt; 0)&#xA;{&#xA;    std::cout &lt;&lt; "Could not write header!" &lt;&lt; std::endl;&#xA;    exit(1);&#xA;}&#xA;&#xA;bool end_of_stream = false;&#xA;do&#xA;{&#xA;    cam >> image;&#xA;    const int stride[] = { static_cast<int>(image.step[0]) };&#xA;    sws_scale(swsctx, &amp;image.data, stride, 0, image.rows, frame->data, frame->linesize);&#xA;    frame->pts &#x2B;= av_rescale_q(1, out_codec_ctx->time_base, out_stream->time_base);&#xA;    write_frame(out_codec_ctx, ofmt_ctx, frame);&#xA;} while (!end_of_stream);&#xA;&#xA;av_write_trailer(ofmt_ctx);&#xA;&#xA;av_frame_free(&amp;frame);&#xA;avcodec_close(out_codec_ctx);&#xA;avio_close(ofmt_ctx->pb);&#xA;avformat_free_context(ofmt_ctx);&#xA;}&#xA;</int>

    &#xA;

    This is my receiver code that i have too many questions :

    &#xA;

    1.av_parser_parse2(acpc, out_codec_ctx, &pkt_demo->data, &out_buff_size, (uint8_t*)buffer_data, buffer_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0).

    &#xA;

    As i understand, this function takes bytes untill it can create AVpacket.(In my case this function for twice, in the first one reads as big as my buffer size (4096), at the second one it reads about 2900, then goes the decoding line.)&#xA;My questions about this function,&#xA;It takes AVpacket.pts, AVpacket.dst and AVpacket.pos but, while i am receiving some bytes how can I pass those variables.(I am already trying to fill AVpacket).&#xA;After passing this function, i am having error in int response = avcodec_send_packet(pCodecContext, pPacket), line. The error :The error&#xA;And sometimes getting this error :The error-2

    &#xA;

        ////////CONFIG CODEC CONTEXT&#xA;&#xA;avcodec_open2(out_codec_ctx, out_codec, NULL);&#xA;&#xA;////////PARSER INITIALIZATION&#xA;AVCodecParserContext * acpc = av_parser_init(AV_CODEC_ID_H264);&#xA;uint8_t* out_buff;&#xA;int out_buff_size;&#xA;&#xA;////////PARSER INITIALIZATION&#xA;size_t buffer_size = 4096;&#xA;uint8_t* buffer_data = new uint8_t[buffer_size];&#xA;//AVPacket pkt_demo;&#xA;&#xA;AVPacket *pkt_demo = av_packet_alloc();&#xA;AVFrame *pFrame = av_frame_alloc();&#xA;int response = 0;&#xA;&#xA;&#xA;&#xA;while (recv(ClientSocket, (char*)buffer_data, buffer_size, 0) > 0) {&#xA;        int len = av_parser_parse2(acpc, out_codec_ctx, &amp;pkt_demo->data, &amp;out_buff_size, &#xA;(uint8_t*)buffer_data, buffer_size, pkt_demo->pts, pkt_demo->dts, -1);&#xA;        std::cout &lt;&lt; "READING!!!!" &lt;&lt; std::endl;&#xA;        if (out_buff_size > 0) {&#xA;            std::cout &lt;&lt; "started!!!!" &lt;&lt; std::endl;&#xA;            //pkt_demo->data = out_buff;&#xA;            pkt_demo->size = out_buff_size;&#xA;            response = decode_packet(pkt_demo, out_codec_ctx, pFrame);&#xA;            if (response &lt; 0)break;&#xA;        }&#xA;    av_packet_unref(pkt_demo);&#xA;}&#xA;delete[] buffer_data;&#xA;&#xA;static int decode_packet(AVPacket *pPacket, AVCodecContext *pCodecContext, AVFrame *pFrame)&#xA;{&#xA;&#xA;&#xA;int response = avcodec_send_packet(pCodecContext, pPacket);&#xA;std::cout &lt;&lt; response &lt;&lt; std::endl;&#xA;&#xA;if (response &lt; 0) {&#xA;&#xA;    return response;&#xA;}&#xA;&#xA;while (response >= 0)&#xA;{&#xA;    response = avcodec_receive_frame(pCodecContext, pFrame);&#xA;    if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;        break;&#xA;    }&#xA;    else if (response &lt; 0) {&#xA;&#xA;        return response;&#xA;    }&#xA;&#xA;}&#xA;return 0;&#xA;}&#xA;

    &#xA;

    In addition to that, i have checked the CodecContext, i have hardcoded every property on the receiver side, so they are the same.(Which also thisis another thing that confuses me, because AVpacket should have already have the context information right ?)

    &#xA;

  • About "ffmpeg -c copy" two ts files, can not play the problem

    4 septembre 2022, par Orlando Bloom

    aaa.mp4

    &#xA;

    General&#xA;Complete name                            : C:/aaa.mp4&#xA;Format                                   : MPEG-4&#xA;Format profile                           : Base Media&#xA;Codec ID                                 : isom (isom/iso2/avc1/mp41)&#xA;File size                                : 3.08 MiB&#xA;Duration                                 : 11 s 512 ms&#xA;Overall bit rate                         : 2 248 kb/s&#xA;Writing application                      : Lavf57.83.100&#xA;Comment                                  : GIFSHOW [899819595][iOS][11.4.1][iPhone9,2][5.8.5.606][Camera:f]#[720x1280][5327k][78k][C][1][tv=bec1_f80c][ags=0.455141][agm=0.747282][agsi=2000]&#xA;&#xA;Video&#xA;ID                                       : 1&#xA;Format                                   : AVC&#xA;Format/Info                              : Advanced Video Codec&#xA;Format profile                           : High@L3.1&#xA;Format settings                          : CABAC / 4 Ref Frames&#xA;Format settings, CABAC                   : Yes&#xA;Format settings, Reference frames        : 4 frames&#xA;Codec ID                                 : avc1&#xA;Codec ID/Info                            : Advanced Video Coding&#xA;Duration                                 : 11 s 512 ms&#xA;Bit rate                                 : 2 161 kb/s&#xA;Width                                    : 720 pixels&#xA;Height                                   : 1 280 pixels&#xA;Display aspect ratio                     : 0.563&#xA;Frame rate mode                          : Constant&#xA;Frame rate                               : 29.970 (29970/1000) FPS&#xA;Color space                              : YUV&#xA;Chroma subsampling                       : 4:2:0&#xA;Bit depth                                : 8 bits&#xA;Scan type                                : Progressive&#xA;Bits/(Pixel*Frame)                       : 0.078&#xA;Stream size                              : 2.96 MiB (96%)&#xA;Writing library                          : x264 core 148&#xA;Codec configuration box                  : avcC&#xA;&#xA;Audio&#xA;ID                                       : 2&#xA;Format                                   : AAC LC SBR&#xA;Format/Info                              : Advanced Audio Codec Low Complexity with Spectral Band Replication&#xA;Commercial name                          : HE-AAC&#xA;Format settings                          : Explicit&#xA;Codec ID                                 : mp4a-40-2&#xA;Duration                                 : 11 s 501 ms&#xA;Bit rate mode                            : Constant&#xA;Bit rate                                 : 78.8 kb/s&#xA;Channel(s)                               : 2 channels&#xA;Channel layout                           : L R&#xA;Sampling rate                            : 44.1 kHz&#xA;Frame rate                               : 21.533 FPS (2048 SPF)&#xA;Compression mode                         : Lossy&#xA;Stream size                              : 111 KiB (4%)&#xA;Default                                  : Yes&#xA;Alternate group                          : 1&#xA;&#xA;&#xA;

    &#xA;

    I want to merge this mp4 with another ts file, because my hardware configuration is very poor, so I choose "-c copy"

    &#xA;

    General&#xA;ID                                       : 1 (0x1)&#xA;Complete name                            : C:/bbb.ts&#xA;Format                                   : MPEG-TS&#xA;File size                                : 3.41 MiB&#xA;Duration                                 : 15 s 315 ms&#xA;Overall bit rate mode                    : Variable&#xA;Overall bit rate                         : 1 861 kb/s&#xA;&#xA;Video&#xA;ID                                       : 256 (0x100)&#xA;Menu ID                                  : 1 (0x1)&#xA;Format                                   : AVC&#xA;Format/Info                              : Advanced Video Codec&#xA;Format profile                           : High@L3.1&#xA;Format settings                          : CABAC / 4 Ref Frames&#xA;Format settings, CABAC                   : Yes&#xA;Format settings, Reference frames        : 4 frames&#xA;Codec ID                                 : 27&#xA;Duration                                 : 15 s 382 ms&#xA;Width                                    : 1 080 pixels&#xA;Height                                   : 606 pixels&#xA;Display aspect ratio                     : 16:9&#xA;Frame rate mode                          : Variable&#xA;Color space                              : YUV&#xA;Chroma subsampling                       : 4:2:0&#xA;Bit depth                                : 8 bits&#xA;Scan type                                : Progressive&#xA;&#xA;Audio&#xA;ID                                       : 257 (0x101)&#xA;Menu ID                                  : 1 (0x1)&#xA;Format                                   : AAC LC&#xA;Format/Info                              : Advanced Audio Codec Low Complexity&#xA;Format version                           : Version 4&#xA;Muxing mode                              : ADTS&#xA;Codec ID                                 : 15-2&#xA;Duration                                 : 15 s 185 ms&#xA;Bit rate mode                            : Variable&#xA;Channel(s)                               : 1 channel&#xA;Channel layout                           : C&#xA;Sampling rate                            : 44.1 kHz&#xA;Frame rate                               : 43.066 FPS (1024 SPF)&#xA;Compression mode                         : Lossy&#xA;Delay relative to video                  : -46 ms&#xA;&#xA;&#xA;&#xA;

    &#xA;

    I directly -c copy them, can't play the whole thing,

    &#xA;

    Then I convert aaa.mp4 to ts&#xA;using "ffmpeg -i aaa.mp4 -bsf:v h264_mp4toannexb -codec copy -hls_list_size 0 aaa.ts" , this is what I googled.

    &#xA;

    Finally tried aaa.ts and bbb.ts with "-c copy", still can't play.

    &#xA;

    My machine configuration is acceptable, convert aaa.mp4 to the same encoding as bbb.ts

    &#xA;

    If I transcode both together, I can't do it because bbb.ts is too big.

    &#xA;