Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

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

Autres articles (79)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

Sur d’autres sites (5244)

  • Discord 24/7 video stream self-bot crashes after a couple hours

    21 juillet 2023, par angelo

    I've implemented this library to make a self-bot that streams videos from a local folder in a loop 24/7 (don't ask me why). I set up an ubuntu vps to run the bot and it works perfectly fine the first 2-3 hours, after that it gets more and more laggy until the server crashes.
pd : It's basically my first time using javascript and stole most of the code from this repo so don't bully me.

    


    Here's the code :

    


    import { Client, TextChannel, CustomStatus, ActivityOptions } from "discord.js-selfbot-v13";
import { command, streamLivestreamVideo, VoiceUdp, setStreamOpts, streamOpts } from "@dank074/discord-video-stream";
import config from "./config.json";
import fs from 'fs';
import path from 'path';

const client = new Client();

client.patchVoiceEvents(); //this is necessary to register event handlers

setStreamOpts(
    config.streamOpts.width,
    config.streamOpts.height,
    config.streamOpts.fps,
    config.streamOpts.bitrateKbps,
    config.streamOpts.hardware_acc
)

const prefix = '$';

const moviesFolder = config.movieFolder || './movies';

const movieFiles = fs.readdirSync(moviesFolder);
let movies = movieFiles.map(file => {
    const fileName = path.parse(file).name;
    // replace space with _
    return { name: fileName.replace(/ /g, ''), path: path.join(moviesFolder, file) };
});
let originalMovList = [...movies];
let movList = movies;
let shouldStop = false;

// print out all movies
console.log(`Available movies:\n${movies.map(m => m.name).join('\n')}`);

const status_idle = () =>  {
    return new CustomStatus()
        .setState('摸鱼进行中')
        .setEmoji('🐟')
}

const status_watch = (name) => {
    return new CustomStatus()
        .setState(`Playing ${name}...`)
        .setEmoji('📽')
}

// ready event
client.on("ready", () => {
    if (client.user) {
        console.log(`--- ${client.user.tag} is ready ---`);
        client.user.setActivity(status_idle() as ActivityOptions)
    }
});

let streamStatus = {
    joined: false,
    joinsucc: false,
    playing: false,
    channelInfo: {
        guildId: '',
        channelId: '',
        cmdChannelId: ''
    },
    starttime: "00:00:00",
    timemark: '',
}

client.on('voiceStateUpdate', (oldState, newState) => {
    // when exit channel
    if (oldState.member?.user.id == client.user?.id) {
        if (oldState.channelId && !newState.channelId) {
            streamStatus.joined = false;
            streamStatus.joinsucc = false;
            streamStatus.playing = false;
            streamStatus.channelInfo = {
                guildId: '',
                channelId: '',
                cmdChannelId: streamStatus.channelInfo.cmdChannelId
            }
            client.user?.setActivity(status_idle() as ActivityOptions)
        }
    }
    // when join channel success
    if (newState.member?.user.id == client.user?.id) {
        if (newState.channelId && !oldState.channelId) {
            streamStatus.joined = true;
            if (newState.guild.id == streamStatus.channelInfo.guildId && newState.channelId == streamStatus.channelInfo.channelId) {
                streamStatus.joinsucc = true;
            }
        }
    }
})

client.on('messageCreate', async (message) => {
    if (message.author.bot) return; // ignore bots
    if (message.author.id == client.user?.id) return; // ignore self
    if (!config.commandChannels.includes(message.channel.id)) return; // ignore non-command channels
    if (!message.content.startsWith(prefix)) return; // ignore non-commands

    const args = message.content.slice(prefix.length).trim().split(/ +/); // split command and arguments
    if (args.length == 0) return;

    const user_cmd = args.shift()!.toLowerCase();

    if (config.commandChannels.includes(message.channel.id)) {
        switch (user_cmd) {
            case 'play':
                playCommand(args, message);
                break;
            case 'stop':
                stopCommand(message);
                break;
            case 'playtime':
                playtimeCommand(message);
                break;
            case 'pause':
                pauseCommand(message);
                break;
            case 'resume':
                resumeCommand(message);
                break;
            case 'list':
                listCommand(message);
                break;
            case 'status':
                statusCommand(message);
                break;
            case 'refresh':
                refreshCommand(message);
                break;
            case 'help':
                helpCommand(message);
                break;
            case 'playall':
                playAllCommand(args, message);
                break;
            case 'stream':
                streamCommand(args, message);
                break;
            case 'shuffle':
                shuffleCommand();
                break;
            case 'skip':
                //skip cmd
                break;
            default:
                message.reply('Invalid command');
        }
    }
});

