Recherche avancée

Médias (91)

Autres articles (65)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • 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 (6334)

  • libswscale error Slice Parameters 0, 1080 are invalid

    3 mai 2023, par lokit khemka

    I am trying to scale a video from 1080p to 480p. For that, I have setup swscaler context as :

    


    encoder_sc->sws_ctx = sws_getContext(1920, 1080,
                            AV_PIX_FMT_YUV420P, 
                           854, 480, AV_PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL );


    


    However, when I am calling the scale frame function as

    


    sws_scale_frame(encoder->sws_ctx, input_frame, input_frame);


    


    However, when I do that I am getting the error Slice parameter 0, 1080 are in valid. I am very new to FFMPEG and video processing in general. I could not find any solution while searching. Any help is greatly appreciated.

    


    EDIT : I am including the entire source code because I cannot seem to solve the issue.

    


    

typedef struct StreamingContext{
    AVFormatContext* avfc;
    AVCodec *video_avc;
    AVCodec *audio_avc;
    AVStream *video_avs;
    AVStream *audio_avs;
    AVCodecContext *video_avcc;
    AVCodecContext *audio_avcc;
    int video_index;
    int audio_index;
    char* filename;
    struct SwsContext *sws_ctx;
}StreamingContext;


typedef struct StreamingParams{
    char copy_video;
    char copy_audio;
    char *output_extension;
    char *muxer_opt_key;
    char *muxer_opt_value;
    char *video_codec;
    char *audio_codec;
    char *codec_priv_key;
    char *codec_priv_value;
}StreamingParams;


int prepare_video_encoder(StreamingContext *encoder_sc, AVCodecContext *decoder_ctx, AVRational input_framerate,
                          StreamingParams sp)
{
    encoder_sc->video_avs = avformat_new_stream(encoder_sc->avfc, NULL);
    encoder_sc->video_avc = avcodec_find_encoder_by_name(sp.video_codec);
    if (!encoder_sc->video_avc)
    {
        logging("Cannot find the Codec.");
        return -1;
    }

    encoder_sc->video_avcc = avcodec_alloc_context3(encoder_sc->video_avc);
    if (!encoder_sc->video_avcc)
    {
        logging("Could not allocate memory for Codec Context.");
        return -1;
    }

    av_opt_set(encoder_sc->video_avcc->priv_data, "preset", "fast", 0);
    if (sp.codec_priv_key && sp.codec_priv_value)
        av_opt_set(encoder_sc->video_avcc->priv_data, sp.codec_priv_key, sp.codec_priv_value, 0);

    encoder_sc->video_avcc->height = decoder_ctx->height;
    encoder_sc->video_avcc->width = decoder_ctx->width;
    encoder_sc->video_avcc->sample_aspect_ratio = decoder_ctx->sample_aspect_ratio;

    if (encoder_sc->video_avc->pix_fmts)
        encoder_sc->video_avcc->pix_fmt = encoder_sc->video_avc->pix_fmts[0];
    else
        encoder_sc->video_avcc->pix_fmt = decoder_ctx->pix_fmt;

    encoder_sc->video_avcc->bit_rate = 2 * 1000 * 1000;
    encoder_sc->video_avcc->rc_buffer_size = 4 * 1000 * 1000;
    encoder_sc->video_avcc->rc_max_rate = 2 * 1000 * 1000;
    encoder_sc->video_avcc->rc_min_rate = 2.5 * 1000 * 1000;

    encoder_sc->video_avcc->time_base = av_inv_q(input_framerate);
    encoder_sc->video_avs->time_base = encoder_sc->video_avcc->time_base;

    //Creating Scaling Context
    encoder_sc->sws_ctx = sws_getContext(1920, 1080,
                            decoder_ctx->pix_fmt, 
                           854, 480, encoder_sc->video_avcc->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL );
    if (!encoder_sc->sws_ctx){logging("Cannot Create Scaling Context."); return -1;}

    if (avcodec_open2(encoder_sc->video_avcc, encoder_sc->video_avc, NULL) < 0)
    {
        logging("Could not open the Codec.");
        return -1;
    }
    avcodec_parameters_from_context(encoder_sc->video_avs->codecpar, encoder_sc->video_avcc);
    return 0;
}



