Recherche avancée

Médias (91)

Autres articles (106)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

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

  • Live stream is gets delayed while processing frame in opencv + python

    18 mars 2021, par Himanshu sharma

    I capture and process an IP camera RTSP stream in a OpenCV 4.4.0.46 on Ubuntu.
Unfortunately the processing takes quite a lot of time, roughly 0.2s per frame, and the stream quickly gets delayed.
Video file have to save for 5 min but by this delaying video file is saved for 3-4 min only.

    


    Can we process faster to overcome delays ?

    


    I have two IP camera which have two diffrent fps_rate(Camera 1 have 18000 and camera 2 have 20 fps)

    


    I am implementing this code in difference Ubuntu PCs

    


      

    • Python 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0] on linux
    • 


    • Django==3.1.2
    • 


    • Ubuntu = 18.04 and 20.04
    • 


    • opencv-contrib-python==4.4.0.46
    • 


    • opencv-python==4.4.0.46
    • 


    


    input_stream = 'rtsp://'+username+':'+password+'@'+ip+'/user='+username+'_password='+password+'_channel=0channel_number_stream=0.sdp'
input_stream---> rtsp://admin:Admin123@192.168.1.208/user=admin_password=Admin123_channel=0channel_number_stream=0.sdp

input_stream---> rtsp://Admin:@192.168.1.209/user=Admin_password=_channel=0channel_number_stream=0.sdp

vs = cv2.VideoCapture(input_stream)
fps_rate = int(vs.get(cv2.CAP_PROP_FPS))
I have two IP camera which have two diffrent fps_rate(Camera 1 have 18000 and camera 2 have 20 fps)

video_file_name = 0
start_time = time.time()
while(True):
    ret, frame = vs.read()
    time.sleep(0.2)     # <= Simulate processing time (mask detection, face detection and many detection is hapning)


    ###  Start of  writing a video to disk          
    minute = 5  ## saving a file for 5 minute only then saving another file for 5 min
    second  = 60
    minite_to_save_video = int(minute) * int(second)


    # if we are supposed to be writing a video to disk, initialize
    if time.time() - start_time >= minite_to_save_video or  video_file_name == 0 :
        ## where H = heigth, W = width, C = channel 
        H, W, C = frame.shape
        
        print('time.time()-->',time.time(),'video_file_name-->', video_file_name,  ' #####')
        start_time = time.time()

        video_file_name = str(time.mktime(datetime.datetime.now().timetuple())).replace('.0', '')
        output_save_directory = output_stream+str(int(video_file_name))+'.mp4'


        fourcc = cv2.VideoWriter_fourcc(*'avc1')
        
        writer = cv2.VideoWriter(output_save_directory, fourcc,20.0,(W, H), True)

    # check to see if we should write the frame to disk
    if writer is not None:
        
        try:
            writer.write(frame)

        except Exception as e:
            print('Error in writing video output---> ', e)


    


  • ffmpeg stops capturing whole hour of HTTP stream after some time

    7 juillet 2020, par CompuChip

    First of all, sorry if I'm using the wrong terminology. I've been playing around with nginx and I'm still a bit confused about RTMP and HLS and other acronyms.

    


    I've managed to setup OBS to stream to an nginx server, which takes the RTMP stream and chops it into pieces for HLS. Here's the relevant part of the nginx configuration file.

    


    rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        ping 30s;
        deny play all;

        application live {
            live on;
            hls on;
            hls_nested on; # Create a new folder for each stream
            hls_path /mnt/hls/live;
            hls_fragment 3s;
            hls_fragment_naming timestamp;
            hls_playlist_length 60s;
        }
    }
}

