Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • Error Installing mobile-ffmpeg-full-gpl (4.4.LTS) via CocoaPods - 404 Not Found

    18 mars, par Muhammad Accucia

    I am trying to install mobile-ffmpeg-full-gpl (4.4.LTS) in my iOS project using CocoaPods, but I am encountering a 404 error when CocoaPods attempts to download the framework.

    Here is the error message:

    \[!\] Error installing mobile-ffmpeg-full-gpl
    \[!\] /usr/bin/curl -f -L -o /var/folders/78/lk7swzb97ml4dt3zd9grny0c0000gn/T/d20250201-6580-dtli8h/file.zip https://github.com/tanersener/mobile-ffmpeg/releases/download/v4.4.LTS/mobile-ffmpeg-full-gpl-4.4.LTS-ios-framework.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.15.2 cocoapods-downloader/2.1'
    
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    Dload  Upload   Total   Spent    Left  Speed
    0     9    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    curl: (56) The requested URL returned error: 404
    

    It seems like the requested file is no longer available at the specified URL.

    Checked the official GitHub releases page for mobile-ffmpeg-full-gpl (4.4.LTS), but I couldn't find the exact file.

  • Decoding the h.264 stream from a COM port

    18 mars, par Peter

    I would like to know if there is a reliable way to decode an H.264 NAL stream coming through a serial port using software.

    So far, I have managed to decode a single frame using a python script. In this script, I first write the incoming data to a file, and when the end-of-frame marker 00_00_00_01 appears, I display the frame using ffplay.

    import serial
    import subprocess
    import os
    import time
    
    ser = serial.Serial('COM3', 115200, timeout=1)
    output_file = "output.264"
    
    # Variable to store the ffplay process
    ffplay_process = None
    
    # Open the file for writing in binary mode
    with open(output_file, "wb") as file:
    
        print("Writing bytes to output.264. Waiting for the end-of-frame marker 0x00000001.")
    
        buffer = bytearray()
        marker = b'\x00\x00\x00\x01'
    
        try:
            while True:
                if ser.in_waiting:  # If there is data in the buffer
                    data = ser.read(ser.in_waiting)  # Read all available bytes
                    buffer.extend(data)
    
                    # Check if the end-of-frame marker is in the buffer
                    while marker in buffer:
                        index = buffer.index(marker) + len(marker)  # Position after the marker
                        frame = buffer[:index]  # Extract the frame
                        buffer = buffer[index:]  # Keep the remaining data
    
                        print(f"Frame recorded: {len(frame)} bytes")
                        file.write(frame)  # Write the frame to the file
                        file.flush()  # Force writing to disk
    
                        # Close the ffplay window if it is already open
                        if ffplay_process and ffplay_process.poll() is None:
                            ffplay_process.terminate()
                            ffplay_process.wait()  # Wait for the process to terminate
    
                        # Play the recorded frame, reopening the window
                        ffplay_process = subprocess.Popen(["ffplay", "-f", "h264", "-i", output_file])
    
        except KeyboardInterrupt:
            print("\nRecording stopped.")
        finally:
            # Close the serial port and the ffplay process
            ser.close()
    

    However, each time a new end-of-frame marker is detected, the ffplay window closes and reopens to show the next frame. It will flicker when transferring the video. Is there a way to display the frames in the same window for seamless playback when streaming video?

    Or is there a better approach or software that is more suited for this task? I do not know where to start, so I will be glad for any hints.

  • ffmpeg : is there a fast way for extracting several thumbnails from a video without parsing the video from the beginning every time ?

    18 mars, par archie

    I tried several ways for extracting sample frames from a video file with ffmpeg. I found out that the fastest way is by placing the following command in a loop:

    ffmpeg -ss $frame_time -i "$input_video" -frames:v 1 -vf scale=256:-1 "$Work_dir/thumb$thumb_index.jpg"
    

    (I have omitted the parts of the command that are not relevant to the question, such as drawtext, hide_banner, loglevel). The variables frame_time and thumb_index are initialized before the loop and incremented by a fixed amount at every step: +1 for thumbs_index and $duration/25 for frame_time. I read in the ffmpeg documentation (https://trac.ffmpeg.org/wiki/Seeking) that having the -ss part before the -i part is very fast because the input is parsed by keyframe. For the same reason, the loop containing the command above is also much faster than commands based on "-vf fps=$thumbs_number/$duration".

    In fact, the code works pretty well. However, I can't escape a feeling of programming discomfort, because ffmpeg is called several times for each video file, and every time it has to parse the file from the beginning. I mean, if I had a function doing the same as the command above — it would parse a video from the beginning to search for a frame at a certain time — calling it n times to extract a regular sequence of n frames would be bad programming. I should change the function to parse the video file once and get all the frames I need in a single pass.

    My question is: is there a fast way for having ffmpeg parse a video file a single time, searching by keyframes and extracting a given number of frames at a given distance from one another? I am ready to take No for an answer, but one who is deeper into ffmpeg than I am might know a way. Thanks

  • How to implement FFMPEG retry logic [closed]

    18 mars, par M9A

    I am recording a live stream using the following code:

    ffmpeg -i  -c copy output.mp4
    

    This works fine for occasions where the stream is segmented in the sense that it will retry if the stream drops. However if the url no longer exists or returns a code such as 403, it will still retry, resulting in an infinite loop of retrying when the stream doesnt exist.

    How can I retry for segments but maybe retry only a few times for page errors?

  • Loading a larger file with ffmpeg crashes on safari mobile

    17 mars, par developer1

    My use case is to extract audio from video file to minimize the size of sent file over network. Everything works fine on a computer (chrome, safari) but it's either stuck or crashes on ios safari. AFAIK it crashes not while executing the ffmpeg command, but while trying to load the input file, which is quite big (500MB+).

    I load the ffmpeg like this:

      const baseURL = "https://unpkg.com/@ffmpeg/core-mt@0.12.6/dist/esm";
      await ffmpeg.load({
        coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
        wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
        workerURL: await toBlobURL(
          `${baseURL}/ffmpeg-core.worker.js`,
          "text/javascript"
        ),
      });
    
    

    And I try to load the file like this:

    await ffmpeg.writeFile(inputFileName, await fetchFile(file));
    

    But it does not go past this step. How can I work around this limitation? Is there any other way to load larger files?

    Thank you.