Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • I'm getting error while building the project in vue for ffmpeg.wasm

    2 avril, par EaBengaluru

    Hi i'm getting below error when i build the project with $npm run build command

    enter image description here

    I'm using vuetify "vuetify": "^2.4.0" still because 3.0 is still in beta so i'm using "vue": "^2.6.11",

    Here is my package.json

    {
       ....
       "dependencies": {
          "@ffmpeg/core": "^0.11.5",
          "@ffmpeg/ffmpeg": "^0.11.0",
          "core-js": "^3.6.5",
          "vue": "^2.6.11",
          "vue-router": "^3.5.3",
          "vuetify": "^2.4.0"
        },
        "devDependencies": {
          "@vue/cli-plugin-babel": "~4.5.0",
          "@vue/cli-plugin-eslint": "~4.5.0",
          "@vue/cli-service": "~4.5.0",
          "babel-eslint": "^10.1.0",
          "eslint": "^6.7.2",
          "eslint-plugin-vue": "^6.2.2",
          "sass": "~1.32.0",
          "sass-loader": "^10.0.0",
          "vue-cli-plugin-vuetify": "~2.4.5",
          "vue-template-compiler": "^2.6.11",
          "vuetify-loader": "^1.7.0"
        },
        "eslintConfig": {
          "root": true,
          "env": {
            "node": true
          },
          "extends": [
            "plugin:vue/essential",
            "eslint:recommended"
          ],
          "parserOptions": {
            "parser": "babel-eslint"
          },
          "rules": {}
        },
        "browserslist": [
          "> 1%",
          "last 2 versions",
          "not dead"
        ]
      }
    

    Note: it was working fine with "@ffmpeg/ffmpeg": "^0.10.1", when i updated it to "@ffmpeg/ffmpeg": "^0.11.0", it is not working

    in my vue.config.js there is nothing much , except transpileDependencies

    module.exports = {
      transpileDependencies: [
        'vuetify'
      ]
    }
    

    Here is i have uploaded my project https://easyupload.io/rl9xyd [Download with high speed]

    Note: i want to use vuetify

    Question: i want to build with "@ffmpeg/core": "^0.11.0", "@ffmpeg/ffmpeg": "^0.11.5" and vuetify

    Please help me to resolve the error thanks in advance !!!

  • Merge multiple hls playlists

    2 avril, par Boris

    I want to speed up the process of HLS segmentation of .mp4 video. Now, processing a half-hour video can take about 5 minutes, and that is too long. To do this, I decided to split the video into fragments, process each of them in parallel, and then create an .m3u8 file that will contain a list of .ts files from all the resulting playlists in the correct order. I used the next commands:

    ffmpeg -i original.mp4 -acodec copy -f segment -segment_time 10 -vcodec copy -reset_timestamps 1 -map 0 output_time_%d.mp4
    

    for splitting the original video to .mp4 fragments 10 seconds long each;

    ffmpeg -y -i output_time_0.mp4 -b:v 1M -g 60 -hls_list_size 0 -hls_segment_filename output_time_0_%d.ts -hls_segment_size 50000 -hls_time 3 output_time_0_playlist.m3u8
    
    ffmpeg -y -i output_time_1.mp4 -b:v 1M -g 60 -hls_list_size 0 -hls_segment_filename output_time_1_%d.ts -hls_segment_size 50000 -hls_time 3 output_time_1_playlist.m3u8
    

    and so forth for each fragment. Then I have edited an .m3u8 file in text editor. I did this, but the problem is that when I try to play my synthetic playlist in the player, playback stops at the beginning of the first "alien" fragment. The flag #EXT-X-DISCONTINUITY did not change anything. So I had multiple .m3u8 files:

    #EXTM3U
    #EXT-X-VERSION:4
    #EXT-X-TARGETDURATION:4
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:385964@0
    output_time_0_0.ts
    #EXTINF:2.002000,
    #EXT-X-BYTERANGE:180104@0
    output_time_0_1.ts
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:438604@0
    output_time_0_2.ts
    #EXTINF:0.133467,
    #EXT-X-BYTERANGE:142128@0
    output_time_0_3.ts
    #EXT-X-ENDLIST
    

    and

    #EXTM3U
    #EXT-X-VERSION:4
    #EXT-X-TARGETDURATION:4
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:447628@0
    output_time_1_0.ts
    #EXTINF:2.002000,
    #EXT-X-BYTERANGE:222592@0
    output_time_1_1.ts
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:517940@0
    output_time_1_2.ts
    #EXTINF:0.100100,
    #EXT-X-BYTERANGE:154912@0
    output_time_1_3.ts
    #EXT-X-ENDLIST
    

    and I've joined them manually, so I have the following one:

    #EXTM3U
    #EXT-X-VERSION:4
    #EXT-X-TARGETDURATION:4
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:385964@0
    output_time_0_0.ts
    #EXTINF:2.002000,
    #EXT-X-BYTERANGE:180104@0
    output_time_0_1.ts
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:438604@0
    output_time_0_2.ts
    #EXTINF:0.133467,
    #EXT-X-BYTERANGE:142128@0
    output_time_0_3.ts
    #EXT-X-DISCONTINUITY
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:447628@0
    output_time_1_0.ts
    #EXTINF:2.002000,
    #EXT-X-BYTERANGE:222592@0
    output_time_1_1.ts
    #EXTINF:4.004000,
    #EXT-X-BYTERANGE:517940@0
    output_time_1_2.ts
    #EXTINF:0.100100,
    #EXT-X-BYTERANGE:154912@0
    output_time_1_3.ts
    #EXT-X-ENDLIST
    

    How do you rate my idea as a whole, and are there any ideas on how to fix the playback error?

  • Looking for a non-FFMPEG/non-Lame Python audio converter for Android [closed]

    1er avril, par Marcelcolt

    So as the title suggests, I'm looking for another way to convert audio. I am currently using PyTubeFix to download audio from YouTube. That works awesome, but it downloads in M4A. I would really like it in MP3.

    Most converter libraries and packages use FFMPEG. I've tried to download it through Termux and PyDroid3, but that doesn't work. I've tried to compile it for Android with NDK, but I am so lost in what I am supposed to be doing... Same goes for Lame. I've been at it for over a week now, but I can't find any other way to convert.

    AI only suggests that I write a library of my own, but not HOW to do that (only that I'd have to convert M4A to WAV first and then back to MP3).

    So I would love it if someone could point me towards a library or package that doesn't depend on FFMPEG or Lame.

    I hope you guys can help!

  • How to restream IPTV playlist with Nginx RTMP, FFmpeg, and Python without recording, but getting HTTP 403 error ? [closed]

    1er avril, par boyuna1720

    I have an IPTV playlist from a provider that allows only one user to connect and watch. I want to restream this playlist through my own server without recording it and in a lightweight manner. I’m using Nginx RTMP, FFmpeg, and Python TCP for the setup, but I keep getting an HTTP 403 error when trying to access the stream.

    Here’s a summary of my setup:

    Nginx RTMP: Used for streaming.

    FFmpeg: Used to handle the video stream.

    Python TCP: Trying to handle the connection between my server and the IPTV source.

    #!/usr/bin/env python3
    
    import sys
    import socket
    import threading
    import requests
    import time
    
    def accept_connections(server_socket, clients, clients_lock):
        """
        Continuously accept new client connections, perform a minimal read of the
        client's HTTP request, send back a valid HTTP/1.1 response header, and
        add the socket to the broadcast list.
        """
        while True:
            client_socket, addr = server_socket.accept()
            print(f"[+] New client connected from {addr}")
            threading.Thread(
                target=handle_client,
                args=(client_socket, addr, clients, clients_lock),
                daemon=True
            ).start()
    
    def handle_client(client_socket, addr, clients, clients_lock):
        """
        Read the client's HTTP request minimally, send back a proper HTTP/1.1 200 OK header,
        and then add the socket to our broadcast list.
        """
        try:
            # Read until we reach the end of the request headers
            request_data = b""
            while b"\r\n\r\n" not in request_data:
                chunk = client_socket.recv(1024)
                if not chunk:
                    break
                request_data += chunk
    
            # Send a proper HTTP response header to satisfy clients like curl
            response_header = (
                "HTTP/1.1 200 OK\r\n"
                "Content-Type: application/octet-stream\r\n"
                "Connection: close\r\n"
                "\r\n"
            )
            client_socket.sendall(response_header.encode("utf-8"))
    
            with clients_lock:
                clients.append(client_socket)
            print(f"[+] Client from {addr} is ready to receive stream.")
        except Exception as e:
            print(f"[!] Error handling client {addr}: {e}")
            client_socket.close()
    
    def read_from_source_and_broadcast(source_url, clients, clients_lock):
        """
        Continuously connect to the source URL (following redirects) using custom headers
        so that it mimics a curl-like request. In case of connection errors (e.g. connection reset),
        wait a bit and then try again.
        
        For each successful connection, stream data in chunks and broadcast each chunk
        to all connected clients.
        """
        # Set custom headers to mimic curl
        headers = {
            "User-Agent": "curl/8.5.0",
            "Accept": "*/*"
        }
    
        while True:
            try:
                print(f"[+] Fetching from source URL (with redirects): {source_url}")
                with requests.get(source_url, stream=True, allow_redirects=True, headers=headers) as resp:
                    if resp.status_code >= 400:
                        print(f"[!] Got HTTP {resp.status_code} from the source. Retrying in 5 seconds.")
                        time.sleep(5)
                        continue
    
                    # Stream data and broadcast each chunk
                    for chunk in resp.iter_content(chunk_size=4096):
                        if not chunk:
                            continue
                        with clients_lock:
                            for c in clients[:]:
                                try:
                                    c.sendall(chunk)
                                except Exception as e:
                                    print(f"[!] A client disconnected or send failed: {e}")
                                    c.close()
                                    clients.remove(c)
            except requests.exceptions.RequestException as e:
                print(f"[!] Source connection error, retrying in 5 seconds: {e}")
                time.sleep(5)
    
    def main():
        if len(sys.argv) != 3:
            print(f"Usage: {sys.argv[0]}  ")
            sys.exit(1)
    
        source_url = sys.argv[1]
        port = int(sys.argv[2])
    
        # Create a TCP socket to listen for incoming connections
        server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        server_socket.bind(("0.0.0.0", port))
        server_socket.listen(5)
        print(f"[+] Listening on port {port}...")
    
        # List of currently connected client sockets
        clients = []
        clients_lock = threading.Lock()
    
        # Start a thread to accept incoming client connections
        t_accept = threading.Thread(
            target=accept_connections,
            args=(server_socket, clients, clients_lock),
            daemon=True
        )
        t_accept.start()
    
        # Continuously read from the source URL and broadcast to connected clients
        read_from_source_and_broadcast(source_url, clients, clients_lock)
    
    if __name__ == "__main__":
        main()
    

    When i write command python3 proxy_server.py 'http://channelurl' 9999 I getting error.

    [+] Listening on port 9999...
    [+] Fetching from source URL (with redirects): http://ate91060.cdn-akm.me:80/dc31a19e5a6a/fc5e38e28e/325973
    [!] Got HTTP 403 from the source. Retrying in 5 seconds.
    ^CTraceback (most recent call last):
      File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 127, in 
        main()
      File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 124, in main
        read_from_source_and_broadcast(source_url, clients, clients_lock)
      File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 77, in read_from_source_and_broadcast
        time.sleep(5)
    KeyboardInterrupt
    
  • Use FFMPEG and i have one video 30sec i want mulipal trimming

    1er avril, par aryan patel

    i want this video trim mulipal like 0.2 sec to 0.5, 0.10sec to 0.14sec and 0.23 to 0.29sec this video trimed success after i want this trimed 3 video merge and create one video and save that any one can know me how