Recherche avancée

Médias (0)

Mot : - Tags -/optimisation

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

Autres articles (45)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (5170)

  • Getting Error while trying to download youtube video by using python

    23 octobre 2024, par Aditya Kumar

    Code

    


    I'm working on a script that allows users to manually select and download separate video and audio streams from YouTube using yt-dlp. The script lists the available video and audio formats, lets the user choose their desired formats, and then merges them using FFmpeg.

    


    Here’s the complete code :

    


    import yt_dlp
import os
import subprocess

# Function to list and allow manual selection of video and audio formats
def download_and_merge_video_audio_with_selection(url, download_path):
    try:
        # Ensure the download path exists
        if not os.path.exists(download_path):
            os.makedirs(download_path)

        # Get available formats from yt-dlp
        ydl_opts = {'listformats': True}

        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            info_dict = ydl.extract_info(url, download=False)
            formats = info_dict.get('formats', [])

        # List available video formats (video only)
        print("\nAvailable video formats:")
        video_formats = [f for f in formats if f.get('vcodec') != 'none' and f.get('acodec') == 'none']
        for idx, f in enumerate(video_formats):
            resolution = f.get('height', 'unknown')
            filesize = f.get('filesize', 'unknown')
            print(f"{idx}: Format code: {f['format_id']}, Resolution: {resolution}p, Size: {filesize} bytes")

        # Let user select the desired video format
        video_idx = int(input("\nEnter the number corresponding to the video format you want to download: "))
        video_format_code = video_formats[video_idx]['format_id']

        # List available audio formats (audio only)
        print("\nAvailable audio formats:")
        audio_formats = [f for f in formats if f.get('acodec') != 'none' and f.get('vcodec') == 'none']
        for idx, f in enumerate(audio_formats):
            abr = f.get('abr', 'unknown')  # Audio bitrate
            filesize = f.get('filesize', 'unknown')
            print(f"{idx}: Format code: {f['format_id']}, Audio Bitrate: {abr} kbps, Size: {filesize} bytes")

        # Let user select the desired audio format
        audio_idx = int(input("\nEnter the number corresponding to the audio format you want to download: "))
        audio_format_code = audio_formats[audio_idx]['format_id']

        # Video download options (based on user choice)
        video_opts = {
            'format': video_format_code,  # Download user-selected video format
            'outtmpl': os.path.join(download_path, 'video.%(ext)s'),  # Save video as video.mp4
        }

        # Audio download options (based on user choice)
        audio_opts = {
            'format': audio_format_code,  # Download user-selected audio format
            'outtmpl': os.path.join(download_path, 'audio.%(ext)s'),  # Save audio as audio.m4a
        }

        # Download the selected video format
        print("\nDownloading selected video format...")
        with yt_dlp.YoutubeDL(video_opts) as ydl_video:
            ydl_video.download([url])

        # Download the selected audio format
        print("\nDownloading selected audio format...")
        with yt_dlp.YoutubeDL(audio_opts) as ydl_audio:
            ydl_audio.download([url])

        # Paths to the downloaded video and audio files
        video_file = os.path.join(download_path, 'video.webm')  # Assuming best video will be .mp4
        audio_file = os.path.join(download_path, 'audio.m4a')  # Assuming best audio will be .m4a
        output_file = os.path.join(download_path, 'final_output.mp4')  # Final merged file

        # FFmpeg command to merge audio and video
        ffmpeg_cmd = [
            'ffmpeg', '-i', video_file, '-i', audio_file, '-c', 'copy', output_file
        ]

        # Run FFmpeg to merge audio and video
        print("\nMerging video and audio...")
        subprocess.run(ffmpeg_cmd, check=True)

        print(f"\nDownload and merging complete! Output file: {output_file}")

    except Exception as e:
        print(f"An error occurred: {e}")

# Example usage
video_url = "https://www.youtube.com/watch?v=SOwk8FhfEZY"  # Replace with your desired video URL
download_path = 'C:/Users/vinod/Downloads/VideoDownload'  # Replace with your desired download path
download_and_merge_video_audio_with_selection(video_url, download_path)



    


    Explanation :

    


    The script first lists all available video formats (video-only) and audio formats (audio-only) from a given YouTube URL.

    


    It allows the user to manually select their preferred video and audio formats.

    


    After downloading the selected formats, it merges the video and audio streams into a single file using FFmpeg.

    


    Error

    


    while trying to run above mentioned code , I am getting this error :

    


    Merging video and audio...
An error occurred: [WinError 2] The system cannot find the file specified


    


    Requirements :

    


    


    yt-dlp : pip install yt-dlp

    


    


    


    FFmpeg : Make sure you have FFmpeg installed and added to your system's PATH.

    


    


  • Transcoding/ Converting mpeg to h264 using ffmpeg h264_nvenc

    15 septembre 2024, par Mustafa

    I'm trying to transcode a video rendered by Davinci Resolve, using ffmpeg from mpeg4 to h264, on Ubuntu, using the following command.

    


    ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i input.mov -c:a copy -c:v h264_nvenc -b:v 8M -preset 7 output-h264_nvenc-p7.mp4 -v verbose


    


    And my Nvidia card is NVIDIA GeForce GTX 1650.

    


    I'm gettting the following error :

    


    [mpeg4 @ 0x55a893ed3200] Video width 3840 not within range from 48 to 2032