http {
    server {
        listen 81 ssl;

        #creates the http-location for our full-resolution (desktop) HLS stream - "http://localhost:8080/live/test/index.m3u8"
        location /live {
            # Elided caching and CORS for brevity

            alias /mnt/hls/live;
            add_header Cache-Control no-cache;
            index index.m3u8;
        }
    }
}


    


    This works well, I can view the stream in VLC or on a website and it looks smooth. Now I wanted to add some logging : I'd like to write full hours (starting at xx:00:00 and ending at xx:59:59) to a file named log_yyyymmdd_hh.mp4, e.g. log_20200707_18.mp4 for the files of 7 July 2020, 18:00 - 19:00 hrs. So I've set up an hourly cron job with the following ffmpeg command :

    


    ffmpeg -i https://stream.example.com:81/live/<streamkey> -preset veryfast -maxrate 2000k \&#xA;    -bufsize 2000k -g 60 -t 3600 -y /var/video/log/$(date &#x2B;\%Y\%m\%d_\%H00).mp4 >/dev/null 2>&amp;1&#xA;</streamkey>

    &#xA;

    At first this seemed to work well, so I left it running happily for about 24 hours. When I checked, most of my hourly files were small ( 100MB) files of about 10 to 15 minutes long. It seems like any small delay in the stream will cause ffmpeg to stop writing to the file. I suspect such hiccups may for example be caused by an OBS plugin and I'll need to look into that, but I would prefer that ffmpeg will retry for some time before giving up. What arguments should I be passing to ffmpeg to make it not break when the stream is down for, say, up to a second every now and then ?.

    &#xA;

    When I view back the HLS files there don't seem to be any noticeable gaps, so eventually all the data arrives. I went for the crontab solution with ffmpeg because when recording from nginx I could not figure out how to start recording at the start of the whole hour.

    &#xA;

  • What am I doing wrong ? Tweepy with ffmpeg

    27 août 2020, par pigeonburger

    I'm trying to get this code to pull the media from any tweet that mentions my twitter handle, convert it using ffmpeg via the subprocess module, then send the converted media back to the person as a reply ? Is this all correct ?&#xA;

    I am also getting an error at tweet_media = clean_data[&#x27;entities&#x27;][&#x27;media&#x27;][&#x27;media_url&#x27;] and I don't understand what I'm doing wrong there (Exception has occurred : TypeError&#xA;list indices must be integers or slices, not str&#xA;line 32, in on_data&#xA;tweet_media = clean_data['entities']['media']['media_url'])

    &#xA;

    Also is there a better way to use ffmpeg with python that I am not aware of ?

    &#xA;

    Here is the code I wrote that I'm trying to use :

    &#xA;

    import tweepy&#xA;from tweepy import Stream&#xA;from tweepy.streaming import StreamListener&#xA;from datetime import datetime&#xA;import time&#xA;import subprocess&#xA;&#xA;stdout = subprocess.PIPE&#xA;def runcmd(cmd):&#xA;    x = subprocess.Popen(cmd, stdout=subprocess.PIPE)&#xA;    return x.communicate(stdout)&#xA;&#xA;print(" TWITTER BOT")&#xA;time.sleep(1.5)&#xA;print(" By PigeonBurger, updated 26 August 2020 \n")&#xA;&#xA;import json&#xA;import random&#xA;&#xA;class StdOutListener(StreamListener):&#xA;    def on_data(self, data):&#xA;        clean_data = json.loads(data)&#xA;        tweetId = clean_data[&#x27;id&#x27;]&#xA;        tweet_name = clean_data[&#x27;user&#x27;][&#x27;screen_name&#x27;]&#xA;        tweet_media = clean_data[&#x27;entities&#x27;][&#x27;media&#x27;][&#x27;media_url&#x27;]&#xA;        tweet_photo = runcmd(&#x27;ffmpeg -i tweet_media output.jpg&#x27;)&#xA;        print(clean_data)&#xA;        tweet = &#x27;Here ya go&#x27;&#xA;        now = datetime.now()&#xA;        dt_string = now.strftime("%d/%m/%Y %H:%M:%S")&#xA;        print(&#x27; Reply sent to @&#x27;&#x2B;tweet_name, &#x27;on&#x27;, dt_string, &#x27;\n&#x27; &#x27; Message:&#x27;, tweet, &#x27;\n&#x27;)&#xA;        respondToTweet(tweet_photo, tweet, tweetId)&#xA;&#xA;def setUpAuth():&#xA;    auth = tweepy.OAuthHandler("consumer_key", "consumer_secret")&#xA;    auth.set_access_token("access_token", "access_token_secret")&#xA;    api = tweepy.API(auth)&#xA;    return api, auth&#xA;&#xA;def followStream():&#xA;    api, auth = setUpAuth()&#xA;    listener = StdOutListener()&#xA;    stream = Stream(auth, listener)&#xA;    stream.filter(track=["@YOUR_TWITTER_HANDLE"], is_async=True)&#xA;&#xA;def respondToTweet(tweet_photo, tweet, tweetId):&#xA;    api, auth = setUpAuth()&#xA;    api.update_with_media(tweet_photo, tweet, in_reply_to_status_id=tweetId, auto_populate_reply_metadata=True, stall_warnings=True)&#xA;&#xA;if __name__ == "__main__":&#xA;    followStream()&#xA;

    &#xA;