client.login("TOKEN_HERE");

let lastPrint = "";

async function playAllCommand(args, message) {
    if (streamStatus.joined) {
        message.reply("Already joined");
        return;
    }

    // args = [guildId]/[channelId]
    if (args.length === 0) {
        message.reply("Missing voice channel");
        return;
    }

    // process args
    const [guildId, channelId] = args.shift()!.split("/");
    if (!guildId || !channelId) {
        message.reply("Invalid voice channel");
        return;
    }

    await client.joinVoice(guildId, channelId);
    streamStatus.joined = true;
    streamStatus.playing = false;
    streamStatus.starttime = "00:00:00";
    streamStatus.channelInfo = {
        guildId: guildId,
        channelId: channelId,
        cmdChannelId: message.channel.id,
    };

    const streamUdpConn = await client.createStream();

    streamUdpConn.voiceConnection.setSpeaking(true);
    streamUdpConn.voiceConnection.setVideoStatus(true);

    playAllVideos(streamUdpConn); // Start playing videos

    // Keep the stream open

    streamStatus.joined = false;
    streamStatus.joinsucc = false;
    streamStatus.playing = false;
    lastPrint = "";
    streamStatus.channelInfo = {
        guildId: "",
        channelId: "",
        cmdChannelId: "",
    };
}

async function playAllVideos(udpConn: VoiceUdp) {

    console.log("Started playing video");

    udpConn.voiceConnection.setSpeaking(true);
    udpConn.voiceConnection.setVideoStatus(true);

    try {
        let index = 0;

        while (true) {
            if (shouldStop) {
                break; // For the stop command
            }

            if (index >= movies.length) {
                // Reset the loop
                index = 0;
            }

            const movie = movList[index];

            if (!movie) {
                console.log("Movie not found");
                index++;
                continue;
            }

            let options = {};
            options["-ss"] = "00:00:00";

            console.log(`Playing ${movie.name}...`);

            try {
                let videoStream = streamLivestreamVideo(movie.path, udpConn);
                command?.on('progress', (msg) => {
                    // print timemark if it passed 10 second sionce last print, becareful when it pass 0
                    if (streamStatus.timemark) {
                        if (lastPrint != "") {
                            let last = lastPrint.split(':');
                            let now = msg.timemark.split(':');
                            // turn to seconds
                            let s = parseInt(now[2]) + parseInt(now[1]) * 60 + parseInt(now[0]) * 3600;
                            let l = parseInt(last[2]) + parseInt(last[1]) * 60 + parseInt(last[0]) * 3600;
                            if (s - l >= 10) {
                                console.log(`Timemark: ${msg.timemark}`);
                                lastPrint = msg.timemark;
                            }
                        } else {
                            console.log(`Timemark: ${msg.timemark}`);
                            lastPrint = msg.timemark;
                        }
                    }
                    streamStatus.timemark = msg.timemark;
                });
                const res = await videoStream;
                console.log("Finished playing video " + res);
            } catch (e) {
                console.log(e);
            }

            index++; // Pasar a la siguiente película
        }
    } finally {
        udpConn.voiceConnection.setSpeaking(false);
        udpConn.voiceConnection.setVideoStatus(false);
    }

    command?.kill("SIGINT");
    // send message to channel, not reply
    (client.channels.cache.get(streamStatus.channelInfo.cmdChannelId) as TextChannel).send('Finished playing video, timemark is ' + streamStatus.timemark);
    client.leaveVoice();
    client.user?.setActivity(status_idle() as ActivityOptions)
    streamStatus.joined = false;
    streamStatus.joinsucc = false;
    streamStatus.playing = false;
    lastPrint = ""
    streamStatus.channelInfo = {
        guildId: '',
        channelId: '',
        cmdChannelId: ''
    };
}

function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}

function shuffleCommand() {
    shuffleArray(movList);
}

