Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

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

Autres articles (32)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

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

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (5795)

  • generate mpeg dash segments in specific directory using FFMPEG

    30 novembre 2023, par hegazy

    I need to generate mpeg dash mpd file and m4s chunks files for streaming which is working perfectly.

    


    The issue is the segments parts (.m4s files) generated in the app directory (ignoring the output .mpd file location) which restricted by the server, and any generated file should be generated only in specific location.

    


    so is there a way to specify the segments location using ffmpeg ?

    


  • How to use ffmpeg to open 2 cams and push the stream from one of them ?

    23 septembre 2024, par kkk123

    I'm using ffmpeg to capture 2 cams and push stream from one of them.

    


    For single camera, I start capturing frames by calling startCameraCapture() from main() which calls initRemoteStream(). Here it opens a pipe to ffmpeg to initialize streaming. Followed by it, decodePacket() is called which writes YUV422 data to the pipe. It runs fine.

    


    But when I want to use 2 cameras, I create a thread for each camera in main() and define active_cam. When I want to push cam1's stream, active_cam = 1. The same logic of the single cam is used. It doesn't work.

    


    Could you please help to understand the logic ? Following is my C++ code. Thanks.

    


    #include <iostream>&#xA;#include <thread>&#xA;#include <atomic>&#xA;#include <mutex>&#xA;#include &#xA;#include <queue>&#xA;#include <opencv2></opencv2>opencv.hpp>&#xA;&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavdevice></libavdevice>avdevice.h>&#xA;}&#xA;&#xA;// 定义全局变量&#xA;std::queue frame_queue1, frame_queue2;&#xA;std::mutex queue_mutex1, queue_mutex2;&#xA;std::condition_variable cv1, cv2;&#xA;std::atomic<bool> keep_running(true);&#xA;FILE* pipe_s1 = nullptr;&#xA;FILE* pipe_s2 = nullptr;&#xA;&#xA;// 初始化推流&#xA;FILE* initRemoteStream(int camera_id) {&#xA;    std::string ffmpegCmd = "ffmpeg -y -f rawvideo -vcodec rawvideo -pix_fmt yuv422 -s 1920x1080 -r 30 -i - -vf scale 1280x720 -c:v libx264 -f rtsp rtsp://192.168.66.126/live/stream" &#x2B; std::to_string(camera_id);&#xA;    FILE* pipe_s = popen(ffmpegCmd.c_str(), "w");&#xA;    if (!pipe_s) {&#xA;        std::cerr &lt;&lt; "无法启动 FFmpeg 进程" &lt;&lt; std::endl;&#xA;        return nullptr;&#xA;    }&#xA;    return pipe_s;&#xA;}&#xA;&#xA;// 解码数据包&#xA;bool decodePacket(AVCodecContext *codec_ctx, AVPacket *packet, int video_stream_index, cv::Mat&amp; global_frame, std::queue&amp; frame_queue, std::condition_variable&amp; cv) {&#xA;    AVFrame *frame = av_frame_alloc();&#xA;    int ret;&#xA;&#xA;    if (packet->stream_index == video_stream_index) {&#xA;        ret = avcodec_send_packet(codec_ctx, packet);&#xA;        if (ret &lt; 0) return false;&#xA;&#xA;        ret = avcodec_receive_frame(codec_ctx, frame);&#xA;        if (ret &lt; 0) return false;&#xA;&#xA;        int width = codec_ctx->width;&#xA;        int height = codec_ctx->height;&#xA;&#xA;        // 创建 YUV422 格式的 Mat 对象&#xA;        cv::Mat yuv422_img(height, width, CV_8UC2, frame->data[0]);&#xA;&#xA;        // 将 YUV422 转换为 BGR&#xA;        //cv::cvtColor(yuv422_img, global_frame, cv::COLOR_YUV2BGR_YUY2);&#xA;        &#xA;        {&#xA;            std::lock_guard lock(queue_mutex1);&#xA;            frame_queue.push(global_frame.clone());&#xA;            cv.notify_one();&#xA;        }&#xA;    }&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    return true;&#xA;}&#xA;&#xA;&#xA;// 摄像头捕获线程&#xA;void startCameraCapture(const char* device_name, int camera_id) {&#xA;    AVFormatContext *format_ctx = nullptr;&#xA;    AVCodecContext *codec_ctx = nullptr;&#xA;    const AVCodec *codec = nullptr;&#xA;    AVPacket packet;&#xA;    int video_stream_index = -1;&#xA;&#xA;    avdevice_register_all();&#xA;    avformat_network_init();&#xA;&#xA;    AVDictionary *options = nullptr;&#xA;    av_dict_set(&amp;options, "video_size", "640x480", 0);&#xA;    av_dict_set(&amp;options, "framerate", "30", 0);&#xA;    AVInputFormat *input_format = av_find_input_format("v4l2");&#xA;&#xA;    if (avformat_open_input(&amp;format_ctx, device_name, input_format, &amp;options) != 0) {&#xA;        std::cerr &lt;&lt; "无法打开输入" &lt;&lt; std::endl;&#xA;        return;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(format_ctx, nullptr) &lt; 0) return;&#xA;&#xA;    for (unsigned int i = 0; i &lt; format_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            video_stream_index = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    AVCodecParameters *codec_par = format_ctx->streams[video_stream_index]->codecpar;&#xA;    codec = avcodec_find_decoder(codec_par->codec_id);&#xA;    codec_ctx = avcodec_alloc_context3(codec);&#xA;    avcodec_parameters_to_context(codec_ctx, codec_par);&#xA;    avcodec_open2(codec_ctx, codec, nullptr);&#xA;&#xA;    // 初始化推流&#xA;    FILE* pipe_s = initRemoteStream(camera_id);&#xA;    if (camera_id == 1) {&#xA;        pipe_s1 = pipe_s;&#xA;    } else {&#xA;        pipe_s2 = pipe_s;&#xA;    }&#xA;&#xA;    while (keep_running) {&#xA;        if (av_read_frame(format_ctx, &amp;packet) >= 0) {&#xA;            cv::Mat global_frame;&#xA;            if (decodePacket(codec_ctx, &amp;packet, video_stream_index, global_frame, (camera_id == 1 ? frame_queue1 : frame_queue2), (camera_id == 1 ? cv1 : cv2))) {&#xA;                av_packet_unref(&amp;packet);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_close_input(&amp;format_ctx);&#xA;    pclose(pipe_s);&#xA;}&#xA;&#xA;// 推理线程&#xA;void inferenceThread() {&#xA;    while (keep_running) {&#xA;        cv::Mat frame1, frame2;&#xA;&#xA;        {&#xA;            std::unique_lock lock(queue_mutex1);&#xA;            cv1.wait(lock, [] { return !frame_queue1.empty(); });&#xA;            frame1 = frame_queue1.front();&#xA;            frame_queue1.pop();&#xA;        }&#xA;&#xA;        {&#xA;            std::unique_lock lock(queue_mutex2);&#xA;            cv2.wait(lock, [] { return !frame_queue2.empty(); });&#xA;            frame2 = frame_queue2.front();&#xA;            frame_queue2.pop();&#xA;        }&#xA;&#xA;        // 进行推理处理 &#xA;&#xA;        // 根据CAN信号决定推流&#xA;        int selected_camera_id = 1; // 假设根据CAN信号确定的摄像头ID&#xA;        FILE* selected_pipe_s = (selected_camera_id == 1) ? pipe_s1 : pipe_s2; // 选择相应的推流管道&#xA;&#xA;        if (selected_pipe_s) {&#xA;            fwrite(selected_camera_id == 1 ? frame1.data : frame2.data, 1, (selected_camera_id == 1 ? frame1.total() : frame2.total()) * frame1.elemSize(), selected_pipe_s);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;int main(int argc, char *argv[]) {&#xA;    std::thread camera1(startCameraCapture, "/dev/video0", 1);&#xA;    std::thread camera2(startCameraCapture, "/dev/video1", 2);&#xA;    std::thread infer_thread(inferenceThread);&#xA;&#xA;    camera1.join();&#xA;    camera2.join();&#xA;    infer_thread.join();&#xA;&#xA;    // 释放资源&#xA;    if (pipe_s1) pclose(pipe_s1);&#xA;    if (pipe_s2) pclose(pipe_s2);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;</bool></queue></mutex></atomic></thread></iostream>

    &#xA;

  • python : can't open file 'F :\\Episode Split\\Episode' : [Errno 2] No such file or directory [closed]

    26 février 2024, par Rafa Segovia

    everyone !

    &#xA;

    I'm trying to write a python script to split a video into parts based on a list of expressions from a docx file, comparing them to the dialogue on an srt file.&#xA;I think I have everything installed on my Windows 10 pc.&#xA;I keep getting this error.

    &#xA;

    python : can't open file 'F :\Episode Split\Episode' : [Errno 2] No such file or directory

    &#xA;

    It's like it detects a space somewhere and stops reading a path.&#xA;There's no file called "Episode" anywhere mentioned on the script.&#xA;Can you take a look at the script and pinpoint how I can fix this error ?

    &#xA;

    Thank you

    &#xA;

    import os&#xA;import re&#xA;import cv2&#xA;import unicodedata&#xA;import chardet&#xA;from fuzzywuzzy import fuzz&#xA;import docx&#xA;from bs4 import BeautifulSoup&#xA;import xml.etree.ElementTree as ET&#xA;&#xA;# Define variables&#xA;expressions_per_cut = 4&#xA;max_time_per_cut_seconds = 20&#xA;fuzzy_ratio = 60&#xA;input_parent_folder = r&#x27;F:\Episode Split&#x27;&#xA;xml_output_folder = r&#x27;F:\Episode Split&#x27;&#xA;&#xA;

    &#xA;

    I tried removing spaces in the paths by using hyphens among other things.

    &#xA;