Recherche avancée

Médias (1)

Mot : - Tags -/stallman

Autres articles (37)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Changer son thème graphique

    22 février 2011, par

    Le thème graphique ne touche pas à la disposition à proprement dite des éléments dans la page. Il ne fait que modifier l’apparence des éléments.
    Le placement peut être modifié effectivement, mais cette modification n’est que visuelle et non pas au niveau de la représentation sémantique de la page.
    Modifier le thème graphique utilisé
    Pour modifier le thème graphique utilisé, il est nécessaire que le plugin zen-garden soit activé sur le site.
    Il suffit ensuite de se rendre dans l’espace de configuration du (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (6248)

  • Exception in Tkinter callback while saving animation with matplotlib

    24 août 2017, par paul

    I’m a little hesitant about asking this, since there seem to be many "Exception in Tkinter callback" questions, but I cannot find one that fits the problem I have here.

    I am trying to save an MP4 animation (of a percolation simulation) using matplotlib with ffmpeg. The code works fine on my home laptop, but not on my work PC. It also works fine if I replace the anim.save line with plt.show(), but I do want to save the animation. I’m using Python 3.5.2 on Ubuntu 17.04 (and I have ffmpeg installed).

    Here is the error :

    >>> Exception in Tkinter callback
    Traceback (most recent call last):
     File "/usr/lib/python3.5/tkinter/__init__.py", line 1558, in __call__
       return self.func(*args)
     File "/usr/lib/python3.5/tkinter/__init__.py", line 604, in callit
       func(*args)
     File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 373, in idle_draw
       self.draw()
     File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 354, in draw
       FigureCanvasAgg.draw(self)
     File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_agg.py", line 474, in draw
       self.figure.draw(self.renderer)
     File "/usr/lib/python3/dist-packages/matplotlib/artist.py", line 62, in draw_wrapper
       draw(artist, renderer, *args, **kwargs)
     File "/usr/lib/python3/dist-packages/matplotlib/figure.py", line 1165, in draw
       self.canvas.draw_event(renderer)
     File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 1809, in draw_event
       self.callbacks.process(s, event)
     File "/usr/lib/python3/dist-packages/matplotlib/cbook.py", line 563, in process
       proxy(*args, **kwargs)
     File "/usr/lib/python3/dist-packages/matplotlib/cbook.py", line 430, in __call__
       return mtd(*args, **kwargs)
     File "/usr/lib/python3/dist-packages/matplotlib/animation.py", line 661, in _start
       self._init_draw()
     File "/usr/lib/python3/dist-packages/matplotlib/animation.py", line 1221, in _init_draw
       self._draw_frame(next(self.new_frame_seq()))
    StopIteration

    The code producing the error is :

    def percolate():

       # initialize an instance of the Percolator class
       perc = Percolator(1, 100, 0.1)

       # initialize the image
       fig, ax = plt.subplots()
       im = plt.imshow(perc.states)

       anim = animation.FuncAnimation(fig, perc.update, perc.update_iter, repeat=False, fargs=(im, ), save_count=perc.n**2)
       anim.save("perc.mp4")

    I can reproduce the code for the Percolator class if necessary, but that part is working fine. It has two functions : update_iter, a generator function that yields True as long as the animation should continue, and update, which takes (the result of the iterator and) im as inputs, and its last two lines are

    im.set_array(self.states)
    return im,

    UPDATE :

    Here’s an MWE.

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import animation


    class Percolator:

       def __init__(self):
           self.i = 0
           self.states = np.zeros((10, 10))
           self.end = False

       def update(self, garbage=None, im=None):
           self.i += 1
           if self.i == 10:
               self.end = True
           im.set_array(self.states)
           return im,

       def update_iter(self):
           while self.end == False:
               yield True

    def percolate():

       perc = Percolator()
       fig, ax = plt.subplots()
       im = plt.imshow(perc.states)

       anim = animation.FuncAnimation(fig, perc.update, perc.update_iter, repeat=False, \
                                      fargs=(im, ), save_count=100)

       anim.save("perc.gif", writer="imagemagick")

    In this example, the Percolator class doesn’t do anything interesting - it sets up a 10x10 grid of 0s, and each call to its update function sets the image to the same 10x10 grid.

    If the frames attribute of FuncAnimation is set to 50 (say), rather than to perc.update_iter, then there is no error and the image is saved correctly. So the problem seems to be with my generator function. I want to use the generator function because I want to keep creating new frames until some condition on perc.states is met - here, boringly, I’ve just asked it to keep going for 10 iterations.

    System details : Python 3.5.3, matplotlib 2.0.0, Ubuntu 17.04.

    UPDATE 2 :

    Same problem after upgrading to matplotlib 2.0.2. Also, printing some output along the way reveals that the error occurs at the end of the iterations. In fact, if update_iter is changed to :

    def update_iter(self):
       print(self.end)
       while self.end == False:
           yield True

    ... then the output is :

    False
    False
    False
    False
    False
    False
    False
    False
    False
    False
    False
    True
    >>> True
    Exception in Tkinter callback
    Traceback (most recent call last):
    etc.
  • streaming data with ffmpeg using pipe - freeze after few seconds

    13 octobre 2022, par tamirg

    Im fetching some video data, and trying to stream it using ffmpeg.
what i do is create an ffmpeg process, set it to get info from '-', and then when i fetch the video data i write it to the process STDIN.

    


    My problem is that its working, but only working for around 3 seconds, then the stream stops, and there are no longer any logs from ffmpeg.

    


    Im running ffmpeg with log level debug, and it seems to parse the data ok, which i guess thats why it works for 3 seconds, but then the ffmpeg stops printing any more logs.

    


    I dont want to attach all the logs because its too much, but ill write the main parts.
Maybe the ffmpeg process is missing some arguments ?

    


    It starts with :

    


    Clipping frame in rate conversion by 0.000008
2022-10-13T09:16:53.535546194Z cur_dts is invalid (this is harmless if it occurs once at the start per stream)
2022-10-13T09:16:53.535987546Z     Last message repeated 2 times
2022-10-13T09:16:53.536012520Z [hevc @ 0x55f4e8798100] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.537017901Z [hevc @ 0x55f4e86eeb80] Decoded frame with POC 0.
2022-10-13T09:16:53.538652961Z [hevc @ 0x55f4e8798100] Output frame with POC 8.
2022-10-13T09:16:53.538782714Z [hevc @ 0x55f4e8789c00] Decoded frame with POC 1.
2022-10-13T09:16:53.540362322Z [hevc @ 0x55f4e8773500] Decoded frame with POC 2.
2022-10-13T09:16:53.540989229Z cur_dts is invalid (this is harmless if it occurs once at the start per stream)
2022-10-13T09:16:53.541118680Z     Last message repeated 1 times
2022-10-13T09:16:53.541161109Z [hevc @ 0x55f4e86eeb80] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.542663730Z [hevc @ 0x55f4e86eeb80] Output frame with POC 9.
2022-10-13T09:16:53.544954074Z [hevc @ 0x55f4e8783e80] Decoded frame with POC 3.
2022-10-13T09:16:53.545102776Z cur_dts is invalid (this is harmless if it occurs once at the start per stream)
2022-10-13T09:16:53.545165406Z     Last message repeated 2 times
2022-10-13T09:16:53.545175969Z [hevc @ 0x55f4e8789c00] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.546742754Z [hevc @ 0x55f4e8789c00] Output frame with POC 10.
2022-10-13T09:16:53.547695241Z [hevc @ 0x55f4e8877c40] Decoded frame with POC 4.
2022-10-13T09:16:53.549347290Z cur_dts is invalid (this is harmless if it occurs once at the start per stream)


    


    then :

    


    2022-10-13T09:16:53.828180084Z cur_dts is invalid (this is harmless if it occurs once at the start per stream)

2022-10-13T09:16:53.831843061Z     Last message repeated 2 times
2022-10-13T09:16:53.831902903Z [hevc @ 0x55f4e88984c0] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.831909160Z [hevc @ 0x55f4e88984c0] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.831912827Z [hevc @ 0x55f4e88984c0] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.832173968Z [hevc @ 0x55f4e88984c0] nal_unit_type: 19(IDR_W_RADL), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.832309139Z [hevc @ 0x55f4e88984c0] Decoding VPS
2022-10-13T09:16:53.832324955Z [hevc @ 0x55f4e88984c0] Main profile bitstream
2022-10-13T09:16:53.832651015Z [hevc @ 0x55f4e88984c0] Decoding SPS
2022-10-13T09:16:53.832730623Z [hevc @ 0x55f4e88984c0] Main profile bitstream
2022-10-13T09:16:53.832785521Z [hevc @ 0x55f4e88984c0] Decoding VUI
2022-10-13T09:16:53.832833202Z [hevc @ 0x55f4e88984c0] Decoding PPS
2022-10-13T09:16:53.833112865Z [hevc @ 0x55f4e88984c0] Output frame with POC 0.
2022-10-13T09:16:53.835713007Z [hevc @ 0x55f4e8888080] Decoded frame with POC 59.
2022-10-13T09:16:53.836572581Z [libx264 @ 0x55f4e8794800] frame=   0 QP=44.23 NAL=3 Slice:I Poc:0   I:14400 P:0    SKIP:0    size=41597 bytes
2022-10-13T09:16:53.836783822Z [rtp @ 0x55f4eaa75fc0] Sending NAL 7 of len 24 M=0
2022-10-13T09:16:53.836805582Z [rtp @ 0x55f4eaa75fc0] Sending NAL 8 of len 4 M=0
2022-10-13T09:16:53.836809885Z [rtp @ 0x55f4eaa75fc0] Sending NAL 6 of len 642 M=0
2022-10-13T09:16:53.836830503Z [rtp @ 0x55f4eaa75fc0] Sending NAL 5 of len 40913 M=1
2022-10-13T09:16:53.836836082Z [rtp @ 0x55f4eaa75fc0] NAL size 40913 > 1460
2022-10-13T09:16:53.837084718Z [hevc @ 0x55f4e88a8900] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.837193504Z [hevc @ 0x55f4e88a8900] Output frame with POC 1.
2022-10-13T09:16:53.844457060Z [libx264 @ 0x55f4e8794800] frame=   1 QP=48.02 NAL=2 Slice:P Poc:2   I:16   P:655  SKIP:13729 size=1459 bytes
2022-10-13T09:16:53.844621824Z [rtp @ 0x55f4eaa75fc0] Sending NAL 1 of len 1455 M=1
2022-10-13T09:16:53.844680058Z [hevc @ 0x55f4e8798100] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:53.844749212Z [hevc @ 0x55f4e8798100] Output frame with POC 2.
2022-10-13T09:16:53.851913353Z [libx264 @ 0x55f4e8794800] frame=   2 QP=44.00 NAL=2 Slice:P Poc:4   I:0    P:11   SKIP:14389 size=48 bytes


    


    and finally the last logs are those, and afterwards i don't get anymore logs :

    


    2022-10-13T09:16:56.836957083Z [NULL @ 0x55f4e86e7a00] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:56.837158270Z [hevc @ 0x55f4e8773500] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
2022-10-13T09:16:56.837355973Z [hevc @ 0x55f4e8773500] Output frame with POC 59.
2022-10-13T09:16:56.837935475Z [hevc @ 0x55f4e86eeb80] Decoded frame with POC 57.
2022-10-13T09:16:56.840799210Z [hevc @ 0x55f4e8789c00] Decoded frame with POC 58.
2022-10-13T09:16:56.842434529Z [libx264 @ 0x55f4e8794800] frame=  59 QP=33.00 NAL=2 Slice:P Poc:118 I:11   P:952  SKIP:13437 size=5251 bytes
2022-10-13T09:16:56.842472226Z [rtp @ 0x55f4eaa75fc0] Sending NAL 1 of len 5247 M=1
2022-10-13T09:16:56.842478464Z [rtp @ 0x55f4eaa75fc0] NAL size 5247 > 1460
2022-10-13T09:16:56.846625001Z [hevc @ 0x55f4e8773500] Decoded frame with POC 59.


    


  • Sending frames from memory to FFMPEG command line program .NET 6

    15 septembre 2021, par Alessandro Martinelli

    I'm trying to use the pipe to send frames generated by my program to ffmpeg command line utility without saving them on disk. Please note I was able to generate a video by first saving frames on disk as images and then having FFMPEG generate a video from such images, but that approach is worse performance-wise and implies writing more data on SSD.

    


    I could use the help of this post, but I have FFMPEG returning an error on frame size, and I don't know how to solve it.

    


    My code is the following :

    


    //object storing single frame returned from camera
mv.impact.acquire.Request pRequest; 
string outputPath = ...;
List frames = new List();

[...]

// Single frame is saved into memory
MemoryStream stream = new MemoryStream();
using (RequestBitmapData data = pRequest.bitmapData) {
    data.bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
    // Please note that now printing data.bitmap.PixelFormat would return Format24bppRgb
}
frames.Add(stream.ToArray());

[...] 

Console.WriteLine(frames.Count + " frames collected. First one length is " + frames.First().Length);

string ffmpegArgument = "/C " + _ffmpegPath + "\\ffmpeg -y -f rawvideo -pix_fmt rgb24 -framerate 3 -video_size 728x544 -i - -c:v libx264 -preset 9 -c:a libvo_aacenc " + outputPath;

Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.Arguments = ffmpegArgument;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardError = false;
cmd.StartInfo.RedirectStandardInput = true;

Console.WriteLine("Executing command " + ffmpegArgument + "...");
cmd.Start();
foreach (byte[] frame in frames) {
        cmd.StandardInput.Write(frame);
}
cmd.StandardInput.Flush();
cmd.StandardInput.Close();


    


    However, when I execute the program, I have the following output :

    


    492 frames collected. First one length is 1188150
Executing command /C ExternalTools\FFmpeg\ffmpeg -y -f rawvideo -pix_fmt rgb24 -framerate 32 -video_size 728x544 -i - -c:v libx264 -preset ultrafast -c:a libvo_aacenc -b:a 128k "Output\TemporaryVideo\2021-09-13 18_58_58.mp4"...
ffmpeg version 2021-06-27-git-49e3a8165c-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.3.0 (Rev2, Built by MSYS2 project)

[...] (configurations)

[rawvideo @ 00000241d34feac0] Packet corrupt (stream = 0, dts = 0).
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, start: 0.000000, bitrate: 304152 kb/s
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 728x544, 304152 kb/s, 32 tbr, 32 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
pipe:: corrupt input packet in stream 0
[rawvideo @ 00000241d3511640] Invalid buffer size, packet size 6396 < expected frame_size 1188096
Error while decoding stream #0:0: Invalid argument

[...] (cpu capabilities)

Output #0, mp4, to 'Output\TemporaryVideo\2021-09-13 18_58_58.mp4':
  Metadata:
    encoder         : Lavf59.3.101
  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv444p, 728x544, q=2-31, 32 fps, 16384 tbn
    Metadata:
      encoder         : Lavc59.2.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!


    


    The value expected by FFMPEG seems correct (1188096 = 728 x 544 x 3), but I don't understand where FFMPEG gets that "packet size 6396" from. Furthermore, that value (6396) changes at every program execution.

    


    I'm pretty sure frames are not corrupted since, if I save such frames on disk, the image is generated correctly.

    


    Thank you for your time,
Alessandro