Recherche avancée

Médias (1)

Mot : - Tags -/book

Autres articles (105)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (8870)

  • Segmentation fault with avcodec_encode_video2() while encoding H.264

    16 juillet 2015, par Baris Demiray

    I’m trying to convert a cv::Mat to an AVFrame to encode it then in H.264 and wanted to start from a simple example, as I’m a newbie in both. So I first read in a JPEG file, and then do the pixel format conversion with sws_scale() from AV_PIX_FMT_BGR24 to AV_PIX_FMT_YUV420P keeping the dimensions the same, and it all goes fine until I call avcodec_encode_video2().

    I read quite a few discussions regarding an AVFrame allocation and the question segmetation fault while avcodec_encode_video2 seemed like a match but I just can’t see what I’m missing or getting wrong.

    Here is the minimal code that you can reproduce the crash, it should be compiled with,

    g++ -o OpenCV2FFmpeg OpenCV2FFmpeg.cpp -lopencv_imgproc -lopencv_highgui -lopencv_core -lswscale -lavutil -lavcodec -lavformat

    It’s output on my system,

    cv::Mat [width=420, height=315, depth=0, channels=3, step=1260]
    I'll soon crash..
    Segmentation fault

    And that sample.jpg file’s details by identify tool,

    ~temporary/sample.jpg JPEG 420x315 420x315+0+0 8-bit sRGB 38.3KB 0.000u 0:00.000

    Please note that I’m trying to create a video out of a single image, just to keep things simple.

    #include <iostream>
    #include <cassert>
    using namespace std;

    extern "C" {
       #include <libavcodec></libavcodec>avcodec.h>
       #include <libswscale></libswscale>swscale.h>
       #include <libavformat></libavformat>avformat.h>
    }

    #include <opencv2></opencv2>core/core.hpp>
    #include <opencv2></opencv2>highgui/highgui.hpp>

    const string TEST_IMAGE = "/home/baris/temporary/sample.jpg";

    int main(int /*argc*/, char** argv)
    {
       av_register_all();
       avcodec_register_all();

       /**
        * Initialise the encoder
        */
       AVCodec *h264encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
       AVFormatContext *cv2avFormatContext = avformat_alloc_context();

       /**
        * Create a stream and allocate frames
        */
       AVStream *h264outputstream = avformat_new_stream(cv2avFormatContext, h264encoder);
       avcodec_get_context_defaults3(h264outputstream->codec, h264encoder);
       AVFrame *sourceAvFrame = av_frame_alloc(), *destAvFrame = av_frame_alloc();
       int got_frame;

       /**
        * Pixel formats for the input and the output
        */
       AVPixelFormat sourcePixelFormat = AV_PIX_FMT_BGR24;
       AVPixelFormat destPixelFormat = AV_PIX_FMT_YUV420P;

       /**
        * Create cv::Mat
        */
       cv::Mat cvFrame = cv::imread(TEST_IMAGE, CV_LOAD_IMAGE_COLOR);
       int width = cvFrame.size().width, height = cvFrame.size().height;
       cerr &lt;&lt; "cv::Mat [width=" &lt;&lt; width &lt;&lt; ", height=" &lt;&lt; height &lt;&lt; ", depth=" &lt;&lt; cvFrame.depth() &lt;&lt; ", channels=" &lt;&lt; cvFrame.channels() &lt;&lt; ", step=" &lt;&lt; cvFrame.step &lt;&lt; "]" &lt;&lt; endl;

       h264outputstream->codec->pix_fmt = destPixelFormat;
       h264outputstream->codec->width = cvFrame.cols;
       h264outputstream->codec->height = cvFrame.rows;

       /**
        * Prepare the conversion context
        */
       SwsContext *bgr2yuvcontext = sws_getContext(width, height,
                                                   sourcePixelFormat,
                                                   h264outputstream->codec->width, h264outputstream->codec->height,
                                                   h264outputstream->codec->pix_fmt,
                                                   SWS_BICUBIC, NULL, NULL, NULL);

       /**
        * Convert and encode frames
        */
       for (uint i=0; i &lt; 250; i++)
       {
           /**
            * Allocate source frame, i.e. input to sws_scale()
            */
           avpicture_alloc((AVPicture*)sourceAvFrame, sourcePixelFormat, width, height);

           for (int h = 0; h &lt; height; h++)
               memcpy(&amp;(sourceAvFrame->data[0][h*sourceAvFrame->linesize[0]]), &amp;(cvFrame.data[h*cvFrame.step]), width*3);

           /**
            * Allocate destination frame, i.e. output from sws_scale()
            */
           avpicture_alloc((AVPicture *)destAvFrame, destPixelFormat, width, height);

           sws_scale(bgr2yuvcontext, sourceAvFrame->data, sourceAvFrame->linesize,
                     0, height, destAvFrame->data, destAvFrame->linesize);

           /**
            * Prepare an AVPacket for encoded output
            */
           AVPacket avEncodedPacket;
           av_init_packet(&amp;avEncodedPacket);
           avEncodedPacket.data = NULL;
           avEncodedPacket.size = 0;
           // av_free_packet(&amp;avEncodedPacket); w/ or w/o result doesn't change

           cerr &lt;&lt; "I'll soon crash.." &lt;&lt; endl;
           if (avcodec_encode_video2(h264outputstream->codec, &amp;avEncodedPacket, destAvFrame, &amp;got_frame) &lt; 0)
               exit(1);

           cerr &lt;&lt; "Checking if we have a frame" &lt;&lt; endl;
           if (got_frame)
               av_write_frame(cv2avFormatContext, &amp;avEncodedPacket);

           av_free_packet(&amp;avEncodedPacket);
           av_frame_free(&amp;sourceAvFrame);
           av_frame_free(&amp;destAvFrame);
       }
    }
    </cassert></iostream>

    Thanks in advance !

    EDIT : And the stack trace after the crash,

    Thread 2 (Thread 0x7fffe5506700 (LWP 10005)):
    #0  0x00007ffff4bf6c5d in poll () at /lib64/libc.so.6
    #1  0x00007fffe9073268 in  () at /usr/lib64/libusb-1.0.so.0
    #2  0x00007ffff47010a4 in start_thread () at /lib64/libpthread.so.0
    #3  0x00007ffff4bff08d in clone () at /lib64/libc.so.6

    Thread 1 (Thread 0x7ffff7f869c0 (LWP 10001)):
    #0  0x00007ffff5ecc7dc in avcodec_encode_video2 () at /usr/lib64/libavcodec.so.56
    #1  0x00000000004019b6 in main(int, char**) (argv=0x7fffffffd3d8) at ../src/OpenCV2FFmpeg.cpp:99

    EDIT2 : Problem was that I hadn’t avcodec_open2() the codec as spotted by Ronald. Final version of the code is at https://github.com/barisdemiray/opencv2ffmpeg/, with leaks and probably other problems hoping that I’ll improve it while learning both libraries.

  • How to restream IPTV playlist with Nginx RTMP, FFmpeg, and Python without recording, but getting HTTP 403 error ? [closed]

    1er avril, par boyuna1720

    I have an IPTV playlist from a provider that allows only one user to connect and watch. I want to restream this playlist through my own server without recording it and in a lightweight manner. I’m using Nginx RTMP, FFmpeg, and Python TCP for the setup, but I keep getting an HTTP 403 error when trying to access the stream.

    &#xA;

    Here’s a summary of my setup :

    &#xA;

    Nginx RTMP : Used for streaming.

    &#xA;

    FFmpeg : Used to handle the video stream.

    &#xA;

    Python TCP : Trying to handle the connection between my server and the IPTV source.

    &#xA;

    #!/usr/bin/env python3&#xA;&#xA;import sys&#xA;import socket&#xA;import threading&#xA;import requests&#xA;import time&#xA;&#xA;def accept_connections(server_socket, clients, clients_lock):&#xA;    """&#xA;    Continuously accept new client connections, perform a minimal read of the&#xA;    client&#x27;s HTTP request, send back a valid HTTP/1.1 response header, and&#xA;    add the socket to the broadcast list.&#xA;    """&#xA;    while True:&#xA;        client_socket, addr = server_socket.accept()&#xA;        print(f"[&#x2B;] New client connected from {addr}")&#xA;        threading.Thread(&#xA;            target=handle_client,&#xA;            args=(client_socket, addr, clients, clients_lock),&#xA;            daemon=True&#xA;        ).start()&#xA;&#xA;def handle_client(client_socket, addr, clients, clients_lock):&#xA;    """&#xA;    Read the client&#x27;s HTTP request minimally, send back a proper HTTP/1.1 200 OK header,&#xA;    and then add the socket to our broadcast list.&#xA;    """&#xA;    try:&#xA;        # Read until we reach the end of the request headers&#xA;        request_data = b""&#xA;        while b"\r\n\r\n" not in request_data:&#xA;            chunk = client_socket.recv(1024)&#xA;            if not chunk:&#xA;                break&#xA;            request_data &#x2B;= chunk&#xA;&#xA;        # Send a proper HTTP response header to satisfy clients like curl&#xA;        response_header = (&#xA;            "HTTP/1.1 200 OK\r\n"&#xA;            "Content-Type: application/octet-stream\r\n"&#xA;            "Connection: close\r\n"&#xA;            "\r\n"&#xA;        )&#xA;        client_socket.sendall(response_header.encode("utf-8"))&#xA;&#xA;        with clients_lock:&#xA;            clients.append(client_socket)&#xA;        print(f"[&#x2B;] Client from {addr} is ready to receive stream.")&#xA;    except Exception as e:&#xA;        print(f"[!] Error handling client {addr}: {e}")&#xA;        client_socket.close()&#xA;&#xA;def read_from_source_and_broadcast(source_url, clients, clients_lock):&#xA;    """&#xA;    Continuously connect to the source URL (following redirects) using custom headers&#xA;    so that it mimics a curl-like request. In case of connection errors (e.g. connection reset),&#xA;    wait a bit and then try again.&#xA;    &#xA;    For each successful connection, stream data in chunks and broadcast each chunk&#xA;    to all connected clients.&#xA;    """&#xA;    # Set custom headers to mimic curl&#xA;    headers = {&#xA;        "User-Agent": "curl/8.5.0",&#xA;        "Accept": "*/*"&#xA;    }&#xA;&#xA;    while True:&#xA;        try:&#xA;            print(f"[&#x2B;] Fetching from source URL (with redirects): {source_url}")&#xA;            with requests.get(source_url, stream=True, allow_redirects=True, headers=headers) as resp:&#xA;                if resp.status_code >= 400:&#xA;                    print(f"[!] Got HTTP {resp.status_code} from the source. Retrying in 5 seconds.")&#xA;                    time.sleep(5)&#xA;                    continue&#xA;&#xA;                # Stream data and broadcast each chunk&#xA;                for chunk in resp.iter_content(chunk_size=4096):&#xA;                    if not chunk:&#xA;                        continue&#xA;                    with clients_lock:&#xA;                        for c in clients[:]:&#xA;                            try:&#xA;                                c.sendall(chunk)&#xA;                            except Exception as e:&#xA;                                print(f"[!] A client disconnected or send failed: {e}")&#xA;                                c.close()&#xA;                                clients.remove(c)&#xA;        except requests.exceptions.RequestException as e:&#xA;            print(f"[!] Source connection error, retrying in 5 seconds: {e}")&#xA;            time.sleep(5)&#xA;&#xA;def main():&#xA;    if len(sys.argv) != 3:&#xA;        print(f"Usage: {sys.argv[0]}  <port>")&#xA;        sys.exit(1)&#xA;&#xA;    source_url = sys.argv[1]&#xA;    port = int(sys.argv[2])&#xA;&#xA;    # Create a TCP socket to listen for incoming connections&#xA;    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&#xA;    server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&#xA;    server_socket.bind(("0.0.0.0", port))&#xA;    server_socket.listen(5)&#xA;    print(f"[&#x2B;] Listening on port {port}...")&#xA;&#xA;    # List of currently connected client sockets&#xA;    clients = []&#xA;    clients_lock = threading.Lock()&#xA;&#xA;    # Start a thread to accept incoming client connections&#xA;    t_accept = threading.Thread(&#xA;        target=accept_connections,&#xA;        args=(server_socket, clients, clients_lock),&#xA;        daemon=True&#xA;    )&#xA;    t_accept.start()&#xA;&#xA;    # Continuously read from the source URL and broadcast to connected clients&#xA;    read_from_source_and_broadcast(source_url, clients, clients_lock)&#xA;&#xA;if __name__ == "__main__":&#xA;    main()&#xA;</port>

    &#xA;

    When i write command python3 proxy_server.py &#x27;http://channelurl&#x27; 9999&#xA;I getting error.

    &#xA;

    [&#x2B;] Listening on port 9999...&#xA;[&#x2B;] Fetching from source URL (with redirects): http://ate91060.cdn-akm.me:80/dc31a19e5a6a/fc5e38e28e/325973&#xA;[!] Got HTTP 403 from the source. Retrying in 5 seconds.&#xA;^CTraceback (most recent call last):&#xA;  File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 127, in <module>&#xA;    main()&#xA;  File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 124, in main&#xA;    read_from_source_and_broadcast(source_url, clients, clients_lock)&#xA;  File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 77, in read_from_source_and_broadcast&#xA;    time.sleep(5)&#xA;KeyboardInterrupt&#xA;</module>

    &#xA;

  • While using skvideo.io.FFmpegReader and skvideo.io.FFmpegWriter for video throughput the input video and output video length differ

    28 juin 2024, par Kaesebrotus Anonymous

    I have an h264 encoded mp4 video of about 27.5 minutes length and I am trying to create a copy of the video which excludes the first 5 frames. I am using scikit-video and ffmpeg in python for this purpose. I do not have a GPU, so I am using libx264 codec for the output video.

    &#xA;

    It generally works and the output video excludes the first 5 frames. Somehow, the output video results in a length of about 22 minutes. When visually checking the videos, the shorter video does seem slightly faster and I can identify the same frames at different timestamps. In windows explorer, when clicking properties and then details, both videos' frame rates show as 20.00 fps.

    &#xA;

    So, my goal is to have both videos of the same length, except for the loss of the first 5 frames which should result in a duration difference of 0.25 seconds, and use the same (almost same) codec and not lose quality.

    &#xA;

    Can anyone explain why this apparent loss of frames is happening ?

    &#xA;

    Thank you for your interest in helping me, please find the details below.

    &#xA;

    Here is a minimal example of what I have done.

    &#xA;

    framerate = str(20)&#xA;reader = skvideo.io.FFmpegReader(inputvideo.mp4, inputdict={&#x27;-r&#x27;: framerate})&#xA;writer = skvideo.io.FFmpegWriter(outputvideo.mp4, outputdict={&#x27;-vcodec&#x27;: &#x27;libx264&#x27;, &#x27;-r&#x27;: framerate})&#xA;&#xA;for idx,frame in enumerate(reader.nextFrame()):&#xA;    if idx &lt; 5:&#xA;        continue&#xA;    writer.writeFrame(frame)&#xA;&#xA;reader.close()&#xA;writer.close()&#xA;

    &#xA;

    When I read the output video again using FFmpegReader and check the .probeInfo, I can see that the output video has less frames in total. I have also managed to replicate the same problem for shorter videos (now not excluding the first 5 frames, but only throughputting a video), e.g. 10 seconds input turns to 8 seconds output with less frames. I have also tried playing around with further parameters of the outputdict, e.g. -pix_fmt, -b. I have tried to set -time_base in the output dict to the same value as in the inputdict, but that did not seem to have the desired effect. I am not sure if the name of the parameter is right.

    &#xA;

    For additional info, I am providing the .probeInfo of the input video, of which I used 10 seconds, and the .probeInfo of the 8 second output video it produced.

    &#xA;

    **input video** .probeInfo:&#xA;input dict&#xA;&#xA;{&#x27;video&#x27;: OrderedDict([(&#x27;@index&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@codec_name&#x27;, &#x27;h264&#x27;),&#xA;              (&#x27;@codec_long_name&#x27;,&#xA;               &#x27;H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10&#x27;),&#xA;              (&#x27;@profile&#x27;, &#x27;High 4:4:4 Predictive&#x27;),&#xA;              (&#x27;@codec_type&#x27;, &#x27;video&#x27;),&#xA;              (&#x27;@codec_tag_string&#x27;, &#x27;avc1&#x27;),&#xA;              (&#x27;@codec_tag&#x27;, &#x27;0x31637661&#x27;),&#xA;              (&#x27;@width&#x27;, &#x27;4096&#x27;),&#xA;              (&#x27;@height&#x27;, &#x27;3000&#x27;),&#xA;              (&#x27;@coded_width&#x27;, &#x27;4096&#x27;),&#xA;              (&#x27;@coded_height&#x27;, &#x27;3000&#x27;),&#xA;              (&#x27;@closed_captions&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@film_grain&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@has_b_frames&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@sample_aspect_ratio&#x27;, &#x27;1:1&#x27;),&#xA;              (&#x27;@display_aspect_ratio&#x27;, &#x27;512:375&#x27;),&#xA;              (&#x27;@pix_fmt&#x27;, &#x27;yuv420p&#x27;),&#xA;              (&#x27;@level&#x27;, &#x27;60&#x27;),&#xA;              (&#x27;@chroma_location&#x27;, &#x27;left&#x27;),&#xA;              (&#x27;@field_order&#x27;, &#x27;progressive&#x27;),&#xA;              (&#x27;@refs&#x27;, &#x27;1&#x27;),&#xA;              (&#x27;@is_avc&#x27;, &#x27;true&#x27;),&#xA;              (&#x27;@nal_length_size&#x27;, &#x27;4&#x27;),&#xA;              (&#x27;@id&#x27;, &#x27;0x1&#x27;),&#xA;              (&#x27;@r_frame_rate&#x27;, &#x27;20/1&#x27;),&#xA;              (&#x27;@avg_frame_rate&#x27;, &#x27;20/1&#x27;),&#xA;              (&#x27;@time_base&#x27;, &#x27;1/1200000&#x27;),&#xA;              (&#x27;@start_pts&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@start_time&#x27;, &#x27;0.000000&#x27;),&#xA;              (&#x27;@duration_ts&#x27;, &#x27;1984740000&#x27;),&#xA;              (&#x27;@duration&#x27;, &#x27;1653.950000&#x27;),&#xA;              (&#x27;@bit_rate&#x27;, &#x27;3788971&#x27;),&#xA;              (&#x27;@bits_per_raw_sample&#x27;, &#x27;8&#x27;),&#xA;              (&#x27;@nb_frames&#x27;, &#x27;33079&#x27;),&#xA;              (&#x27;@extradata_size&#x27;, &#x27;43&#x27;),&#xA;              (&#x27;disposition&#x27;,&#xA;               OrderedDict([(&#x27;@default&#x27;, &#x27;1&#x27;),&#xA;                            (&#x27;@dub&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@original&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@comment&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@lyrics&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@karaoke&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@forced&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@hearing_impaired&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@visual_impaired&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@clean_effects&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@attached_pic&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@timed_thumbnails&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@non_diegetic&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@captions&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@descriptions&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@metadata&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@dependent&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@still_image&#x27;, &#x27;0&#x27;)])),&#xA;              (&#x27;tags&#x27;,&#xA;               OrderedDict([(&#x27;tag&#x27;,&#xA;                             [OrderedDict([(&#x27;@key&#x27;, &#x27;language&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;und&#x27;)]),&#xA;                              OrderedDict([(&#x27;@key&#x27;, &#x27;handler_name&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;VideoHandler&#x27;)]),&#xA;                              OrderedDict([(&#x27;@key&#x27;, &#x27;vendor_id&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;[0][0][0][0]&#x27;)])])]))])}&#xA;&#xA;**output video** .probeInfo:&#xA;{&#x27;video&#x27;: OrderedDict([(&#x27;@index&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@codec_name&#x27;, &#x27;h264&#x27;),&#xA;              (&#x27;@codec_long_name&#x27;,&#xA;               &#x27;H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10&#x27;),&#xA;              (&#x27;@profile&#x27;, &#x27;High&#x27;),&#xA;              (&#x27;@codec_type&#x27;, &#x27;video&#x27;),&#xA;              (&#x27;@codec_tag_string&#x27;, &#x27;avc1&#x27;),&#xA;              (&#x27;@codec_tag&#x27;, &#x27;0x31637661&#x27;),&#xA;              (&#x27;@width&#x27;, &#x27;4096&#x27;),&#xA;              (&#x27;@height&#x27;, &#x27;3000&#x27;),&#xA;              (&#x27;@coded_width&#x27;, &#x27;4096&#x27;),&#xA;              (&#x27;@coded_height&#x27;, &#x27;3000&#x27;),&#xA;              (&#x27;@closed_captions&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@film_grain&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@has_b_frames&#x27;, &#x27;2&#x27;),&#xA;              (&#x27;@pix_fmt&#x27;, &#x27;yuv420p&#x27;),&#xA;              (&#x27;@level&#x27;, &#x27;60&#x27;),&#xA;              (&#x27;@chroma_location&#x27;, &#x27;left&#x27;),&#xA;              (&#x27;@field_order&#x27;, &#x27;progressive&#x27;),&#xA;              (&#x27;@refs&#x27;, &#x27;1&#x27;),&#xA;              (&#x27;@is_avc&#x27;, &#x27;true&#x27;),&#xA;              (&#x27;@nal_length_size&#x27;, &#x27;4&#x27;),&#xA;              (&#x27;@id&#x27;, &#x27;0x1&#x27;),&#xA;              (&#x27;@r_frame_rate&#x27;, &#x27;20/1&#x27;),&#xA;              (&#x27;@avg_frame_rate&#x27;, &#x27;20/1&#x27;),&#xA;              (&#x27;@time_base&#x27;, &#x27;1/10240&#x27;),&#xA;              (&#x27;@start_pts&#x27;, &#x27;0&#x27;),&#xA;              (&#x27;@start_time&#x27;, &#x27;0.000000&#x27;),&#xA;              (&#x27;@duration_ts&#x27;, &#x27;82944&#x27;),&#xA;              (&#x27;@duration&#x27;, &#x27;8.100000&#x27;),&#xA;              (&#x27;@bit_rate&#x27;, &#x27;3444755&#x27;),&#xA;              (&#x27;@bits_per_raw_sample&#x27;, &#x27;8&#x27;),&#xA;              (&#x27;@nb_frames&#x27;, &#x27;162&#x27;),&#xA;              (&#x27;@extradata_size&#x27;, &#x27;47&#x27;),&#xA;              (&#x27;disposition&#x27;,&#xA;               OrderedDict([(&#x27;@default&#x27;, &#x27;1&#x27;),&#xA;                            (&#x27;@dub&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@original&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@comment&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@lyrics&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@karaoke&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@forced&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@hearing_impaired&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@visual_impaired&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@clean_effects&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@attached_pic&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@timed_thumbnails&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@non_diegetic&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@captions&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@descriptions&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@metadata&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@dependent&#x27;, &#x27;0&#x27;),&#xA;                            (&#x27;@still_image&#x27;, &#x27;0&#x27;)])),&#xA;              (&#x27;tags&#x27;,&#xA;               OrderedDict([(&#x27;tag&#x27;,&#xA;                             [OrderedDict([(&#x27;@key&#x27;, &#x27;language&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;und&#x27;)]),&#xA;                              OrderedDict([(&#x27;@key&#x27;, &#x27;handler_name&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;VideoHandler&#x27;)]),&#xA;                              OrderedDict([(&#x27;@key&#x27;, &#x27;vendor_id&#x27;),&#xA;                                           (&#x27;@value&#x27;, &#x27;[0][0][0][0]&#x27;)]),&#xA;                              OrderedDict([(&#x27;@key&#x27;, &#x27;encoder&#x27;),&#xA;                                           (&#x27;@value&#x27;,&#xA;                                            &#x27;Lavc61.8.100 libx264&#x27;)])])]))])}&#xA;

    &#xA;

    I used 10 seconds by adding this to the bottom of the loop shown above :

    &#xA;

        if idx >= 200:&#xA;        break&#xA;

    &#xA;