Recherche avancée

Médias (0)

Mot : - Tags -/serveur

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

Autres articles (64)

Sur d’autres sites (11059)

  • Why every audio part is louder in FFmpeg when I join them in one audio ?

    14 mai 2024, par Volodymyr Bilovus

    I trying to make dubbing for audio. I have original audio track and I want to put translated audio parts on top of the original.

    


    translated audio 100% vol : —p1--- ---p2— -----p3--- —p4—

    


    original audio 5% vol : -----------------------------------------

    


    Here is my FFmpeg command with filter_complex

    


    ffmpeg -i video_wpmXlZF4XiE.opus -i 989-audio.mp3 -i 989-audio.mp3 -i 989-audio.mp3 -i 989-audio.mp3 \
-filter_complex "\
[0:a]loudnorm=I=-14:TP=-2:LRA=7, volume=0.05[original]; \
[1:a]loudnorm=I=-14:TP=-2:LRA=7, adelay=5000|5000, volume=1.0[sent1]; \
[2:a]loudnorm=I=-14:TP=-2:LRA=7, adelay=10000|10000, volume=1.0[sent2]; \
[3:a]loudnorm=I=-14:TP=-2:LRA=7, adelay=20000|20000, volume=1.0[sent3]; \
[4:a]loudnorm=I=-14:TP=-2:LRA=7, adelay=30000|30000, volume=1.0[sent4]; \
[original][sent1][sent2][sent3][sent4]amix=inputs=5:duration=longest[out]" \
-map "[out]" output.mp3


    


    Audios I put on top of the original audio track is the same -i 989-audio.mp3 I made it by purpose to show the problem
And here is the audio levels on final generated track.
enter image description here

    


    As you can see, first and second only slightly different but third
and fourth have totally different(higher) volume level (Notice, audio is the same).
Why it's happened ? And how can I workaround this odd behaviour ?

    


  • FFmpeg-Python command too long because of drawtext

    21 mai 2024, par Xascoria

    I have a FFmpeg-Python program that puts subtitles into a video, pseudocode below :

    


    for i in range(10000):
    video= video.filter(
        'drawtext', fontfile=FONT_FILE, text=cur_string, x='(w-text_w)/2', y='(h-text_h)/2',
        fontsize=FONT_SIZE, fontcolor=FONT_COLOR, borderw=2, bordercolor=FONT_OUTLINE_COLOR,
        enable=f'between(t,{i},{i+1})')

video.output(PATH).run()


    


    The code above gives the following error :

    


    FileNotFoundError: [WinError 206] The filename or extension is too long


    


    My questions are :

    


    (1) Is there anyway to check when the ffmpeg command is going to exceed the cmd length limit (8191/28878 ? not actually sure which one is in effect) in code ?

    


    (2) How do I fix this in code ?

    


  • Unable to Play Video Stream on Flask-FFmpeg Media Server on Subsequent Requests

    12 juin 2024, par yternal

    Problem Description :

    


    I am trying to create a media server using Flask and FFmpeg. The server converts an RTSP stream to FLV format for playback in a web browser, and I am testing it using ffplay. The server starts successfully, and the data returned from the first request can be played using ffplay. However, when I interrupt the ffplay request and make it again, ffplay is unable to play the video and displays an "Invalid data found when processing input" error.

    


    I am using the following command to test with ffplay :

    


    ffplay http://127.0.0.1:8000/flv/0


    


    My current Flask code:

    


    import queue
import subprocess
import threading

from flask import Flask, Response, stream_with_context
from gevent import monkey
from gevent.pool import Pool
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from loguru import logger

monkey.patch_all()
app = Flask(__name__)

stream_queue = queue.Queue(maxsize=10000)


def update_stream():
    process = subprocess.Popen(
        ['ffmpeg', '-i', 'rtsp://192.168.1.168/0', '-f', 'flv', '-'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    while True:
        data = process.stdout.read(4096)
        if not data:
            break
        if stream_queue.full():
            stream_queue.get()
        stream_queue.put(data)
        logger.debug(f"stream_queue size: {stream_queue.qsize()}")


@app.route('/flv/')
def flv_stream(stream_id):
    @stream_with_context
    def generate():

        while True:
            data = stream_queue.get()
            yield data

    return Response(generate(), mimetype='video/x-flv')


if __name__ == '__main__':
    HOST = "0.0.0.0"
    PORT = 8000

    threading.Thread(target=update_stream, daemon=True).start()

    logger.info(f"listen in: {HOST}:{PORT}")
    pool = Pool(10000)
    http_serve = WSGIServer((HOST, PORT), app, handler_class=WebSocketHandler, spawn=pool)
    http_serve.max_accept = 30000
    http_serve.serve_forever()


    


    The error message when attempting to play the stream again with ffplay is :

    


    http://127.0.0.1:8000/flv/0: Invalid data found when processing input


    


    I tried adding some parameters to FFmpeg, such as analyzeduration and probesize, but it had no effect.