Recherche avancée

Médias (0)

Mot : - Tags -/optimisation

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

Autres articles (82)

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

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (10190)

  • x86 : hevc_mc : save 1 gpr in epel filter loading

    7 février 2015, par Christophe Gisquet
    x86 : hevc_mc : save 1 gpr in epel filter loading
    

    The 3*stride value stored in r3src can be loaded much later,
    so use r3src instead of a dedicated gpr when possible.

    Signed-off-by : Michael Niedermayer <michaelni@gmx.at>

    • [DH] libavcodec/x86/hevc_mc.asm
  • How to save AVPacket if I have input information from online camera

    31 mars 2020, par Orest

    I am new to libav.&#xA;I have a online video camera and want save video from archive to the video file with libav

    &#xA;&#xA;

    Camera provides such data

    &#xA;&#xA;

    uint32_t frameType, // I frame or P frame&#xA;&#xA;void *frame, //pointer to the frame&#xA;&#xA;size_t frameSize, //size of the frame in bytes&#xA;&#xA;uint64_t timeStamp, //time stamp in time_t units&#xA;&#xA;uint32_t width, //frame width&#xA;&#xA;uint32_t height, //frame heigh&#xA;&#xA;uint32_t genTime, //I do not now what is this. allways 0&#xA;&#xA;const char *encodingType //H264 or H265&#xA;

    &#xA;&#xA;

    I tried this

    &#xA;&#xA;

    void writeHeader(){&#xA;mOutputFilePath = outputFilePath;&#xA;    int ret = 0;&#xA;    avformat_alloc_output_context2(&amp;output_format_context, nullptr, nullptr, outputFilePath.c_str());&#xA;&#xA;AVStream *out_stream;&#xA;        out_stream = avformat_new_stream(output_format_context, nullptr);&#xA;&#xA;        out_stream->discard = AVDISCARD_DEFAULT;//не змінювати&#xA;        out_stream->codecpar->level = 42;//не змінювати&#xA;        out_stream->codecpar->profile = FF_PROFILE_H264_HIGH;//не змінювати&#xA;        out_stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;&#xA;        if(codecID == "H264") out_stream->codecpar->codec_id = AV_CODEC_ID_H264;&#xA;        else if(codecID == "H265") out_stream->codecpar->codec_id = AV_CODEC_ID_H265;&#xA;&#xA;        out_stream->codecpar->format = AV_PIX_FMT_YUV420P;&#xA;        out_stream->codecpar->height = heightFrame;&#xA;        out_stream->codecpar->width = widthFrame;&#xA;        //        out_stream->codecpar->bit_rate = 2478235;&#xA;        //        out_stream->codecpar->bits_per_coded_sample = 24;&#xA;        //        out_stream->codecpar->bits_per_raw_sample = 8;&#xA;        out_stream->codecpar->sample_aspect_ratio.num = 0;&#xA;        out_stream->codecpar->sample_aspect_ratio.den = 1;&#xA;        out_stream->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED;//не змінювати&#xA;&#xA;avio_open(&amp;output_format_context->pb, mOutputFilePath.c_str(), AVIO_FLAG_WRITE);&#xA;avformat_write_header(output_format_context, &amp;opt);&#xA;}&#xA;&#xA;void writePacket(){&#xA; AVPacket inputPacket;&#xA;        av_init_packet(&amp;inputPacket);&#xA;        inputPacket.buf = NULL;&#xA;        inputPacket.pts = (int)timeStamp;&#xA;        inputPacket.dts = inputPacket.pts; &#xA;        inputPacket.data = (unsigned char*)frame;&#xA;        inputPacket.size = (int)frameSize;&#xA;&#xA;        if (frameType == KP2P_FRAME_TYPE_IFRAME)&#xA;        {&#xA;            inputPacket.flags = AV_PKT_FLAG_KEY;&#xA;        }&#xA;        inputPacket.duration = 0;&#xA;        inputPacket.pos = -1;&#xA;av_interleaved_write_frame(output_format_context, &amp;inputPacket);&#xA;    av_packet_unref(&amp;inputPacket);&#xA;}&#xA;&#xA;void closeFile()&#xA;{&#xA;av_write_trailer(output_format_context);&#xA;    if (output_format_context &amp;&amp; !(output_format_context->oformat->flags &amp; AVFMT_NOFILE))&#xA;        avio_closep(&amp;output_format_context->pb);&#xA;    avformat_free_context(output_format_context);&#xA;}&#xA;

    &#xA;&#xA;

    in output file I have black vindow and time is not correct (input 30 seconds in out 2 seconds)&#xA;What am I doing wrong ?

    &#xA;

  • Python : ani.save very slow. Any alternatives to create videos ?

    14 novembre 2023, par Czeskleba

    Im doing some simple diffusion calculations. I save 2 matrices to 2 datasets every so many steps (every 2s or so) to a single .h5 file. After that I then load the file in another script, create some figures (2 subplots etc., see/run code - i know could be prettier). Then I use matplotlib.animation to make the animation. In the code below, in the very last lines, I then run the ani.save command from matplotlib.

    &#xA;

    And that's where the problem is. The animation is created within 2 seconds, even for my longer animations (14.755 frames, done in under 2s at 8284 it/s) but after that, ani.save in line 144 takes forever (it didn't finish over night). It reserves/uses about 10gb of my RAM constantly but seemingly takes forever. If you run the code below be sure to set the frames_to_do (line 20) to something like 30 or 60 to see that it does in fact save an mp4 for shorter videos. You can set it higher to see how fast the time to save stuff increases to something unreasonable.

    &#xA;

    I've been fiddling this for 2 days now and I cant figure it out. I guess my question is : Is there any way to create the video in a reasonable time like this ? Or do I need something other than animation ?

    &#xA;

    You should be able to just run the code. Ill provide a diffusion_array.h5 with 140 frames so you dont have to create a dummy file, if I can figure out how to upload something like this safely. (The results are with dummy numbers for now, diffusion coefficients etc. are not right yet.)&#xA;I used dropbox. Not sure if thats allowed, if not I'll delete the link and uhh PM me or something ?

    &#xA;

    https://www.dropbox.com/scl/fi/fv9stfqkm4trmt3zwtvun/diffusion_array.h5?rlkey=2oxuegnlcxq0jt6ed77rbskyu&dl=0

    &#xA;

    Here is the code :

    &#xA;

    import h5py&#xA;import matplotlib.pyplot as plt&#xA;import matplotlib.colors as mcolors&#xA;from matplotlib.animation import FuncAnimation&#xA;from tqdm import tqdm&#xA;import numpy as np&#xA;&#xA;&#xA;# saving the .mp4 after tho takes forever&#xA;&#xA;# Create an empty figure and axis&#xA;fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 9), dpi=96)&#xA;&#xA;# Load all saved arrays into a list&#xA;file_name = &#x27;diffusion_array.h5&#x27;&#xA;loaded_u_arrays = []&#xA;loaded_h_arrays = []&#xA;frames_to_do = 14755  # for now like this, use # version once the slow mp4 convert is cleared up&#xA;&#xA;# with h5py.File(file_name, &#x27;r&#x27;) as hf:&#xA;#     for key in hf.keys():&#xA;#         if key.startswith(&#x27;u_snapshot_&#x27;):&#xA;#             loaded_u_arrays.append(hf[key][:])&#xA;#         elif key.startswith(&#x27;h_snapshot_&#x27;):&#xA;#             loaded_h_arrays.append(hf[key][:])&#xA;&#xA;with h5py.File(file_name, &#x27;r&#x27;) as hf:&#xA;    for i in range(frames_to_do):&#xA;        target_key1 = f&#x27;u_snapshot_{i:05d}&#x27;&#xA;        target_key2 = f&#x27;h_snapshot_{i:05d}&#x27;&#xA;        if target_key1 in hf:&#xA;            loaded_u_arrays.append(hf[target_key1][:])&#xA;        else:&#xA;            print(f&#x27;Dataset u for time step {i} not found in the file.&#x27;)&#xA;        if target_key2 in hf:&#xA;            loaded_h_arrays.append(hf[target_key2][:])&#xA;        else:&#xA;            print(f&#x27;Dataset h for time step {i} not found in the file.&#x27;)&#xA;&#xA;# Create "empty" imshow objects&#xA;# First one&#xA;norm1 = mcolors.Normalize(vmin=140, vmax=400)&#xA;cmap1 = plt.get_cmap(&#x27;hot&#x27;)&#xA;cmap1.set_under(&#x27;0.85&#x27;)&#xA;im1 = ax1.imshow(loaded_u_arrays[0], cmap=cmap1, norm=norm1)&#xA;ax1.set_title(&#x27;Diffusion Heatmap&#x27;)&#xA;ax1.set_xlabel(&#x27;X&#x27;)&#xA;ax1.set_ylabel(&#x27;Y&#x27;)&#xA;cbar_ax = fig.add_axes([0.05, 0.15, 0.03, 0.7])&#xA;cbar_ax.set_xlabel(&#x27;$T$ / K&#x27;, labelpad=20)&#xA;fig.colorbar(im1, cax=cbar_ax)&#xA;&#xA;&#xA;# Second one&#xA;ax2 = plt.subplot(1, 2, 2)&#xA;norm2 = mcolors.Normalize(vmin=-0.1, vmax=5)&#xA;cmap2 = plt.get_cmap(&#x27;viridis&#x27;)&#xA;cmap2.set_under(&#x27;0.85&#x27;)&#xA;im2 = ax2.imshow(loaded_h_arrays[0], cmap=cmap2, norm=norm2)&#xA;ax2.set_title(&#x27;Diffusion Hydrogen&#x27;)&#xA;ax2.set_xlabel(&#x27;X&#x27;)&#xA;ax2.set_ylabel(&#x27;Y&#x27;)&#xA;cbar_ax = fig.add_axes([0.9, 0.15, 0.03, 0.7])&#xA;cbar_ax.set_xlabel(&#x27;HD in ml/100g&#x27;, labelpad=20)&#xA;fig.colorbar(im2, cax=cbar_ax)&#xA;&#xA;# General&#xA;fig.subplots_adjust(right=0.85)&#xA;time_text = ax2.text(-15, 0.80, f&#x27;Time: {0} s&#x27;, transform=plt.gca().transAxes, color=&#x27;black&#x27;, fontsize=20)&#xA;&#xA;# Annotations&#xA;# Heat 1&#xA;marker_style = dict(marker=&#x27;o&#x27;, markersize=6, markerfacecolor=&#x27;black&#x27;, markeredgecolor=&#x27;black&#x27;)&#xA;ax1.scatter(*[10, 40], s=marker_style[&#x27;markersize&#x27;], c=marker_style[&#x27;markerfacecolor&#x27;],&#xA;            edgecolors=marker_style[&#x27;markeredgecolor&#x27;])&#xA;ann_heat1 = ax1.annotate(f&#x27;Temp: {loaded_u_arrays[0][40, 10]:.0f}&#x27;, xy=[10, 40], xycoords=&#x27;data&#x27;,&#xA;             xytext=([10, 40][0], [10, 40][1] &#x2B; 48), textcoords=&#x27;data&#x27;,&#xA;             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color=&#x27;black&#x27;)&#xA;# Heat 2&#xA;ax1.scatter(*[140, 85], s=marker_style[&#x27;markersize&#x27;], c=marker_style[&#x27;markerfacecolor&#x27;],&#xA;            edgecolors=marker_style[&#x27;markeredgecolor&#x27;])&#xA;ann_heat2 = ax1.annotate(f&#x27;Temp: {loaded_u_arrays[0][85, 140]:.0f}&#x27;, xy=[140, 85], xycoords=&#x27;data&#x27;,&#xA;             xytext=([140, 85][0] &#x2B; 55, [140, 85][1] &#x2B; 3), textcoords=&#x27;data&#x27;,&#xA;             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color=&#x27;black&#x27;)&#xA;&#xA;# Diffusion 1&#xA;marker_style = dict(marker=&#x27;o&#x27;, markersize=6, markerfacecolor=&#x27;black&#x27;, markeredgecolor=&#x27;black&#x27;)&#xA;ax2.scatter(*[10, 40], s=marker_style[&#x27;markersize&#x27;], c=marker_style[&#x27;markerfacecolor&#x27;],&#xA;            edgecolors=marker_style[&#x27;markeredgecolor&#x27;])&#xA;ann_diff1 = ax2.annotate(f&#x27;HD: {loaded_h_arrays[0][40, 10]:.0f}&#x27;, xy=[10, 40], xycoords=&#x27;data&#x27;,&#xA;             xytext=([10, 40][0], [10, 40][1] &#x2B; 48), textcoords=&#x27;data&#x27;,&#xA;             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color=&#x27;black&#x27;)&#xA;# Diffusion 2&#xA;ax2.scatter(*[140, 85], s=marker_style[&#x27;markersize&#x27;], c=marker_style[&#x27;markerfacecolor&#x27;],&#xA;            edgecolors=marker_style[&#x27;markeredgecolor&#x27;])&#xA;ann_diff2 = ax2.annotate(f&#x27;HD: {loaded_h_arrays[0][85, 140]:.0f}&#x27;, xy=[140, 85], xycoords=&#x27;data&#x27;,&#xA;             xytext=([140, 85][0] &#x2B; 55, [140, 85][1] &#x2B; 3), textcoords=&#x27;data&#x27;,&#xA;             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"), fontsize=12, color=&#x27;black&#x27;)&#xA;&#xA;&#xA;# Function to update the animation&#xA;def update(frame, *args):&#xA;    loaded_u_array, loaded_h_array = args&#xA;&#xA;    s_per_frame = 2  # during weld/cooling you save a state every 2s&#xA;    frames_to_room_temp = 7803  # that means this many frames need to be animated&#xA;    dt_big = 87  # during "just diffusion" you save every 10 frame but 87s pass in those&#xA;&#xA;    # Update the time step shown&#xA;    if frame &lt;= frames_to_room_temp:&#xA;        im1.set_data(loaded_u_array[frame])&#xA;        im2.set_data(loaded_h_array[frame])&#xA;        time_text.set_text(f&#x27;Time: {frame * s_per_frame} s&#x27;)&#xA;&#xA;    else:&#xA;        im1.set_data(loaded_u_array[frame])&#xA;        im2.set_data(loaded_h_array[frame])&#xA;        calc_time = int(((2 * frames_to_room_temp) &#x2B; (frame - frames_to_room_temp) * 87) / 3600)&#xA;        time_text.set_text(f&#x27;Time: {calc_time} s&#x27;)&#xA;&#xA;    # Annotate some points&#xA;    ann_heat1.set_text(f&#x27;Temp: {loaded_u_arrays[frame][40, 10]:.0f}&#x27;)&#xA;    ann_heat2.set_text(f&#x27;Temp: {loaded_u_arrays[frame][85, 140]:.0f}&#x27;)&#xA;    ann_diff1.set_text(f&#x27;HD: {loaded_h_arrays[frame][40, 10]:.0f}&#x27;)&#xA;    ann_diff2.set_text(f&#x27;HD: {loaded_h_arrays[frame][85, 140]:.0f}&#x27;)&#xA;&#xA;    return im1, im2  # Return the updated artists&#xA;&#xA;&#xA;# Create the animation without displaying it&#xA;ani = FuncAnimation(fig, update, frames=frames_to_do, repeat=False, blit=True, interval=1,&#xA;                    fargs=(loaded_u_arrays, loaded_h_arrays))  # frames=len(loaded_u_arrays)&#xA;&#xA;# Create the progress bar with tqdm&#xA;with tqdm(total=frames_to_do, desc=&#x27;Creating Animation&#x27;) as pbar:  # total=len(loaded_u_arrays)&#xA;    for i in range(frames_to_do):  # for i in range(len(loaded_u_arrays)):&#xA;        update(i, loaded_u_arrays, loaded_h_arrays)  # Manually update the frame with both datasets&#xA;        pbar.update(1)  # Update the progress bar&#xA;&#xA;# Save the animation as a video file (e.g., MP4)&#xA;print("Converting to .mp4 now. This may take some time. This is normal, wait for Python to finish this process.")&#xA;ani.save(&#x27;diffusion_animation.mp4&#x27;, writer=&#x27;ffmpeg&#x27;, dpi=96, fps=60)&#xA;&#xA;# Close the figure to prevent it from being displayed&#xA;plt.close(fig)&#xA;&#xA;

    &#xA;