async function playCommand(args, message) {
    if (streamStatus.joined) {
        message.reply('Already joined');
        return;
    }

    // args = [guildId]/[channelId]
    if (args.length == 0) {
        message.reply('Missing voice channel');
        return;
    }

    // process args
    const [guildId, channelId] = args.shift()!.split('/');
    if (!guildId || !channelId) {
        message.reply('Invalid voice channel');
        return;
    }

    // get movie name and find movie file
    let moviename = args.shift()
    let movie = movies.find(m => m.name == moviename);

    if (!movie) {
        message.reply('Movie not found');
        return;
    }

    // get start time from args "hh:mm:ss"
    let startTime = args.shift();
    let options = {}
    // check if start time is valid
    if (startTime) {
        let time = startTime.split(':');
        if (time.length != 3) {
            message.reply('Invalid start time');
            return;
        }
        let h = parseInt(time[0]);
        let m = parseInt(time[1]);
        let s = parseInt(time[2]);
        if (isNaN(h) || isNaN(m) || isNaN(s)) {
            message.reply('Invalid start time');
            return;
        }
        startTime = `${h}:${m}:${s}`;
        options['-ss'] = startTime;
        console.log("Start time: " + startTime);
    }

    await client.joinVoice(guildId, channelId);
    streamStatus.joined = true;
    streamStatus.playing = false;
    streamStatus.starttime = startTime ? startTime : "00:00:00";
    streamStatus.channelInfo = {
        guildId: guildId,
        channelId: channelId,
        cmdChannelId: message.channel.id
    }
    const streamUdpConn = await client.createStream();
    playVideo(movie.path, streamUdpConn, options);
    message.reply('Playing ' + (startTime ? ` from ${startTime} ` : '') + moviename + '...');
    client.user?.setActivity(status_watch(moviename) as ActivityOptions);
}

function stopCommand(message) {
    client.leaveVoice()
    streamStatus.joined = false;
    streamStatus.joinsucc = false;
    streamStatus.playing = false;
    streamStatus.channelInfo = {
        guildId: '',
        channelId: '',
        cmdChannelId: streamStatus.channelInfo.cmdChannelId
    }
    // use sigquit??
    command?.kill("SIGINT");
    // msg
    message.reply('Stopped playing');
    shouldStop = true;
    movList = [...originalMovList];
}

function playtimeCommand(message) {
    // streamStatus.starttime + streamStatus.timemark
    // starttime is hh:mm:ss, timemark is hh:mm:ss.000
    let start = streamStatus.starttime.split(':');
    let mark = streamStatus.timemark.split(':');
    let h = parseInt(start[0]) + parseInt(mark[0]);
    let m = parseInt(start[1]) + parseInt(mark[1]);
    let s = parseInt(start[2]) + parseInt(mark[2]);
    if (s >= 60) {
        m += 1;
        s -= 60;
    }
    if (m >= 60) {
        h += 1;
        m -= 60;
    }
    message.reply(`Play time: ${h}:${m}:${s}`);
}

function pauseCommand(message) {
    if (!streamStatus.playing) {
        command?.kill("SIGSTOP");
        message.reply('Paused');
        streamStatus.playing = false;
    } else {
        message.reply('Not playing');
    }
}

function resumeCommand(message) {
    if (!streamStatus.playing) {
        command?.kill("SIGCONT");
        message.reply('Resumed');
        streamStatus.playing = true;
    } else {
        message.reply('Not playing');
    }
}

function listCommand(message) {
    message.reply(`Available movies:\n${movies.map(m => m.name).join('\n')}`);
}

function statusCommand(message) {
    message.reply(`Joined: ${streamStatus.joined}\nJoin success: ${streamStatus.joinsucc}\nPlaying: ${streamStatus.playing}\nChannel: ${streamStatus.channelInfo.guildId}/${streamStatus.channelInfo.channelId}\nTimemark: ${streamStatus.timemark}\nStart time: ${streamStatus.starttime}`);
}

function refreshCommand(message) {
    // refresh movie list
    const movieFiles = fs.readdirSync(moviesFolder);
    movies = movieFiles.map(file => {
        const fileName = path.parse(file).name;
        // replace space with _
        return { name: fileName.replace(/ /g, ''), path: path.join(moviesFolder, file) };
    });
    message.reply('Movie list refreshed ' + movies.length + ' movies found.\n' + movies.map(m => m.name).join('\n'));
}

