Recherche avancée

Médias (17)

Mot : - Tags -/wired

Autres articles (52)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (10428)

  • OpenCV and GoPro - empty frames in VideoCapture stream

    19 mai 2014, par Novatar

    I have a GoPro Hero 3+ (Black) which is connected to a video capture card (AverMedia Game Broadcaster HD). I simply want to get the video stream in OpenCV. With a Logitech Webcam there are no problems. The used code is below.

    VideoCapture cap;
    cap.open(0);

    waitKey(300);

    //cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
    //cap.set(CV_CAP_PROP_FRAME_HEIGHT, 720);

    if (cap.isOpened()){
       cout << "Cam identified" << endl;
    }

    namedWindow("dst", 1);

    while (1){

    Mat frame;

    if (!cap.read(frame)) {
       std::cout << "Unable to read frame from video stream" << std::endl;
       continue;
    }

    imshow("dst", frame);

    [...]

    }

    With the GoPro the following happens : OpenCV is able to open the VideoCapture ("Cam identified") but can’t read any frames (just a gray screen and the output : "Unable to read frame from video stream"). I also checked this with frame.empty() ;.

    I know that the video capture card works correct because Unity opens a WebCamTexture with the GoPro stream without any issues. I read about codec problems in OpenCv and so I already tried to compile OpenCV with FFMPEG support. Now the recorded MP4-Videos of the GoPro can be displayed but the stream still doesn’t work.

    I use OpenCV 2.48, Windows 7 and Visual Studio 2013.


    EDIT : Here is the code of libVLC solution :

    struct ctx
    {
    uint8_t* pixeldata;
    std::mutex imagemutex;
    };

    static void display(void *data, void *id);
    static void unlock(void *data, void *id, void *const *p_pixels);
    static void *lock(void *data, void **p_pixels);

    struct ctx ctx;

    libvlc_instance_t *inst;
    libvlc_media_player_t *mp;
    libvlc_media_t *m;

    int main(int argc, char* argv[])
    {
       ctx.pixeldata = new uint8_t[1280 * 720 * 3];

       char const *vlc_argv[] =
       {
           "-vvv",
           "--no-audio", /* skip any audio track */
           "--no-xlib", /* tell VLC to not use Xlib */
       };

       int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
       inst = libvlc_new(vlc_argc, vlc_argv);

       const char *options[] =
       {
           ":dshow-vdev=AVerMedia HD Capture",
           ":dshow-adev=none",
           //":dshow-size=1280x720",
           ":dshow-fps=24",
           ":dshow-chroma=YUY2",
           ":dshow-video-input=1",
           ":dshow-video-output=1",
           ":dshow-aspect-ratio=16\:9",
           ":live-caching=80",
           NULL
       };

       m = libvlc_media_new_location(inst, "dshow://");
       for (const char **opt = options; *opt; opt++)
           libvlc_media_add_option(m, *opt);

       mp = libvlc_media_player_new_from_media(m);
       libvlc_media_release(m);
       libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
       libvlc_video_set_format(mp, "RV24", 1280, 720, 1280 * 3);
       libvlc_media_player_play(mp);

       namedWindow("all", 1);

       Mat frame(720, 1280, CV_8UC3);

       while (1){

           ctx.imagemutex.lock();
           memcpy(gesamt.data, ctx.pixeldata, 1280 * 720 * sizeof(uint8_t) * 3);
           ctx.imagemutex.unlock();

           imshow("all", gesamt);

           if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
           {
               cout << "esc key is pressed by user" << endl;
               break;
           }

       }

       libvlc_media_player_stop(mp);
       libvlc_media_player_release(mp);
       libvlc_release(inst);
       delete[] ctx.pixeldata;

       return 0;
    }

    void display(void *data, void *id){
       (void)data;
       assert(id == NULL);
    }

    void unlock(void *data, void *id, void *const *p_pixels){
       struct ctx *ctx = (struct ctx*)data;
       ctx->imagemutex.unlock();
       assert(id == NULL);
    }

    void *lock(void *data, void **p_pixels){
       struct ctx *ctx = (struct ctx*)data;
       ctx->imagemutex.lock();
       *p_pixels = ctx->pixeldata;
       return NULL;
    }
  • Python and ffmpeg audio sync and screen recording issues

    9 août 2020, par odddollar

    I'm using ffmpeg and python to record my desktop screen. When the program is run, it starts recording, then when I press a key-combo it cuts off the last x amount of seconds and saves it then starts recording again ; similar to the "record that" functionality of windows game bar.

    


    I have it working so it records video just fine, but then I change the ffmpeg command to record audio from my desktop and I get an error saying ValueError: could not convert string to float: 'N/A' occurring when I try to calculate the length of the recorded video. It appears as though the recording isn't being stopped until after I try to calculate the video length, even though this exact same code works fine when not recording audio.

    


    Additionally, I also have an issue when recording audio in that the audio is a couple hundred milliseconds in front of the video. It's not a lot but it's enough to be noticeable.

    


    What I'm overall asking, is there a way I can modify the ffmpeg command to prevent the audio desync issues, and what might be causing the problems I'm getting when attempting to find the length of the video with audio ?

    


    import keyboard, signal
from os import remove
from os.path import isfile
from subprocess import Popen, getoutput
from datetime import datetime
import configparser

