Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (95)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

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

  • Revision 37337 : Pas besoin du title qui reprends le titre Une erreur sur un label

    16 avril 2010, par kent1@… — Log

    Pas besoin du title qui reprends le titre
    Une erreur sur un label

  • Merging multiple audios to a video with ffmpeg causes the volume being reduced. How to avoid that ?

    25 janvier 2024, par Terry Windwalker
            const command = ffmpeg();

        const mp4Path = path.join(__dirname, '..', '..', 'temp', `q-video-${new Date().getTime()}.mp4`);

        fs.writeFileSync(mp4Path, videoBuff);
        console.log('mp4 file created at: ', mp4Path);

        // Set the video stream as the input for ffmpeg
        command.input(mp4Path);

        const mp3Paths = [];

        for (let i = 0; i < audios.length; i++) {
            const audio = audios[i];
            const mp3Path = path.join(__dirname, '..', '..', 'temp', `q-audio-${new Date().getTime()}-${i}.mp3`);
            mp3Paths.push(mp3Path);

            fs.writeFileSync(mp3Path, audio.questionBuf);
            console.log('mp3 file created at: ', mp3Path);
            // Set the audio stream as the input for ffmpeg
            command.input(mp3Path);
        }

        // -------
        // ChatGPT take 1
        const audioTags = [];
        const audioFilters = audios.map((audio, index) => {
            const startTime = audio.start_at; // Replace with your logic to calculate start time
            const endTime = audio.end_at;     // Replace with your logic to calculate end time
            audioTags.push(`[delayed${index}]`);
            // Working
            // return `[${index + 1}:a]atrim=start=0:end=${(endTime - startTime) / 1000},adelay=${startTime}[delayed${index}]`;
            return `[${index + 1}:a]dynaudnorm=p=0.9:m=100:s=5,atrim=start=0:end=${(endTime - startTime) / 1000},adelay=${startTime}[delayed${index}]`;
        });
        
        // Concatenate the delayed audio streams
        const concatFilter = audioFilters.join(';');
        
        // Mix the concatenated audio streams
        const mixFilter = `${concatFilter};[0:a]${audioTags.join('')}amix=inputs=${audios.length + 1}:duration=first:dropout_transition=2[out]`;

        // Set the complex filter for ffmpeg
        command.complexFilter([mixFilter]);

        // Set the output size
        if (!isScreen) {
            command.videoFilter('scale=720:-1');
        }
        else {
            command.videoFilter('scale=1920:-1');
        }

        // Set input options
        command.inputOptions([
            '-analyzeduration 20M',
            '-probesize 100M'
        ]);

        // Set output options
        command.outputOptions([
            '-c:v libx264', // Specify a video codec
            '-c:a aac',
            '-map 0:v',      // Map the video stream from the first input
            '-map [out]'     // Map the audio stream from the complex filter
        ]);

        // Set the output format
        command.toFormat('mp4');

        // Set the output file path
        command.output(outputFilePath);

        // Event handling
        command
            .on('start', commandLine => {
                console.log('Spawned Ffmpeg with command: ' + commandLine);
            })
            .on('codecData', data => {
                console.log('Input is ' + data.audio + ' audio ' +
                'with ' + data.video + ' video');
            })
            .on('progress', progress => {
                // console.log('progress: ', progress);
                console.log(`Processing: ${
                    progress.percent ?
                    progress.percent.toFixed(2)
                    :
                    '0.00'
                }% done`);
            })
            .on('stderr', stderrLine => {
                console.log('Stderr output: ' + stderrLine);
            })
            .on('error', (err, stdout, stderr) => {
                console.error('Error merging streams:', err);
                console.error('ffmpeg stdout:', stdout);
                console.error('ffmpeg stderr:', stderr);
                reject(err);
            })
            .on('end', () => {
                console.log('Merging finished successfully.');
                const file = fs.readFileSync(outputFilePath);
                console.log('File read successfully.');
                setTimeout(() => {
                    fs.unlinkSync(outputFilePath);
                    console.log('Output file deleted successfully.');
                    fs.unlinkSync(mp4Path);
                    console.log('MP4 file deleted successfully.');
                    console.log('mp3Paths: ', mp3Paths);
                    for (let mp3Path of mp3Paths) {
                        fs.unlinkSync(mp3Path);
                    }
                    console.log('MP3 file deleted successfully.');
                    if (isScreen) {
                        for (let path of pathsScreen) {
                            fs.unlinkSync(path);
                        }
                    }
                    else {
                        for (let path of pathsCamera) {
                            fs.unlinkSync(path);
                        }
                    }
                    console.log('All temp files deleted successfully.');
                }, 3000);
                resolve(file);
            });
        
        // Run the command
        command.run();


    


    This is how I am merging my video files (which is an array of webm files) right now. It seems this command is causing the volume of the video gradually increase from the beginning to the end (the earlier part of the video has much lower volume than later part of the video). How should I fix this ?

    


    Things tried and investigated so far :

    


      

    • I have checked the original video, it does not have the volume issue. So the volume issue was caused by this piece of code without an doubt.
    • 


    • I have tried dynaudnorm, not fully understanding how it works, though. Adding it to each of the audio file does not fix this issue, and adding it as a separated filter at the end of the combined filter string would break the session.
    • 


    


  • Everytime I run my code ffmpeg responds with this instead of doing its function. How do I fix ?

    25 juillet 2023, par Oreo F
    Output from ffmpeg/avlib:

ffmpeg version 2023-07-19-git-efa6cec759-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 14.100 / 58. 14.100
  libavcodec     60. 22.100 / 60. 22.100
  libavformat    60. 10.100 / 60. 10.100
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9.  8.102 /  9.  8.102
  libswscale      7.  3.100 /  7.  3.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100


    


    Everytime I run the code it does this.

    


    code :

    


    import praw
import requests
import cv2
import os
from pydub import AudioSegment

def download_video(url, filename):
    response = requests.get(url)
    with open(filename, 'wb') as f:
        f.write(response.content)

def combine_videos(video_urls, output_filename):
    video_clips = []
    audio_clips = []
    for i, url in enumerate(video_urls):
        temp_filename = f'temp_video_{i}.mp4'
        download_video(url, temp_filename)
        video_clip = cv2.VideoCapture(temp_filename)
        audio_clip = AudioSegment.from_file(temp_filename, format="mp4")
        video_clips.append(video_clip)
        audio_clips.append(audio_clip)
    
    if not video_clips:
        print("No video clips to combine.")
        return

    frame_width = int(video_clips[0].get(cv2.CAP_PROP_FRAME_WIDTH))
    frame_height = int(video_clips[0].get(cv2.CAP_PROP_FRAME_HEIGHT))
    fps = int(video_clips[0].get(cv2.CAP_PROP_FPS))

    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    output_clip = cv2.VideoWriter(output_filename, fourcc, fps, (frame_width, frame_height))

    for i, video_clip in enumerate(video_clips):
        while True:
            ret, frame = video_clip.read()
            if not ret:
                break
            output_clip.write(frame)
    
    for video_clip in video_clips:
        video_clip.release()
    
    output_clip.release()

    # Combining audio using pydub
    combined_audio = sum(audio_clips)
    combined_audio.export("combined_audio.mp3", format="mp3")

    # Merging audio with video using ffmpeg
    os.system(f'ffmpeg -i {output_filename} -i combined_audio.mp3 -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 final_output.mp4')

    # Cleaning up temporary files
    os.remove("combined_audio.mp3")

def main():
    reddit = praw.Reddit(
       client_id='XXX',
        client_secret='XXX',
        user_agent='Reddit Video Downloader'
    )
    
    subreddit_name = input("Enter the name of the subreddit: ")
    limit = int(input("Enter the number of videos to download: "))
    
    subreddit = reddit.subreddit(subreddit_name)
    submissions = subreddit.hot(limit=limit)
    
    video_urls = [submission.url for submission in submissions if submission.media and 'reddit_video' in submission.media]
    
    if video_urls:
        output_filename = input("Enter the output filename (e.g., output.mp4): ")
        combine_videos(video_urls, output_filename)
        print("Videos combined successfully!")
    else:
        print("No Reddit videos found in the subreddit.")

if __name__ == "__main__":
    main()


    


    Anyone got any idea why this happens ?

    


    I'm making a script that scrapes videos from a specific subreddit.

    


    Also if it helps the temp video file is corrupted when it gets made.

    


    I've put this into chatGPT as well and brought an expert friend and he hasn't been able to help me.