Recherche avancée

Médias (0)

Mot : - Tags -/albums

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

Autres articles (65)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (8779)

  • x86 : replace explicit REP_RETs with RETs

    1er février 2023, par Lynne
    x86 : replace explicit REP_RETs with RETs
    

    From x86inc :
    > On AMD cpus <=K10, an ordinary ret is slow if it immediately follows either
    > a branch or a branch target. So switch to a 2-byte form of ret in that case.
    > We can automatically detect "follows a branch", but not a branch target.
    > (SSSE3 is a sufficient condition to know that your cpu doesn't have this problem.)

    x86inc can automatically determine whether to use REP_RET rather than
    REP in most of these cases, so impact is minimal. Additionally, a few
    REP_RETs were used unnecessary, despite the return being nowhere near a
    branch.

    The only CPUs affected were AMD K10s, made between 2007 and 2011, 16
    years ago and 12 years ago, respectively.

    In the future, everyone involved with x86inc should consider dropping
    REP_RETs altogether.

    • [DH] libavcodec/x86/aacpsdsp.asm
    • [DH] libavcodec/x86/ac3dsp.asm
    • [DH] libavcodec/x86/alacdsp.asm
    • [DH] libavcodec/x86/audiodsp.asm
    • [DH] libavcodec/x86/dirac_dwt.asm
    • [DH] libavcodec/x86/fft.asm
    • [DH] libavcodec/x86/flacdsp.asm
    • [DH] libavcodec/x86/h264_chromamc.asm
    • [DH] libavcodec/x86/h264_chromamc_10bit.asm
    • [DH] libavcodec/x86/h264_deblock_10bit.asm
    • [DH] libavcodec/x86/h264_idct.asm
    • [DH] libavcodec/x86/h264_idct_10bit.asm
    • [DH] libavcodec/x86/h264_intrapred.asm
    • [DH] libavcodec/x86/h264_intrapred_10bit.asm
    • [DH] libavcodec/x86/h264_qpel_10bit.asm
    • [DH] libavcodec/x86/h264_qpel_8bit.asm
    • [DH] libavcodec/x86/h264_weight.asm
    • [DH] libavcodec/x86/h264_weight_10bit.asm
    • [DH] libavcodec/x86/hevc_sao.asm
    • [DH] libavcodec/x86/hevc_sao_10bit.asm
    • [DH] libavcodec/x86/hpeldsp.asm
    • [DH] libavcodec/x86/hpeldsp_vp3.asm
    • [DH] libavcodec/x86/huffyuvdsp.asm
    • [DH] libavcodec/x86/jpeg2000dsp.asm
    • [DH] libavcodec/x86/lossless_videodsp.asm
    • [DH] libavcodec/x86/lossless_videoencdsp.asm
    • [DH] libavcodec/x86/me_cmp.asm
    • [DH] libavcodec/x86/pngdsp.asm
    • [DH] libavcodec/x86/qpel.asm
    • [DH] libavcodec/x86/qpeldsp.asm
    • [DH] libavcodec/x86/rv34dsp.asm
    • [DH] libavcodec/x86/rv40dsp.asm
    • [DH] libavcodec/x86/sbrdsp.asm
    • [DH] libavcodec/x86/takdsp.asm
    • [DH] libavcodec/x86/utvideodsp.asm
    • [DH] libavcodec/x86/v210.asm
    • [DH] libavcodec/x86/vc1dsp_mc.asm
    • [DH] libavcodec/x86/videodsp.asm
    • [DH] libavcodec/x86/vp8dsp.asm
    • [DH] libavfilter/x86/af_volume.asm
    • [DH] libavfilter/x86/avf_showcqt.asm
    • [DH] libavfilter/x86/scene_sad.asm
    • [DH] libavfilter/x86/vf_blend.asm
    • [DH] libavfilter/x86/vf_framerate.asm
    • [DH] libavfilter/x86/vf_gradfun.asm
    • [DH] libavfilter/x86/vf_hqdn3d.asm
    • [DH] libavfilter/x86/vf_interlace.asm
    • [DH] libavfilter/x86/vf_maskedmerge.asm
    • [DH] libavfilter/x86/vf_stereo3d.asm
    • [DH] libavfilter/x86/vf_w3fdif.asm
    • [DH] libavutil/x86/float_dsp.asm
    • [DH] libavutil/x86/lls.asm
    • [DH] libswresample/x86/audio_convert.asm
    • [DH] libswresample/x86/rematrix.asm
    • [DH] libswscale/x86/input.asm
    • [DH] libswscale/x86/output.asm
    • [DH] libswscale/x86/scale.asm
    • [DH] libswscale/x86/scale_avx2.asm
    • [DH] libswscale/x86/yuv2yuvX.asm
    • [DH] libswscale/x86/yuv_2_rgb.asm
    • [DH] tests/checkasm/x86/checkasm.asm
  • FFmpeg fails to draw text

    6 avril 2024, par Edoardo Balducci

    I've rarely used ffmpeg before, so, sorry If the question is too dumb.&#xA;I have a problem adding a text layer to a video frame using ffmpeg.

    &#xA;

    This is my current code :

    &#xA;

    import subprocess&#xA;from PyQt5.QtGui import QPixmap, QImage&#xA;from PyQt5.QtWidgets import QLabel&#xA;&#xA;class VideoThumbnailLabel(QLabel):&#xA;    def __init__(self, file_path, *args, **kwargs):&#xA;        super().__init__(*args, **kwargs)&#xA;        self.video = video&#xA;        video_duration = self.get_video_duration(file_path)&#xA;        thumbnail_path = self.get_thumbnail(file_path, video_duration)&#xA;        if thumbnail_path:&#xA;            self.setPixmap(QPixmap(thumbnail_path).scaled(160, 90, Qt.KeepAspectRatio))&#xA;        self.setToolTip(f"{video.title}\n{video.description}")&#xA;&#xA;    def get_video_duration(self, video_path):&#xA;        """Returns the duration of the video in seconds."""&#xA;        command = [&#xA;            &#x27;ffprobe&#x27;, &#x27;-v&#x27;, &#x27;error&#x27;, &#x27;-show_entries&#x27;,&#xA;            &#x27;format=duration&#x27;, &#x27;-of&#x27;,&#xA;            &#x27;default=noprint_wrappers=1:nokey=1&#x27;, video_path&#xA;        ]&#xA;        try:&#xA;            result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)&#xA;            if result.returncode != 0:&#xA;                print(f"ffprobe error: {result.stderr}")&#xA;                return 0&#xA;            duration = float(result.stdout)&#xA;            return int(duration)  # Returning duration as an integer for simplicity&#xA;        except Exception as e:&#xA;            print(f"Error getting video duration: {e}")&#xA;            return 0&#xA;&#xA;    def get_thumbnail(self, video_path, duration):&#xA;        """Generates a thumbnail with the video duration overlaid."""&#xA;        output_path = "thumbnail.jpg"  # Temporary thumbnail file&#xA;        duration_str = f"{duration // 3600:02d}:{(duration % 3600) // 60:02d}:{duration % 60:02d}"&#xA;        command = [&#xA;            &#x27;ffmpeg&#x27;, &#x27;-i&#x27;, video_path,&#xA;            &#x27;-ss&#x27;, &#x27;00:00:01&#x27;,  # Time to take the screenshot&#xA;            &#x27;-frames:v&#x27;, &#x27;1&#x27;,  # Number of frames to capture&#xA;            &#x27;-vf&#x27;, f"drawtext=text=&#x27;Duration: {duration_str}&#x27;:x=10:y=10:fontsize=24:fontcolor=white",&#xA;            &#x27;-q:v&#x27;, &#x27;2&#x27;,  # Output quality&#xA;            &#x27;-y&#x27;,  # Overwrite output files without asking&#xA;            output_path&#xA;        ]&#xA;        try:&#xA;            result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)&#xA;            if result.returncode != 0:&#xA;                print(f"ffmpeg error: {result.stderr}")&#xA;                return None&#xA;            return output_path&#xA;        except Exception as e:&#xA;            print(f"Error generating thumbnail with duration: {e}")&#xA;            return None&#xA;

    &#xA;

    and it is used like this :

    &#xA;

    for i, video in enumerate(self.videos):&#xA;    video_widget = VideoThumbnailLabel(video.file)&#xA;    video_widget.mousePressEvent = lambda event, v=video: self.onThumbnailClick(&#xA;        v&#xA;    )&#xA;    self.layout.addWidget(video_widget, i // 3, i % 3)&#xA;

    &#xA;

    I'm facing a problem where I am not able to get the thumbnail if I try to add the duration (I've tested it without the draw filter and worked fine)

    &#xA;

    I get this error (from the result.returncode) that I'm not able to comprehend :

    &#xA;

    ffmpeg error: b"ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers\n  built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)\n  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_4 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=&#x27;-Wl,-ld_classic&#x27; --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon\n  libavutil      58. 29.100 / 58. 29.100\n  libavcodec     60. 31.102 / 60. 31.102\n  libavformat    60. 16.100 / 60. 16.100\n  libavdevice    60.  3.100 / 60.  3.100\n  libavfilter     9. 12.100 /  9. 12.100\n  libswscale      7.  5.100 /  7.  5.100\n  libswresample   4. 12.100 /  4. 12.100\n  libpostproc    57.  3.100 / 57.  3.100\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;/Users/edoardo/Projects/work/test/BigBuckBunny.mp4&#x27;:\n  Metadata:\n    major_brand     : mp42\n    minor_version   : 0\n    compatible_brands: isomavc1mp42\n    creation_time   : 2010-01-10T08:29:06.000000Z\n  Duration: 00:09:56.47, start: 0.000000, bitrate: 2119 kb/s\n  Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)\n    Metadata:\n      creation_time   : 2010-01-10T08:29:06.000000Z\n      handler_name    : (C) 2007 Google Inc. v08.13.2007.\n      vendor_id       : [0][0][0][0]\n  Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1991 kb/s, 24 fps, 24 tbr, 24k tbn (default)\n    Metadata:\n      creation_time   : 2010-01-10T08:29:06.000000Z\n      handler_name    : (C) 2007 Google Inc. v08.13.2007.\n      vendor_id       : [0][0][0][0]\n[Parsed_drawtext_0 @ 0x60000331cd10] Both text and text file provided. Please provide only one\n[AVFilterGraph @ 0x600002018000] Error initializing filters\n[vost#0:0/mjpeg @ 0x13ce0c7e0] Error initializing a simple filtergraph\nError opening output file thumbnail.jpg.\nError opening output files: Invalid argument\n"&#xA;

    &#xA;

    I've installed both ffmpeg and ffmprobe in my machine :

    &#xA;

    ┌(edoardomacbook-air)-[~/Projects/work/tests-scripts]                                                                                                                                   &#xA;└─ $ ffmpeg -version &amp;&amp; ffprobe -version                                                                                                                                                              2 ⚙ &#xA;ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers&#xA;built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)&#xA;configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_4 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=&#x27;-Wl,-ld_classic&#x27; --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon&#xA;libavutil      58. 29.100 / 58. 29.100&#xA;libavcodec     60. 31.102 / 60. 31.102&#xA;libavformat    60. 16.100 / 60. 16.100&#xA;libavdevice    60.  3.100 / 60.  3.100&#xA;libavfilter     9. 12.100 /  9. 12.100&#xA;libswscale      7.  5.100 /  7.  5.100&#xA;libswresample   4. 12.100 /  4. 12.100&#xA;libpostproc    57.  3.100 / 57.  3.100&#xA;ffprobe version 6.1.1 Copyright (c) 2007-2023 the FFmpeg developers&#xA;built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)&#xA;configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_4 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=&#x27;-Wl,-ld_classic&#x27; --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon&#xA;libavutil      58. 29.100 / 58. 29.100&#xA;libavcodec     60. 31.102 / 60. 31.102&#xA;libavformat    60. 16.100 / 60. 16.100&#xA;libavdevice    60.  3.100 / 60.  3.100&#xA;libavfilter     9. 12.100 /  9. 12.100&#xA;libswscale      7.  5.100 /  7.  5.100&#xA;libswresample   4. 12.100 /  4. 12.100&#xA;libpostproc    57.  3.100 / 57.  3.100&#xA;

    &#xA;

    Does anyone see the problem ?

    &#xA;


    &#xA;

    P.S. : I know that I havent provided a minimal reproducible example, but since I don't know where the problem lies I didn't want to exclude anything

    &#xA;

  • Downscaling a video from 1080p to 480p using swscale and encoding to x265 gives a glitched output

    5 mai 2023, par lokit khemka

    I am basically first scaling a frame and then sending the frame to the encoder as below :

    &#xA;

    scaled_frame->pts = input_frame->pts;&#xA;scaled_frame->pkt_dts = input_frame->pkt_dts;&#xA;scaled_frame->pict_type = input_frame->pict_type;&#xA;sws_scale_frame(encoder->sws_ctx, scaled_frame, input_frame);&#xA;if (encode_video(decoder, encoder, scaled_frame))&#xA;     return -1;&#xA;

    &#xA;

    The scaling context is configured as :

    &#xA;

    scaled_frame->width = 854;&#xA;scaled_frame->height=480; &#xA;encoder->sws_ctx = sws_getContext(1920, 1080,&#xA;                            decoder->video_avcc->pix_fmt, &#xA;                           scaled_frame->width, scaled_frame->height, decoder->video_avcc->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL );&#xA;    if (!encoder->sws_ctx){logging("Cannot Create Scaling Context."); return -1;}&#xA;

    &#xA;

    The encoder is configured as :

    &#xA;

        encoder_sc->video_avcc->height = decoder_ctx->height; //1080&#xA;    encoder_sc->video_avcc->width = decoder_ctx->width; //1920&#xA;    encoder_sc->video_avcc->bit_rate = 2 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_buffer_size = 4 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_max_rate = 2 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_min_rate = 2.5 * 1000 * 1000;&#xA;&#xA;    encoder_sc->video_avcc->time_base = av_inv_q(input_framerate);&#xA;    encoder_sc->video_avs->time_base = encoder_sc->video_avcc->time_base;&#xA;

    &#xA;

    When I get the output, the output video is 1080p and I have glitches like : enter image description here

    &#xA;

    I changed the encoder avcc resolution to 480p (854 x 480). However, that is causing the video to get sliced to the top quarter of the original frame.&#xA;I am new to FFMPEG and video processing in general.

    &#xA;

    EDIT : I am adding the minimal reproducible code sample. However, it is really long because I need to include code for decoding, scaling and then encoding because the possible error is either in scaling or encoding :

    &#xA;

    #include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>timestamp.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;&#xA;#include &#xA;#include &#xA;&#xA;typedef struct StreamingContext{&#xA;    AVFormatContext* avfc;&#xA;    AVCodec *video_avc;&#xA;    AVCodec *audio_avc;&#xA;    AVStream *video_avs;&#xA;    AVStream *audio_avs;&#xA;    AVCodecContext *video_avcc;&#xA;    AVCodecContext *audio_avcc;&#xA;    int video_index;&#xA;    int audio_index;&#xA;    char* filename;&#xA;    struct SwsContext *sws_ctx;&#xA;}StreamingContext;&#xA;&#xA;&#xA;typedef struct StreamingParams{&#xA;    char copy_video;&#xA;    char copy_audio;&#xA;    char *output_extension;&#xA;    char *muxer_opt_key;&#xA;    char *muxer_opt_value;&#xA;    char *video_codec;&#xA;    char *audio_codec;&#xA;    char *codec_priv_key;&#xA;    char *codec_priv_value;&#xA;}StreamingParams;&#xA;&#xA;void logging(const char *fmt, ...)&#xA;{&#xA;    va_list args;&#xA;    fprintf(stderr, "LOG: ");&#xA;    va_start(args, fmt);&#xA;    vfprintf(stderr, fmt, args);&#xA;    va_end(args);&#xA;    fprintf(stderr, "\n");&#xA;}&#xA;&#xA;int fill_stream_info(AVStream *avs, AVCodec **avc, AVCodecContext **avcc)&#xA;{&#xA;    *avc = avcodec_find_decoder(avs->codecpar->codec_id);&#xA;    if (!*avc)&#xA;    {&#xA;        logging("Failed to find the codec.\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    *avcc = avcodec_alloc_context3(*avc);&#xA;    if (!*avcc)&#xA;    {&#xA;        logging("Failed to alloc memory for codec context.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avcodec_parameters_to_context(*avcc, avs->codecpar) &lt; 0)&#xA;    {&#xA;        logging("Failed to fill Codec Context.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avcodec_open2(*avcc, *avc, NULL) &lt; 0)&#xA;    {&#xA;        logging("Failed to open Codec.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int open_media(const char *in_filename, AVFormatContext **avfc)&#xA;{&#xA;    *avfc = avformat_alloc_context();&#xA;&#xA;    if (!*avfc)&#xA;    {&#xA;        logging("Failed to Allocate Memory for Format Context");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avformat_open_input(avfc, in_filename, NULL, NULL) != 0)&#xA;    {&#xA;        logging("Failed to open input file %s", in_filename);&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(*avfc, NULL) &lt; 0)&#xA;    {&#xA;        logging("Failed to get Stream Info.");&#xA;        return -1;&#xA;    }&#xA;}&#xA;&#xA;int prepare_decoder(StreamingContext *sc)&#xA;{&#xA;    for (int i = 0; i &lt; sc->avfc->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        if (sc->avfc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            sc->video_avs = sc->avfc->streams[i];&#xA;            sc->video_index = i;&#xA;&#xA;            if (fill_stream_info(sc->video_avs, &amp;sc->video_avc, &amp;sc->video_avcc))&#xA;            {&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        else&#xA;        {&#xA;            logging("Skipping Streams other than Video.");&#xA;        }&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int prepare_video_encoder(StreamingContext *encoder_sc, AVCodecContext *decoder_ctx, AVRational input_framerate,&#xA;                          StreamingParams sp)&#xA;{&#xA;    encoder_sc->video_avs = avformat_new_stream(encoder_sc->avfc, NULL);&#xA;    encoder_sc->video_avc = avcodec_find_encoder_by_name(sp.video_codec);&#xA;    if (!encoder_sc->video_avc)&#xA;    {&#xA;        logging("Cannot find the Codec.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    encoder_sc->video_avcc = avcodec_alloc_context3(encoder_sc->video_avc);&#xA;    if (!encoder_sc->video_avcc)&#xA;    {&#xA;        logging("Could not allocate memory for Codec Context.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    av_opt_set(encoder_sc->video_avcc->priv_data, "preset", "fast", 0);&#xA;    if (sp.codec_priv_key &amp;&amp; sp.codec_priv_value)&#xA;        av_opt_set(encoder_sc->video_avcc->priv_data, sp.codec_priv_key, sp.codec_priv_value, 0);&#xA;&#xA;    encoder_sc->video_avcc->height = decoder_ctx->height;&#xA;    encoder_sc->video_avcc->width = decoder_ctx->width;&#xA;    encoder_sc->video_avcc->sample_aspect_ratio = decoder_ctx->sample_aspect_ratio;&#xA;&#xA;    if (encoder_sc->video_avc->pix_fmts)&#xA;        encoder_sc->video_avcc->pix_fmt = encoder_sc->video_avc->pix_fmts[0];&#xA;    else&#xA;        encoder_sc->video_avcc->pix_fmt = decoder_ctx->pix_fmt;&#xA;&#xA;    encoder_sc->video_avcc->bit_rate = 2 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_buffer_size = 4 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_max_rate = 2 * 1000 * 1000;&#xA;    encoder_sc->video_avcc->rc_min_rate = 2.5 * 1000 * 1000;&#xA;&#xA;    encoder_sc->video_avcc->time_base = av_inv_q(input_framerate);&#xA;    encoder_sc->video_avs->time_base = encoder_sc->video_avcc->time_base;&#xA;&#xA;    &#xA;&#xA;    if (avcodec_open2(encoder_sc->video_avcc, encoder_sc->video_avc, NULL) &lt; 0)&#xA;    {&#xA;        logging("Could not open the Codec.");&#xA;        return -1;&#xA;    }&#xA;    avcodec_parameters_from_context(encoder_sc->video_avs->codecpar, encoder_sc->video_avcc);&#xA;    return 0;&#xA;}&#xA;&#xA;int encode_video(StreamingContext *decoder, StreamingContext *encoder, AVFrame *input_frame)&#xA;{&#xA;    if (input_frame)&#xA;        input_frame->pict_type = AV_PICTURE_TYPE_NONE;&#xA;&#xA;    AVPacket *output_packet = av_packet_alloc();&#xA;    if (!output_packet)&#xA;    {&#xA;        logging("Could not allocate memory for Output Packet.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    int response = avcodec_send_frame(encoder->video_avcc, input_frame);&#xA;&#xA;    while (response >= 0)&#xA;    {&#xA;        response = avcodec_receive_packet(encoder->video_avcc, output_packet);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)&#xA;        {&#xA;            break;&#xA;        }&#xA;        else if (response &lt; 0)&#xA;        {&#xA;            logging("Error while receiving packet from encoder: %s", av_err2str(response));&#xA;            return -1;&#xA;        }&#xA;&#xA;        output_packet->stream_index = decoder->video_index;&#xA;        output_packet->duration = encoder->video_avs->time_base.den / encoder->video_avs->time_base.num / decoder->video_avs->avg_frame_rate.num * decoder->video_avs->avg_frame_rate.den;&#xA;&#xA;        av_packet_rescale_ts(output_packet, decoder->video_avs->time_base, encoder->video_avs->time_base);&#xA;        response = av_interleaved_write_frame(encoder->avfc, output_packet);&#xA;        if (response != 0)&#xA;        {&#xA;            logging("Error %d while receiving packet from decoder: %s", response, av_err2str(response));&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    av_packet_unref(output_packet);&#xA;    av_packet_free(&amp;output_packet);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int transcode_video(StreamingContext *decoder, StreamingContext *encoder, AVPacket *input_packet, AVFrame *input_frame, AVFrame *scaled_frame)&#xA;{&#xA;    int response = avcodec_send_packet(decoder->video_avcc, input_packet);&#xA;    if (response &lt; 0)&#xA;    {&#xA;        logging("Error while sending the Packet to Decoder: %s", av_err2str(response));&#xA;        return response;&#xA;    }&#xA;&#xA;    while (response >= 0)&#xA;    {&#xA;        response = avcodec_receive_frame(decoder->video_avcc, input_frame);&#xA;        &#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF)&#xA;        {&#xA;            break;&#xA;        }&#xA;        else if (response &lt; 0)&#xA;        {&#xA;            logging("Error while receiving frame from Decoder: %s", av_err2str(response));&#xA;            return response;&#xA;        }&#xA;        if (response >= 0)&#xA;        {&#xA;            scaled_frame->pts = input_frame->pts;&#xA;            scaled_frame->pkt_dts = input_frame->pkt_dts;&#xA;            scaled_frame->pict_type = input_frame->pict_type;&#xA;            sws_scale_frame(encoder->sws_ctx, scaled_frame, input_frame);&#xA;            if (encode_video(decoder, encoder, scaled_frame))&#xA;                return -1;&#xA;        }&#xA;&#xA;        av_frame_unref(input_frame);&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int main(int argc, char *argv[])&#xA;{&#xA;    StreamingParams sp = {0};&#xA;    sp.copy_audio = 1;&#xA;    sp.copy_video = 0;&#xA;    sp.video_codec = "libx265";&#xA;&#xA;&#xA;    StreamingContext *decoder = (StreamingContext *)calloc(1, sizeof(StreamingContext));&#xA;    decoder->filename = argv[1];&#xA;&#xA;    StreamingContext *encoder = (StreamingContext *)calloc(1, sizeof(StreamingContext));&#xA;    encoder->filename = argv[2];&#xA;&#xA;    if (sp.output_extension)&#xA;    {&#xA;        strcat(encoder->filename, sp.output_extension);&#xA;    }&#xA;&#xA;    if (open_media(decoder->filename, &amp;decoder->avfc))&#xA;        return -1;&#xA;    if (prepare_decoder(decoder))&#xA;        return -1;&#xA;&#xA;    avformat_alloc_output_context2(&amp;encoder->avfc, NULL, NULL, encoder->filename);&#xA;    if (!encoder->avfc)&#xA;    {&#xA;        logging("Could not allocate memory for output Format Context.");&#xA;        return -1;&#xA;    }&#xA;&#xA;        AVRational input_framerate = av_guess_frame_rate(decoder->avfc, decoder->video_avs, NULL);&#xA;        prepare_video_encoder(encoder, decoder->video_avcc, input_framerate, sp);&#xA;&#xA;&#xA;    if (encoder->avfc->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        encoder->avfc->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;    if (!(encoder->avfc->oformat->flags &amp; AVFMT_NOFILE))&#xA;    {&#xA;        if (avio_open(&amp;encoder->avfc->pb, encoder->filename, AVIO_FLAG_WRITE) &lt; 0)&#xA;        {&#xA;            logging("could not open the output file");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    AVDictionary *muxer_opts = NULL;&#xA;&#xA;    if (sp.muxer_opt_key &amp;&amp; sp.muxer_opt_value)&#xA;    {&#xA;        av_dict_set(&amp;muxer_opts, sp.muxer_opt_key, sp.muxer_opt_value, 0);&#xA;    }&#xA;&#xA;    if (avformat_write_header(encoder->avfc, &amp;muxer_opts) &lt; 0)&#xA;    {&#xA;        logging("an error occurred when opening output file");&#xA;        return -1;&#xA;    }&#xA;&#xA;    AVFrame *input_frame = av_frame_alloc();&#xA;    AVFrame *scaled_frame = av_frame_alloc();&#xA;    if (!input_frame || !scaled_frame)&#xA;    {&#xA;        logging("Failed to allocate memory for AVFrame");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // scaled_frame->format = AV_PIX_FMT_YUV420P;&#xA;    scaled_frame->width = 854;&#xA;    scaled_frame->height=480;    &#xA;&#xA;    //Creating Scaling Context&#xA;    encoder->sws_ctx = sws_getContext(1920, 1080,&#xA;                            decoder->video_avcc->pix_fmt, &#xA;                           scaled_frame->width, scaled_frame->height, decoder->video_avcc->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL );&#xA;    if (!encoder->sws_ctx){logging("Cannot Create Scaling Context."); return -1;}&#xA;&#xA;&#xA;    AVPacket *input_packet = av_packet_alloc();&#xA;    if (!input_packet)&#xA;    {&#xA;        logging("Failed to allocate memory for AVPacket.");&#xA;        return -1;&#xA;    }&#xA;&#xA;    while (av_read_frame(decoder->avfc, input_packet) >= 0)&#xA;    {&#xA;        if (decoder->avfc->streams[input_packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;                if (transcode_video(decoder, encoder, input_packet, input_frame, scaled_frame))&#xA;                    return -1;&#xA;                av_packet_unref(input_packet);&#xA;        }&#xA;        else&#xA;        {&#xA;            logging("Ignoring all nonvideo  packets.");&#xA;        }&#xA;    }&#xA;&#xA;    if (encode_video(decoder, encoder, NULL))&#xA;        return -1;&#xA;&#xA;    av_write_trailer(encoder->avfc);&#xA;&#xA;    if (muxer_opts != NULL)&#xA;    {&#xA;        av_dict_free(&amp;muxer_opts);&#xA;        muxer_opts = NULL;&#xA;    }&#xA;&#xA;    if (input_frame != NULL)&#xA;    {&#xA;        av_frame_free(&amp;input_frame);&#xA;        input_frame = NULL;&#xA;    }&#xA;&#xA;    if (input_packet != NULL)&#xA;    {&#xA;        av_packet_free(&amp;input_packet);&#xA;        input_packet = NULL;&#xA;    }&#xA;&#xA;    avformat_close_input(&amp;decoder->avfc);&#xA;&#xA;    avformat_free_context(decoder->avfc);&#xA;    decoder->avfc = NULL;&#xA;    avformat_free_context(encoder->avfc);&#xA;    encoder->avfc = NULL;&#xA;&#xA;    avcodec_free_context(&amp;decoder->video_avcc);&#xA;    decoder->video_avcc = NULL;&#xA;    avcodec_free_context(&amp;decoder->audio_avcc);&#xA;    decoder->audio_avcc = NULL;&#xA;&#xA;    free(decoder);&#xA;    decoder = NULL;&#xA;    free(encoder);&#xA;    encoder = NULL;&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    The video I am using for testing is available at the repo : https://github.com/leandromoreira/ffmpeg-libav-tutorial

    &#xA;

    The file name is small_bunny_1080p_60fps.mp4

    &#xA;