int transcode_video(StreamingContext *decoder, StreamingContext *encoder, AVPacket *input_packet, AVFrame *input_frame, AVFrame *scaled_frame)
{
    int response = avcodec_send_packet(decoder->video_avcc, input_packet);
    if (response < 0)
    {
        logging("Error while sending the Packet to Decoder: %s", av_err2str(response));
        return response;
    }

    while (response >= 0)
    {
        response = avcodec_receive_frame(decoder->video_avcc, input_frame);
        
        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)
        {
            break;
        }
        else if (response < 0)
        {
            logging("Error while receiving frame from Decoder: %s", av_err2str(response));
            return response;
        }
        if (response >= 0)
        {
            scaled_frame->format = encoder->video_avcc->pix_fmt;
            scaled_frame->width = 854;
            scaled_frame->height = 480;
            sws_scale_frame(encoder->sws_ctx, scaled_frame, input_frame);
            //ERROR is in the scaled_frame
            if (encode_video(decoder, encoder, scaled_frame)) 
                return -1;
        }

        av_frame_unref(input_frame);
    }
    return 0;
}



    


  • Make 2 videos on top of each other in a 1080×1920 scene

    6 octobre 2023, par Byte me

    I am trying to make two videos on top of each other. Right now i am scaling both to 1080x960 using ffmpeg and putting them together using vstack. Unfortunetely no success. Can anyone help me ?

    


      ffmpeg()
      .input('./placeholder.mp4').videoCodec('copy')
      .input("./scaled_YT.mp4").videoCodec('copy')
      .complexFilter([
        `[0:v]scale=1080x960[v0];[1:v]scale=1080x960[v1];[v0][v1]vstack=inputs=2[v]`
    ], ['v'])
      .toFormat('mp4')
      .on('end', () => {
          console.log('Files have been merged!');
      })
      .on('error', (err) => {
          console.error('Error:', err)
      })
      .save(outputPath);


    


    Error: Error: ffmpeg exited with code 1: &#xA;    at ChildProcess.<anonymous> (D:\Discord Bots\TEMP_TEST\done_projects\videoEditor_bot\node_modules\fluent-ffmpeg\lib\processor.js:182:22)  &#xA;    at ChildProcess.emit (node:events:513:28)&#xA;    at ChildProcess._handle.onexit (node:internal/child_process:291:12)&#xA;</anonymous>

    &#xA;

  • Create video with size based on image and place a video somewhere with an offset

    10 mars 2024, par NoKey

    I am trying out FFMPEG and I am unsure how hard it is to do what I want. I have some device frames and I want to play a video inside the frame. For example, this is a device frame :

    &#xA;

    enter image description here

    &#xA;

    Now I want to play a video within the screen of the iPhone. I already got the exact X and Y offset where the video must be placed to show it correctly. I have the following challenges to make it work, and I want to make sure FFMPEG can do it before I spend to much time reinventing the wheel :

    &#xA;

      &#xA;
    • The output of the video must be as big as the PNG. This is already a&#xA;confusing part for me. I have the width and height already available,&#xA;but the things I saw is that FFMPEG will take over the input of the&#xA;video as final size. The final output of the video should of course&#xA;be the length of the input video.

      &#xA;

    • &#xA;

    • The background must be transparant (so no black background, I want to&#xA;play the video on top of a website so it's nice if it's transparant and the corners are not black).

      &#xA;

    • &#xA;

    • The ability to place a video somewhere with a specified X and Y&#xA;offset inside the device frame.

      &#xA;

    • &#xA;

    • Not sure if it's possible in the same command, but maybe the video&#xA;needs to be resized to make it fit. I got the exact dimensions for&#xA;the video.

      &#xA;

    • &#xA;

    &#xA;

    The things I struggle most is point 1 where the output video must have a transparant background and where the device frame is placed in. Does anybody got tips ?

    &#xA;