function helpCommand(message) {
    // reply all commands here
    message.reply('Available commands:\nplay [guildId]/[channelId] [movie] [start time]\nstop\nlist\nstatus\nrefresh\nplaytime\npause\nresume\nhelp');
}

async function playVideo(video: string, udpConn: VoiceUdp, options: any) {
    console.log("Started playing video");

    udpConn.voiceConnection.setSpeaking(true);
    udpConn.voiceConnection.setVideoStatus(true);
    try {
        let videoStream = streamLivestreamVideo(video, udpConn);
        command?.on('progress', (msg) => {
            // print timemark if it passed 10 second sionce last print, becareful when it pass 0
            if (streamStatus.timemark) {
                if (lastPrint != "") {
                    let last = lastPrint.split(':');
                    let now = msg.timemark.split(':');
                    // turn to seconds
                    let s = parseInt(now[2]) + parseInt(now[1]) * 60 + parseInt(now[0]) * 3600;
                    let l = parseInt(last[2]) + parseInt(last[1]) * 60 + parseInt(last[0]) * 3600;
                    if (s - l >= 10) {
                        console.log(`Timemark: ${msg.timemark}`);
                        lastPrint = msg.timemark;
                    }
                } else {
                    console.log(`Timemark: ${msg.timemark}`);
                    lastPrint = msg.timemark;
                }
            }
            streamStatus.timemark = msg.timemark;
        });
        const res = await videoStream;
        console.log("Finished playing video " + res);
    } catch (e) {
        console.log(e);
    } finally {
        udpConn.voiceConnection.setSpeaking(false);
        udpConn.voiceConnection.setVideoStatus(false);
    }
    command?.kill("SIGINT");
    // send message to channel, not reply
    (client.channels.cache.get(streamStatus.channelInfo.cmdChannelId) as TextChannel).send('Finished playing video, timemark is ' + streamStatus.timemark);
    client.leaveVoice();
    client.user?.setActivity(status_idle() as ActivityOptions)
    streamStatus.joined = false;
    streamStatus.joinsucc = false;
    streamStatus.playing = false;
    lastPrint = ""
    streamStatus.channelInfo = {
        guildId: '',
        channelId: '',
        cmdChannelId: ''
    }
}

async function streamCommand(args, message) {

    if (streamStatus.joined) {
        message.reply('Already joined');
        return;
    }

    // args = [guildId]/[channelId]
    if (args.length == 0) {
        message.reply('Missing voice channel');
        return;
    }

    // process args
    const [guildId, channelId] = args.shift()!.split('/');
    if (!guildId || !channelId) {
        message.reply('Invalid voice channel');
        return;
    }

    let url = args.shift()
    let options = {}

    await client.joinVoice(guildId, channelId);
    streamStatus.joined = true;
    streamStatus.playing = false;
    //streamStatus.starttime = startTime ? startTime : "00:00:00";
    streamStatus.channelInfo = {
        guildId: guildId,
        channelId: channelId,
        cmdChannelId: message.channel.id
    }
    const streamUdpConn = await client.createStream();
    playStream(url, streamUdpConn, options);
    message.reply('Playing url');
    client.user?.setActivity(status_watch('livestream') as ActivityOptions);
}

async function playStream(video: string, udpConn: VoiceUdp, options: any) {
    console.log("Started playing video");

    udpConn.voiceConnection.setSpeaking(true);
    udpConn.voiceConnection.setVideoStatus(true);

    try {
        console.log("Trying to stream url");
        const res = await streamLivestreamVideo(video, udpConn);
        console.log("Finished streaming url");
    } catch (e) {
        console.log(e);
    } finally {
        udpConn.voiceConnection.setSpeaking(false);
        udpConn.voiceConnection.setVideoStatus(false);
    }

    command?.kill("SIGINT");
    client.leaveVoice();
    client.user?.setActivity(status_idle() as ActivityOptions)
    streamStatus.joined = false;
    streamStatus.joinsucc = false;
    streamStatus.playing = false;
    streamStatus.channelInfo = {
        guildId: '',
        channelId: '',
        cmdChannelId: ''
    }

}

// run server if enabled in config
if (config.server.enabled) {
    // run server.js
    require('./server');
}



    


    I've tried running the code with the nocache package, setting up a cron job to clean the cache every 5 minutes, unifying functions in the code, but nothigns works.