class Main:
    def __init__(self, save_location, framerate, duration):
        self.save_location = save_location
        self.framerate = int(framerate)
        self.duration = int(duration)
        self.working = self.save_location + '\\' + 'working.avi'
        self.start_recording()

    def start_recording(self):
        if isfile(self.working):
            remove(self.working)

        # start recording to working file at set framerate
        self.process = Popen(f'ffmpeg -thread_queue_size 578 -f gdigrab -video_size 1920x1080 -i desktop -f dshow -i audio="Stereo Mix (Realtek High Definition Audio)" -b:v 7M -minrate 4M -framerate {self.framerate} {self.working}')
        #self.process = Popen(f'ffmpeg -f gdigrab -framerate {self.framerate} -video_size 1920x1080 -i desktop -b:v 7M -minrate 2M {self.working}')

    def trim_video(self):
        # stop recording working file
        self.process.send_signal(signal.CTRL_C_EVENT)

        # call 'cause I have to
        getoutput(f"ffprobe -i {self.working}")

        # get length of working video
        length = getoutput(f'ffprobe -i {self.working} -show_entries format=duration -v quiet -of csv="p=0"')

        # get time before desired recording time
        start = float(length) - self.duration

        # get save location and title
        title = self.save_location+'\\'+self.get_time()+'.avi'

        # cut to last amount of desired time
        Popen(f"ffmpeg -ss {start} -i {self.working} -c copy -t {self.duration} {title}")
        getoutput(f"ffprobe -i {self.working}")

        self.start_recording()

    def get_time(self):
        now = datetime.now()
        return now.strftime("%Y_%m_%d#%H-%M-%S")


if __name__ == "__main__":
    config = configparser.ConfigParser()
    config.read("settings.ini")
    config = config["DEFAULT"]

    run = Main(config["savelocation"].replace("\\", "\\\\"), config["framerate"], config["recordlast"])
    keyboard.add_hotkey("ctrl+shift+alt+g", lambda:run.trim_video())

    while True:
        try:
            keyboard.wait()
        except KeyboardInterrupt:
            pass


    


    The contents of the settings.ini file are listed below

    


    [DEFAULT]
savelocation = C:\
framerate = 30
recordlast = 10


    


    In the code block, the first line with self.process = Popen is the one that records audio and has the issues, the second line (the commented out one below) is the one that works fine.

    


  • FFMPEG Screen Flashing Green

    18 novembre 2022, par Devin Dixon

    I have this problem where my ffmpeg videos are flicking green. Example of the video is here :
https://www.glitch.fun/streams/31fea7e0-7523-4365-9780-31deee9e472c/watchrecording/efb841c0-4b87-4482-b165-990880a66f63

    


    My ffmpeg command is this :

    


    /usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -y -v info -f x11grab -draw_mouse 0 -r 60 -s 1920x1080 -thread_queue_size 14000 -i :0.0+0,0 -f alsa -thread_queue_size 14000 -i plug:bsnoop -acodec aac -strict -2 -ar 44100 -b:a 128k -af aresample=async=1 -c:v h264_vaapi -vf format=nv12|vaapi,hwupload -preset medium -maxrate 14000k -bufsize 14000k -pix_fmt yuv420p -r 60 -crf 25 -g 120 -tune zerolatency -f flv rtmp://ingest.bingewave.com/live/[output_to_livestream] -pix_fmt yuv420p -r 60 -b:v 15000k -maxrate 15000k -bufsize 15000k -c:v h264_vaapi -vf format=nv12|vaapi,hwupload -preset medium -keyint_min 24 -level 3.0 -g 120 -tune zerolatency -f flv rtmp://127.0.0.1:1935/live/[output_to_recording]


    


    The reason why my fps and bitrate is so high and preset is so medium is because Glitch is an open source esports platform, and those kinds of settings are required for streaming of game graphics
The command has two outputs :

    


      

    • rtmp ://[output_to_livestream] goes to a livestream where users watch live
    • 


    • rtmp ://127.0.0.1:1935/live/[output to recording] goes a goes to a file
    • 


    


    And the output to the recording is captured by nginx and saved to a file as such :

    


    rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            #Set this to "record off" if you don't want to save a copy of your broadcasts
            record all;
            # The directory in which the recordings will be stored.
            record_path /var/www/html/recordings;
            record_unique on;
            record_suffix -%d-%b-%y-%T.flv;
            on_record_done http://127.0.0.1:3000/recorded;
            # Turn on HLS
            exec /usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -i rtmp://127.0.0.1:1935/live/$name -c:v copy -c:a copy -f flv rtmp://127.0.0.1/show/$name;
        }

        application show {
            live on;
            # Turn on HLS
            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
            # disable consuming the stream from nginx as rtmp
            deny play all;
        }
    }
}


    


    So the part that goes to the live is fine, no green flickering at all. But the part that goes to the recording is one that goes the above issue :

    


    -pix_fmt yuv420p -r 60 -b:v 15000k -maxrate 15000k -bufsize 15000k -c:v h264_vaapi -vf format=nv12|vaapi,hwupload -preset medium -keyint_min 24 -level 3.0 -g 120 -tune zerolatency -f flv rtmp://127.0.0.1:1935/live/[output_to_recording]


    


    I
s there something I need to be changing here ?