[mpeg4 @ 0x55a893ed3200] Failed setup for format cuda: hwaccel initialisation returned error.


    


    And here's the complete output. The command produces an output but its quality is significantly less than the original.

    


      built with gcc 13 (Ubuntu 13.2.0-23ubuntu4)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared --enable-gpl --enable-libx264
  libavutil      59. 36.100 / 59. 36.100
  libavcodec     61. 13.100 / 61. 13.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.101 / 61.  2.101
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
-vsync is deprecated. Use -fps_mode
Passing a number to -vsync is deprecated, use a string argument as described in the manual.
Selecting decoder 'mpeg4' because of requested hwaccel method cuda
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2024-09-15T04:25:29.000000Z
    encoder         : Blackmagic Design DaVinci Resolve
  Duration: 00:20:34.87, start: 0.000000, bitrate: 347243 kb/s
  Stream #0:0[0x1]: Video: mpeg4 (Simple Profile), 1 reference frame (mp4v / 0x7634706D), yuv420p(bt709/bt709/unknown, left), 3840x2160 [SAR 1:1 DAR 16:9], 345703 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
      Metadata:
        creation_time   : 2024-09-15T04:25:29.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        encoder         : MPEG4 Video
        timecode        : 01:00:00:00
  Stream #0:1[0x2]: Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-09-15T04:25:29.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
      Metadata:
        creation_time   : 2024-09-15T04:25:29.000000Z
        handler_name    : TimeCodeHandler
        timecode        : 01:00:00:00
[out#0/mp4 @ 0x55a8929e8d80] No explicit maps, mapping streams automatically...
[vost#0:0/h264_nvenc @ 0x55a8929f5880] Created video stream from input stream 0:0
[aost#0:1/copy @ 0x55a893867080] Created audio stream from input stream 0:1
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
[vost#0:0/h264_nvenc @ 0x55a8929f5880] Starting thread...
[vf#0:0 @ 0x55a8929f17c0] Starting thread...
[vist#0:0/mpeg4 @ 0x55a89293a100] [dec:mpeg4 @ 0x55a8929f4440] Starting thread...
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x55a8929e0600] Starting thread...
Press [q] to stop, [?] for help
[mpeg4 @ 0x55a893ed3200] NVDEC capabilities:
[mpeg4 @ 0x55a893ed3200] format supported: yes, max_mb_count: 8192
[mpeg4 @ 0x55a893ed3200] min_width: 48, max_width: 2032
[mpeg4 @ 0x55a893ed3200] min_height: 16, max_height: 2032
[mpeg4 @ 0x55a893ed3200] Video width 3840 not within range from 48 to 2032
[mpeg4 @ 0x55a893ed3200] Failed setup for format cuda: hwaccel initialisation returned error.
[graph -1 input from stream 0:0 @ 0x75c970002e40] w:3840 h:2160 pixfmt:yuv420p tb:1/15360 fr:60/1 sar:1/1 csp:bt709 range:unknown
[graph -1 input from stream 0:0 @ 0x75c970002e40] video frame properties congruent with link at pts_time: 0
[h264_nvenc @ 0x55a8929e62c0] Using device cuda0 (type cuda) with h264_nvenc encoder.
[h264_nvenc @ 0x55a8929e62c0] Loaded Nvenc version 12.2
[h264_nvenc @ 0x55a8929e62c0] Nvenc initialized successfully
[h264_nvenc @ 0x55a8929e62c0] The selected preset is deprecated. Use p1 to p7 + -tune or fast/medium/slow.
Output #0, mp4, to 'output-h264_nvenc-p7.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf61.5.101
  Stream #0:0: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive, left), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 8000 kb/s, 60 fps, 15360 tbn (default)
      Metadata:
        creation_time   : 2024-09-15T04:25:29.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        timecode        : 01:00:00:00
        encoder         : Lavc61.13.100 h264_nvenc
      Side data:
        cpb: bitrate max/min/avg: 0/0/8000000 buffer size: 16000000 vbv_delay: N/A
  Stream #0:1: Audio: pcm_s16le (ipcm / 0x6D637069), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-09-15T04:25:29.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]


    


    How can I find the cause of the error and resolve it ?

    


    Also is there a way to improve the quality of the output video as it's much lower than the original ? I tried doing the same conversion using libxh264 (using the CPU) and that produced a far better video.

    


  • ffmpeg fast seek large MP4 over HTTP

    28 juillet 2024, par Gmanicus

    I'm attempting to download snapshots from a video provided by the U.S House of Representatives :

    


    https://houseliveprod-f9h4cpb9dyb8gegg.a01.azurefd.net/east/2024-04-11T08-55-12_Download/video_3000000_1.mp4


    


    I am using fluent-ffmpeg in Node to execute this command :

    


    ffmpeg('https://houseliveprod-f9h4cpb9dyb8gegg.a01.azurefd.net/east/2024-04-11T08-55-12_Download/video_3000000_1.mp4')
  .inputOption(`-ss 03:33:33`)
  .outputOptions([
     '-vframes 1'
  ])
  .output('test.png')

// Effectively:
// ffmpeg -ss 03:33:33 -i  -y -vframes 1 test.png


    


    My intention is to fast-seek to the desired timestamp and take a snapshot over HTTP. However, when doing so, the performance is not great. A snapshot takes about 10s per 3hrs of video and seems to increase fairly linearly at that rate.

    


    However, when using ffmpeg on the same video locally, it's super fast ! Sub-500ms regardless of the desired timestamp.

    


    Is there some magic that could be done via ffmpeg options or perhaps some sort of technique with manual requests to get a snapshot at the desired segment of video more efficiently ?