I think that the problem has to do with certain process that never really ends after one video finishes playing, probably ffmpeg. I don't know whether is my code, my vps or the library the problem.

    


    I wanted the bot to stay in the voice channel streaming my videos 24/7 (no interruptions), I don't know how to prevent it from getting laggy after a while.

    


    This is the config.json file just in case you wanna test the code and can't find it

    


    {
    "token": "DCTOKEN",
    "videoChannels": ["ID", "OTHERID"],
    "commandChannels": ["ID", "OTHERID"],
    "adminIds": ["ID"],
    "movieFolder": "./movies/",
    "previewCache": "/tmp/preview-cache",
    "streamOpts": {
        "width": 1280,
        "height": 720,
        "fps": 30,
        "bitrateKbps": 3000,
        "hardware_acc": true
    },
    "server": {
        "enabled": false,
        "port": 8080
    }
}



    


  • What's the most desireable way to capture system display and audio in the form of individual encoded audio and video packets in go (language) ? [closed]

    11 janvier 2023, par Tiger Yang

    Question (read the context below first) :

    


    For those of you familiar with the capabilities of go, Is there a better way to go about all this ? Since ffmpeg is so ubiquitous, I'm sure it's been optomized to perfection, but what's the best way to capture system display and audio in the form of individual encoded audio and video packets in go (language), so that they can be then sent via webtransport-go ? I wish for it to prioritize efficiency and low latency, and ideally capture and encode the framebuffer directly like ffmpeg does.

    


    Thanks ! I have many other questions about this, but I think it's best to ask as I go.

    


    Context and what I've done so far :

    


    I'm writing a remote desktop software for my personal use because of grievances with current solutions out there. At the moment, it consists of a web app that uses the webtransport API to send input datagrams and receive AV packets on two dedicated unidirectional streams, and the webcodecs API to decode these packets. On the serverside, I originally planned to use python with the aioquic library as a webtransport server. Upon connection and authentication, the server would start ffmpeg as a subprocess with this command :

    


    ffmpeg -init_hw_device d3d11va -filter_complex ddagrab=video_size=1920x1080:framerate=60 -vcodec hevc_nvenc -tune ll -preset p7 -spatial_aq 1 -temporal_aq 1 -forced-idr 1 -rc cbr -b:v 400K -no-scenecut 1 -g 216000 -f hevc -

    


    What I really appreciate about this is that it uses windows' desktop duplication API to copy the framebuffer of my GPU and hand that directly to the on-die hardware encoder with zero round trips to the CPU. I think it's about as efficient and elegant a solution as I can manage. It then outputs the encoded stream to the stdout, which python can read and send to the client.

    


    As for the audio, there is another ffmpeg instance :

    


    ffmpeg -f dshow -channels 2 -sample_rate 48000 -sample_size 16 -audio_buffer_size 15 -i audio="RD Audio (High Definition Audio Device)" -acodec libopus -vbr on -application audio -mapping_family 0 -apply_phase_inv true -b:a 25K -fec false -packet_loss 0 -map 0 -f data -

    


    which listens to a physical loopback interface, which is literally just a short wire bridging the front panel headphone and microphone jacks (I'm aware of the quality loss of converting to analog and back, but the audio is then crushed down to 25kbps so it's fine) ()

    


    Unfortunately, aioquic was not easy to work with IMO, and I found webtransport-go https://github.com/adriancable/webtransport-go, which was a hell of a lot better in both simplicity and documentation. However, now I'm dealing with a whole new language, and I wanna ask : (above)

    


    EDIT : Here's the code for my server so far :

    


    

    

    package main

import (
    "bytes"
    "context"
    "fmt"
    "log"
    "net/http"
    "os/exec"
    "time"

    "github.com/adriancable/webtransport-go"
)

func warn(str string) {
    fmt.Printf("\n===== WARNING ===================================================================================================\n   %s\n=================================================================================================================\n", str)
}

