Recherche avancée

Médias (1)

Mot : - Tags -/blender

Autres articles (57)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

Sur d’autres sites (8497)

  • Trying to convert code to be compatible with macOS by not using the .exe version of FFmpeg and FFmprobe. Cant open the .mp4 file when i go to run code

    9 juillet 2024, par Bruno Hawkins

    I am attempting to edit some code in python for extracting frames from a video (using parallel processing to make it faster) a friend created that works on windows, so that it can be used on macOS. However, i am running into some issues and i am not sure what the problem is.

    


    Essentially, when i go to run the frame extractor and try to select a video in the formats specified, it wont let me select it.

    


    i have commented my code best i can. i am an amateur programmer so apologies if it is straightforward.

    


    import os
import subprocess
import multiprocessing
import tkinter as tk
from tkinter import ttk, filedialog, messagebox

def extract_frames(video_path, output_folder, fps, start_time, duration, process_number):
    video_name = os.path.splitext(os.path.basename(video_path))[0]
    part_output_folder = os.path.join(output_folder, f"part_{process_number}")
    if not os.path.exists(part_output_folder):
        os.makedirs(part_output_folder)

    # Using 'ffmpeg' instead of 'ffmpeg.exe' for macOS compatibility
    ffmpeg_command = [
        'ffmpeg', '-ss', str(start_time), '-t', str(duration), '-i', video_path, '-vf', f'fps={fps}',
        os.path.join(part_output_folder, f'{video_name}_frame_%07d.png')
    ]

    print(f"Running FFmpeg command: {' '.join(ffmpeg_command)}")

    try:
        process = subprocess.run(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        if process.returncode != 0:
            print(f"Cannot process the file {video_path}: {process.stderr.decode('utf-8')}")
            return part_output_folder, 0
    except Exception as e:
        print(f"Failed to run FFmpeg command: {str(e)}")
        return part_output_folder, 0

    frame_count = len([f for f in os.listdir(part_output_folder) if f.endswith('.png')])
    return part_output_folder, frame_count

def worker_function(queue, video_path, output_folder, fps, start_time, duration, process_number):
    result = extract_frames(video_path, output_folder, fps, start_time, duration, process_number)
    queue.put(result)

def parallel_frame_extraction(video_path, output_folder, fps, num_processes):
    # Use 'ffprobe' instead of 'ffprobe.exe' for macOS compatibility
    ffprobe_command = [
        'ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'format=duration', '-of',
        'default=noprint_wrappers=1:nokey=1', video_path
    ]

    try:
        result = subprocess.run(ffprobe_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        duration = float(result.stdout.strip())
    except Exception as e:
        messagebox.showerror("Error", f"Failed to get video duration: {str(e)}")
        return

    chunk_duration = duration / num_processes
    processes = []
    manager = multiprocessing.Manager()
    queue = manager.Queue()

    if not os.path.exists(output_folder):
        os.makedirs(output_folder)

    for i in range(num_processes):
        start_time = i * chunk_duration
        p = multiprocessing.Process(target=worker_function,
                                    args=(queue, video_path, output_folder, fps, start_time, chunk_duration, i))
        p.start()
        processes.append(p)

    for p in processes:
        p.join()

    global_frame_offset = 0
    while not queue.empty():
        part_output_folder, frame_count = queue.get()
        frame_files = sorted([f for f in os.listdir(part_output_folder) if f.endswith('.png')])
        for i, frame_file in enumerate(frame_files):
            new_name = os.path.join(output_folder,
                                    f'{os.path.basename(video_path)}_frame_{global_frame_offset + i:07d}.png')
            os.rename(os.path.join(part_output_folder, frame_file), new_name)
        global_frame_offset += frame_count
        os.rmdir(part_output_folder)

    messagebox.showinfo("Complete",
                        f"Frame extraction completed for {video_path}. Total frames extracted: {global_frame_offset}")

def start_frame_extraction():
    video_path = filedialog.askopenfilename(filetypes=[("Video files", "*.mp4;*.avi;*.mkv")])
    if not video_path:
        return

    output_folder = output_folder_var.get()
    if not output_folder:
        return

    fps = int(fps_var.get())
    num_processes = int(num_processes_var.get())

    parallel_frame_extraction(video_path, output_folder, fps, num_processes)

if __name__ == "__main__":
    root = tk.Tk()
    root.title("Frame Extraction")

    output_folder_var = tk.StringVar()
    fps_var = tk.StringVar(value="1")
    num_processes_var = tk.StringVar(value="4")

    def browse_output_folder():
        folder_selected = filedialog.askdirectory()
        output_folder_var.set(folder_selected)

    tk.Label(root, text="Output Folder:").grid(row=0, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=output_folder_var, width=50).grid(row=0, column=1, padx=10, pady=10)
    tk.Button(root, text="Browse", command=browse_output_folder).grid(row=0, column=2, padx=10, pady=10)

    tk.Label(root, text="FPS:").grid(row=1, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=fps_var, width=10).grid(row=1, column=1, padx=10, pady=10)

    tk.Label(root, text="Number of Processes:").grid(row=2, column=0, padx=10, pady=10)
    tk.Entry(root, textvariable=num_processes_var, width=10).grid(row=2, column=1, padx=10, pady=10)

    tk.Button(root, text="Start Frame Extraction", command=start_frame_extraction).grid(row=3, column=0, columnspan=3,
                                                                                        padx=10, pady=20)

    root.mainloop()


    


    I tried changing the FFmpeg and FFmprobe path formats from

    


    ffmpeg_path = os.path.join(os.path.dirname(__file__), 'ffmpeg-7.0.1-essentials_build', 'bin', 'ffmpeg.exe')
ffprobe_path = os.path.join(os.path.dirname(__file__), 'ffmpeg-7.0.1-essentials_build', 'bin', 'ffprobe.exe')



    


    to

    


    ffmpeg_command = [
    'ffmpeg', '-ss', str(start_time), '-t', str(duration), '-i', video_path, '-vf', f'fps={fps}',
    os.path.join(part_output_folder, f'{video_name}_frame_%07d.png')
]

ffprobe_command = [
    'ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'format=duration', '-of',
    'default=noprint_wrappers=1:nokey=1', video_path
]



    


    I found this online so im not sure if it is the correct thing to do.

    


    Thanks for any help.

    


  • Problem with combining a video and an audio stream from USB device

    3 février 2020, par FHoevi

    I have two USB devices attached to an RPi, both show up as usual as /dev/video0. Here’s some additional info coming from two command line inputs :

    Device 1, video only (attached to an RPi4) :

    ffmpeg -f v4l2 -list_formats all -i /dev/video0 reports

    [video4linux2,v4l2 @ 0xe5e1c0] Compressed:       mjpeg :
    Motion-JPEG : 1280x720 640x480 320x240

    v4l2-ctl --list-formats-ext reports

    ioctl: VIDIOC_ENUM_FMT
           Type: Video Capture
           [0]: 'MJPG' (Motion-JPEG, compressed)
                   Size: Discrete 1280x720
                           Interval: Stepwise 0.033s - 0.033s with step 0.000s
    (30.000-30.000 fps)
                   Size: Discrete 640x480
                           Interval: Stepwise 0.033s - 0.033s with step 0.000s
    (30.000-30.000 fps)
                   Size: Discrete 320x240
                           Interval: Stepwise 0.033s - 0.033s with step 0.000s
    (30.000-30.000 fps)

    Does work : ffmpeg -f v4l2 -i /dev/video0 -vcodec h264_omx -preset ultrafast -tune zerolatency -g 300 -b:v 1M -mpegts_service_type advanced_codec_digital_hdtv -f mpegts udp://OtherMachine:Port?pkt_size=1316

    Device 2, video and audio (attached to an RPi3, but does not work either on the RPi4) :

    ffmpeg -f v4l2 -list_formats all -i /dev/video0 reports

    [video4linux2,v4l2 @ 0x2c41210] Compressed:       mjpeg :
    Motion-JPEG : 1920x1080 1280x720

    v4l2-ctl --list-formats-ext reports

    ioctl: VIDIOC_ENUM_FMT
                  Index       : 0
                  Type        : Video Capture
                  Pixel Format: 'MJPG' (compressed)
                  Name        : Motion-JPEG
                                 Size: Discrete 1920x1080
                                               Interval: Discrete 0.033s
    (30.000 fps)
                                               Interval: Discrete 0.067s
    (15.000 fps)
                                 Size: Discrete 1280x720
                                               Interval: Discrete 0.033s
    (30.000 fps)
                                               Interval: Discrete 0.067s
    (15.000 fps)

    After quite some tedious work and way too many hours I got this running :

    Video only : ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -c:v copy -preset ultrafast -tune zerolatency -g 300 -f matroska udp://OtherMachine:Port?pkt_size=1316

    Does not work at all : ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -c:v copy -preset ultrafast -tune zerolatency -g 300 -f mpegts udp://OtherMachine:Port?pkt_size=1316, on "OtherMachine" I do see that there is an incoming data stream via VLC, but it could not be digested properly.

    Audio only : ffmpeg -f alsa -thread_queue_size 1024 -i plughw:1 -c:a mp2 -ac 2 -ar 44100 -preset ultrafast -tune zerolatency -b:a 128K -f mpegts udp://OtherMachine:Port?pkt_size=1316

    But this does not work either :

    ffmpeg -f v4l2 -input_format mjpeg -i /dev/video0 -f alsa -thread_queue_size
    1024 -i plughw:1 -c:v copy -c:a mp2 -ac 2 -ar 44100 -preset ultrafast -tune zerolatency -g 300  -b:a 128K -f mpegts udp://OtherMachine:Port?pkt_size=1316

    Could you please provide a hint on how to get these two streams for device 2 working together ? Both of them come from the same hardware/device, my guess is that the MJPG video stream is somehow not fully compliant with the mpegts standard (like it is for device 1) since it works with matroska, but not with mpegts. Could that be ? What needs to be done in that case ?

    Another hint, with the same kind of hardware setup I can do this

    cvlc -vvv v4l2:///dev/video0 --input-slave=alsa://plughw:1,0 --sout='#transcode{acodec=mpga,ab=128}:std{access=http,mux=asf,dst=:Port}'

    So, here my understanding is that video gets passed on unchanged (mjpeg) and audio gets transcoded via vlc’s mpga which presumably corresponds to mp2 for ffmpeg. The container format is asf, but I was not able to get that running with ffmpeg for no obvious reason. Anyway, picking up this vlc broadcast stream via http://StreamingMachine:Port on any other machine in my network is working well. But how to achieve that with ffmpeg directly and potentially not as http:// but udp :// or pipe stream ?

    Alternatively, let me ask this question : Given that I have an incoming mjpeg video stream as well as an incoming mp2 audio stream which kind of container format (ok, it’s obviously not mpegts) is the most appropriate one for combined streaming across my LAN or even into a pipe for further processing ? Believe me, I tried my very best over a couple of hours to find out how to proceed but with no success. At least to my humble knowledge there is nothing such like a table providing answers to questions of that kind.

    I’d be glad to get some insights.

    Best

  • Why does Android kill a process spawned by the developed application ?

    23 octobre 2013, par uprego

    I have a weird problem that I posted as a comment in Understanding Android Tight loops / Spin-On-Suspend error without any useful further comment.

    Let be here the reproduced comment :

    Is it possible for this to be happening also to android native codes, abstracting
    which piece of software would be causing it? It's the only reason I know ffmpeg
    (static binary custom compilation, n2.0.1 tag mint as it clones) is failing to me
    on some devices and not in others (but fails in no device when launched over a v
    algrind!! that, am now supposing, traps frequently the inner program)

    The problem, briefly, is that a compiled ffmpeg n2.0.1 is running OK in emulator and a Sony device, but failing with a segmentation violation in a Samsung device. The program was ran then from valgrind in that Samsung device, with no fail.

    • I have some clues about what could be happening here. But do you know what is happening ?
    • Can this Samsung phone run this ffmpeg compilation the same good the emulator and the Sony phone do ? If not, what are the next steps (trying - when possible - to avoid the use of the NDK) ?