Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (76)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, 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 (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

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

Sur d’autres sites (8063)

  • FFMPEG Implement RTSP Client, high speed playback

    11 juillet 2021, par TTGroup

    I am writing software to play videos that have been recorded from NVR. I have completed most of the work, but there is one more feature that allows the user to change the play speed such as 0.5x, 2x, 4x, 8x ...

    


    I searched the internet all day and still couldn't find any suggestions. Here is my summary code below.

    


    auto pFormatCtx = avformat_alloc_context();

av_dict_set_int(&opts, "rw_timeout", 5000000, 0);
av_dict_set_int(&opts, "tcp_nodelay", 1, 0);
av_dict_set_int(&opts, "stimeout", 10000000, 0);
av_dict_set(&opts, "user_agent", "Mozilla/5.0", 0);
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
av_dict_set(&opts, "rtsp_flags", "prefer_tcp", 0);
av_dict_set_int(&opts, "buffer_size", BUFSIZE, 0);

int err = avformat_open_input(&pFormatCtx, fullRtspUri, NULL, &opts);
if(err < 0)
    return;
    
err = avformat_find_stream_info(pFormatCtx, NULL);
if (err < 0)
    return;
pFormatCtx->flags |= AVFMT_FLAG_NONBLOCK;
pFormatCtx->flags |= AVFMT_FLAG_DISCARD_CORRUPT;
pFormatCtx->flags |= AVFMT_FLAG_NOBUFFER;       
av_dump_format(pFormatCtx, 0, fullRtspUri, 0);
    
int videoStreamInd = -1;
for (int i = 0; i < pFormatCtx->nb_streams; i++)
{
    AVStream* stream = pFormatCtx->streams[i];
    if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
    {
        if (videoStreamInd == -1)
        {
            videoStreamInd = i;
            break;
        }
    }   
}

if (videoStreamInd == -1)
    return; 
auto videoStream = pFormatCtx->streams[videoStreamInd];

isRunning = true;
while(isRunning)
{
    ret = av_read_frame(pFormatCtx, avPacket);
    if (ret < 0)
        return; 

    if (avPacket->stream_index != videoStreamInd)
        continue;
    
    //Code for render process here............
}


    


    I have read through this NVR API documentation and see support for 2x, 4x speed play as below

    


    Play in 2× Speed:
PLAY rtsp://10.17.133.46:554/ISAPI/streaming/tracks/101?starttime=20170313T230652Z&endtime=20170314T025706Z RTSP/1.0
CSeq:6
Authorization: Digest username="admin", 
realm="4419b66d2485", 
nonce="a0ecd9b1586ff9461f02f910035d0486", 
uri="rtsp://10.17.133.46:554/ISAPI/streaming/tracks/101?starttime=20170313T230652Z&endtime=20170314T025706Z", 
response="fb986d385a7d839052ec4f0b2b70c631"
Session:2049381566;timeout=60
Scale:2.000
User-Agent:NKPlayer-1.00.00.081112

RTSP/1.0 200 OK
CSeq: 6
Session: 2049381566
Scale: 2.000
RTP-Info: url=trackID=1;seq=1,url=trackID=2;seq=1
Date: Tue, Mar 14 2017 10:57:24 GMT


    


    How to play RTSP video with speeds of 0.5x, 2x, 4x ...?
Everyone who can assist me in this case, I am very grateful.

    


  • How to save animations with tight layout, transparency and in high quality with matplotlib ?

    29 novembre 2019, par mapf

    I am trying to implement an option in my GUI to save an image sequence displayed using matplotlib. The code looks something like this :

    import matplotlib.pyplot as plt
    from matplotlib.backends.backend_qt5agg import \
       FigureCanvasQTAgg as FigureCanvas
    from matplotlib.animation import FuncAnimation
    from PIL import Image


    plt.rcParams['savefig.bbox'] = 'tight'


    class Printer:
       def __init__(self, data):
           self.fig, self.ax = plt.subplots()
           self.canvas = FigureCanvas(self.fig)

           # some irrelevant color adjustment here
           #self.ax.spines['bottom'].set_color('#f9f2d7')
           #self.ax.spines['top'].set_color('#f9f2d7')
           #self.ax.spines['right'].set_color('#f9f2d7')
           #self.ax.spines['left'].set_color('#f9f2d7')
           #self.ax.tick_params(axis='both', colors='#f9f2d7')
           #self.ax.yaxis.label.set_color('#f9f2d7')
           #self.ax.xaxis.label.set_color('#f9f2d7')
           #self.fig.subplots_adjust(left=0.1, right=0.975, bottom=0.09, top=0.98)
           self.fig.patch.set_alpha(0)
           self.fig.patch.set_visible(False)
           self.canvas.setStyleSheet("background-color:transparent;")
           self.fig.set_size_inches(10, 10, True)
           self.fig.tight_layout()

           self.data = data
           self.image_artist = self.ax.imshow(data[0])

       def animate(self, i):
           self.image_artist.set_data(self.data[i])
           self.canvas.draw()


    def save_animation():
       data = [
           Image.open("test000.png"),
           Image.open("test001.png"),
       ]
       file = 'test.gif'
       printer = Printer(data)

       ani = FuncAnimation(
           printer.fig, printer.animate, interval=100, frames=len(data),
       )
       # writer = animation.writers['pillow'](bitrate=1000)
       ani.save(
           file, writer='pillow', savefig_kwargs={'transparent': True, 'bbox_inches': 'tight'}
       )


    save_animation()

    Transparency :

    As you can see I have already tried several different approaches as suggested elsewhere (1, 2), but didn’t manage to find a solution. All of the settings and arguments patch.set_alpha(0), patch.set_visible(False), canvas.setStyleSheet("background-color:transparent;"), savefig_kwargs={'transparent': True} seem to have no effect at all on the transparency. I found this post but I didn’t get the code to work (for one I had to comment out this %matplotlib inline, but then I ended up getting some error during the MovieWriter.cleanup out = TextIOWrapper(BytesIO(out)).read() TypeError: a bytes-like object is required, not 'str'). Here, it was suggested that this is actually a bug, but the proposed workaroud doesn’t work for me since I would have to rely on third-party software. There also exists this bug report which was supposedly solved, so maybe it is unrelated.

    Tight layout

    I actually couldn’t really find much on this, but all the things I tried (plt.rcParams['savefig.bbox'] = 'tight', fig.tight_layout(), savefig_kwargs={'bbox_inches': 'tight'}) don’t have any effect or are even actively discarded in the case of the bbox_inches argument. How does this work ?

    High quality

    Since I cannot use ImageMagick and can’t get ffmpeg to work (more on this below), I rely on pillow to save my animation. But the only argument in terms of quality that I can pass on seems to be the bitrate, which doesn’t have any effect. The files still have the same size and the animation still looks like mush. The only way that I found to increase the resolution was to use fig.set_size_inches(10, 10, True), but this still doesn’t improve the overall quality of the animation. It still looks bad. I saw that you can pass on codec and extra_args so maybe that is something that might help, but I have no idea how to use these because I couldn’t find a list with allowed arguments.

    ffmpeg

    I can’t get ffmpeg to work. I installed the python package from here and can import it into a python session but I don’t know how I can get matplotlib to use that. I also got ffmpeg from here (Windows 64-bit version) and set the plt.rcParams['animation.ffmpeg_path'] to where I saved the files (there was no intaller to run, not sure if I did it correctly). But this didn’t help either. Also this is of course also third-party software, so if somebody else were to use my code/program it wouldn’t work.

  • Preserving or syncing audio of original video to video fragments

    2 mai 2015, par Code_Ed_Student

    I currently have a few videos that I want to split into EXACTLY 30 seconds segments. I have been able to accomplish but the audio is not being properly preserve. Its out of sync. I tried playing arsample ab and other libraries but I am not getting the desired outuput. What would be the best way to both split the videos in exactly 30 second frames and preserve the audio ?

    ffmpeg -i $file -preset medium -map 0 -segment_time 30 -g 225 -r 25  -sc_threshold 0 -force_key_frames expr:gte(t,n_forced*30) -f segment -movflags faststart -vf scale=-1:720,format=yuv420p -vcodec libx264 -crf 20 -codec:a copy $dir/$video_file-%03d.mp4

    short snippet of output

    Input #0, flv, from '/media/sf_linux_sandbox/hashtag_pull/video-downloads/5b64d7ab-a669-4016-b55e-fe4720cbd843/5b64d7ab-a669-4016-b55e-fe4720cbd843.flv':
     Metadata:
       moovPosition    : 40
       avcprofile      : 77
       avclevel        : 31
       aacaot          : 2
       videoframerate  : 30
       audiochannels   : 2
       ©too           : Lavf56.15.102
       length          : 7334912
       sampletype      : mp4a
       timescale       : 48000
     Duration: 00:02:32.84, start: 0.000000, bitrate: 2690 kb/s
       Stream #0:0: Video: h264 (Main), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 30.30 fps, 29.97 tbr, 1k tbn, 59.94 tbc
       Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
    [libx264 @ 0x3663ba0] using SAR=1/1
    [libx264 @ 0x3663ba0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
    [libx264 @ 0x3663ba0] profile High, level 3.1
    [libx264 @ 0x3663ba0] 264 - core 144 r2 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=225 keyint_min=22 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, segment, to '/media/sf_linux_sandbox/hashtag_pull/video-edits/30/5b64d7ab-a669-4016-b55e-fe4720cbd843/5b64d7ab-a669-4016-b55e-fe4720cbd843-%03d.mp4':
     Metadata:
       moovPosition    : 40
       avcprofile      : 77
       avclevel        : 31
       aacaot          : 2
       videoframerate  : 30
       audiochannels   : 2
       ©too           : Lavf56.15.102
       length          : 7334912
       sampletype      : mp4a
       timescale       : 48000
       encoder         : Lavf56.16.102
       Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
       Metadata:
         encoder         : Lavc56.19.100 libx264
       Stream #0:1: Audio: aac, 48000 Hz, stereo
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (copy)