func main() {

    password := []byte("abc")

    videoString := []string{
        "ffmpeg",
        "-init_hw_device", "d3d11va",
        "-filter_complex", "ddagrab=video_size=1920x1080:framerate=60",
        "-vcodec", "hevc_nvenc",
        "-tune", "ll",
        "-preset", "p7",
        "-spatial_aq", "1",
        "-temporal_aq", "1",
        "-forced-idr", "1",
        "-rc", "cbr",
        "-b:v", "500K",
        "-no-scenecut", "1",
        "-g", "216000",
        "-f", "hevc", "-",
    }

    audioString := []string{
        "ffmpeg",
        "-f", "dshow",
        "-channels", "2",
        "-sample_rate", "48000",
        "-sample_size", "16",
        "-audio_buffer_size", "15",
        "-i", "audio=RD Audio (High Definition Audio Device)",
        "-acodec", "libopus",
        "-mapping_family", "0",
        "-b:a", "25K",
        "-map", "0",
        "-f", "data", "-",
    }

    connected := false

    http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
        session := request.Body.(*webtransport.Session)

        session.AcceptSession()
        fmt.Println("\nAccepted incoming WebTransport connection.")
        fmt.Println("Awaiting authentication...")

        authData, err := session.ReceiveMessage(session.Context()) // Waits here till first datagram
        if err != nil {                                            // if client closes connection before sending anything
            fmt.Println("\nConnection closed:", err)
            return
        }

        if len(authData) >= 2 && bytes.Equal(authData[2:], password) {
            if connected {
                session.CloseSession()
                warn("Client has authenticated, but a session is already taking place! Connection closed.")
                return
            } else {
                connected = true
                fmt.Println("Client has authenticated!\n")
            }
        } else {
            session.CloseSession()
            warn("Client has failed authentication! Connection closed. (" + string(authData[2:]) + ")")
            return
        }

        videoStream, _ := session.OpenUniStreamSync(session.Context())

        videoCmd := exec.Command(videoString[0], videoString[1:]...)
        go func() {
            videoOut, _ := videoCmd.StdoutPipe()
            videoCmd.Start()

            buffer := make([]byte, 15000)
            for {
                len, err := videoOut.Read(buffer)
                if err != nil {
                    break
                }
                if len > 0 {
                    videoStream.Write(buffer[:len])
                }
            }
        }()

        time.Sleep(50 * time.Millisecond)

        audioStream, err := session.OpenUniStreamSync(session.Context())

        audioCmd := exec.Command(audioString[0], audioString[1:]...)
        go func() {
            audioOut, _ := audioCmd.StdoutPipe()
            audioCmd.Start()

            buffer := make([]byte, 15000)
            for {
                len, err := audioOut.Read(buffer)
                if err != nil {
                    break
                }
                if len > 0 {
                    audioStream.Write(buffer[:len])
                }
            }
        }()

        for {
            data, err := session.ReceiveMessage(session.Context())
            if err != nil {
                videoCmd.Process.Kill()
                audioCmd.Process.Kill()

                connected = false

                fmt.Println("\nConnection closed:", err)
                break
            }

            if len(data) == 0 {

            } else if data[0] == byte(0) {
                fmt.Printf("Received mouse datagram: %s\n", data)
            }
        }

    })

    server := &webtransport.Server{
        ListenAddr: ":1024",
        TLSCert:    webtransport.CertFile{Path: "SSL/fullchain.pem"},
        TLSKey:     webtransport.CertFile{Path: "SSL/privkey.pem"},
        QuicConfig: &webtransport.QuicConfig{
            KeepAlive:      false,
            MaxIdleTimeout: 3 * time.Second,
        },
    }

    fmt.Println("Launching WebTransport server at", server.ListenAddr)
    ctx, cancel := context.WithCancel(context.Background())
    if err := server.Run(ctx); err != nil {
        log.Fatal(err)
        cancel()
    }

}

    


    


    



  • Set path while installing [duplicate]

    12 janvier 2021, par Education 4Fun

    My requirement is to set a path(C :/ffmpeg) while installing the software itself for my application(which I made)
    
A reference that it's possible(While installing python 3.8.0 we have check box by ticking it we can add the path of python automatically)
    
This is the main requirement which I wanna do with my application

    


    enter image description here

    


    About My application :
    
My application is a simple video editing application that runs on cmd as it uses FFmpeg its path should be set only then the application will work
The application is coded in python and the GUI is made using pyqt5 The application runs on cmd like the commands and all here is a reference image for observation enter image description here

    


    enter image description here

    


    So it's mandatory to add the path else FFmpeg will not recognize. If there is any way to do in building setup like how python can add the path as per user requirement refer to the image (1st image)

    


    About Files in C :/ffmpeg
Files in FFmpeg folder refer to image for that info

    


    enter image description here

    


    Hope the query is a bit clear.
Thanks a lot