Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (55)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • 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.

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (3547)

  • Python subprocess or os.system not working with ffmpeg

    13 février 2024, par confused

    I've been trying to get this darn programming run since last night and cannot seem to get anything to work. I want to first trim the video and then resize the video. I'm reading which video and what to give the final name from a text file, over 780 lines long, quite a few videos.

    


    Thus far with every idea under the sun I have tried, subprocess and os.system, I can't get anything more than error statements or right now all I get is no file creation of any kind. How the heck do I get this to work correctly ?

    


    import ffmpeg
import subprocess
import os

os.chdir('/home/Downloads/SRs/')
a = open('SRt.txt', 'r')
b = a.readlines()
a.close()
for c in range(0, len(b)-1):
    words = list(b[c].split(" "))
    d = len(words)
    e = words[d-1]
    f = b[c].replace(e, 'FR' + str(c) + '.mp4')
    words[d-1] = 'FR' + str(c) + '.mp4'
    print(f)
    subprocess.call(f, shell=True)
    subprocess.call([
        'ffmpeg',
        '-i',
        "'FR' + str(c) + '.mp4'",
        '-vf scale=320:240',
        words[d-1],
        ])


    


    Here are some examples of what the original file would look like :

    


     ffmpeg -i SR.mp4 -ss 00:00:00 -to 00:01:22 -c:v copy -a copy CPH.mp4
 ffmpeg -i SR.mp4 -ss 00:01:24 -to 00:02:58 -c:v copy -a copy CG.mp4
 ffmpeg -i SR.mp4 -ss 00:02:59 -to 00:05:41 -c:v copy -a copy CSGP.mp4


    


    Nothing fancy just separating video in its own individual segments and then resaving it before resizing it.

    


    I tried :

    


    z=subprocess.call(f, shell=True, stdout=subprocess.PIPE)
print(z)


    


    But all I get is '1'.

    


    When I changed it to :

    


    z=subprocess.call(f, shell=True, stderr=subprocess.PIPE)
print(z)


    


    All I get is '1'.

    


    Maybe I'm doing something wrong.

    


  • Why do I get UnknownValueError when trying to run .recognize_google ?

    21 juillet 2022, par John Smith

    Following code is meant to transcribe a long audio file to text. It is to do this piece by piece. trimmed.wav holds a 15-second-long piece of a longer audio file (whose path is stored in fname) :

    


    #!/usr/bin/env python3

from subprocess import run
from sys import exit

italic = '\33[3m'
end = '\33[m'

try:
    from speech_recognition import AudioFile, Recognizer
except:
    run("pip3 install SpeechRecognition", shell=True)
    from speech_recognition import AudioFile, Recognizer

def transcribe_piece(fname, lang, stime):
    extension = fname[-3:]
    etime = stime + 15
    cmd = f"ffmpeg -ss {stime} -to {etime} -i {fname} -c copy trimmed.{extension} >/dev/null 2>&1"
    run(cmd, shell=True)
    cmd = f"ffmpeg -i trimmed.{extension} -f wav trimmed.wav >/dev/null 2>&1"
    run(cmd, shell=True)
    r = Recognizer()    
    af = AudioFile("trimmed.wav")
    with af as source:
        r.adjust_for_ambient_noise(source)
        audio = r.record(source)
        t = r.recognize_google(audio, language=lang)#UnknownValueError() speech_recognition.UnknownValueError
        print(f"{italic}{t}{end}")
        with open("of", "w") as f:
            f.write(f"{t}\n")
    run(f"rm trimmed.{extension}", shell=True) 
    run(f"rm trimmed.wav", shell=True)
    
    

fname = input("File name? Skip the path if the file is in CWD. The usage of ~ is allowed.\n")

lang = input("""Specify one of the following languages:
fr-BE, fr-CA, fr-FR, fr-CH

en-AU, en-CA, en-GH, en-HK, en-IN, en-IE, en-KE, en-NZ, en-PK, en-PH, en-SG, en-ZA, en-TZ, en-GB, en-US

es-AR, es-BO, es-BO, es-CL, es-CO, es-CR, es-DO, es-EC, es-SV, es-SV, es-GT, es-HN, es-MX, es-NI, es-PA, es-PY, es-PE, es-PR, es-ES, es-US, es-UY, es-VE\n""")


#for stime in range(0, 10000, 15):
#    try:
#        transcribe_piece(fname, lang, stime)
#    except:
#        run("shred -u trimmed.wav" , shell=True) 
        #run("shred -u trimmed.wav >/dev/null 2>&1" , shell=True) 
#        exit(0)
        
for stime in range(0, 10000, 15):#this loop is only for the sake of debugging, use try/except above
    transcribe_piece(fname, lang, stime)



    


    It gives me the following error :

    


    Traceback (most recent call last):&#xA;  File "/home/jim/CS/SoftwareDevelopment/MySoftware/Python/speech-to-text/long-audio-to-text.py", line 61, in <module>&#xA;    transcribe_piece(fname, lang, stime)&#xA;  File "/home/jim/CS/SoftwareDevelopment/MySoftware/Python/speech-to-text/long-audio-to-text.py", line 31, in transcribe_piece&#xA;    t = r.recognize_google(audio, language=lang)&#xA;  File "/home/jim/.local/lib/python3.10/site-packages/speech_recognition/__init__.py", line 858, in recognize_google&#xA;    if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError()&#xA;speech_recognition.UnknownValueError&#xA;&#xA;</module>

    &#xA;

    The said error refers to line 31, that is t = r.recognize_google(audio, language=lang).&#xA;Why do I get this error ? How might I rewrite this code so that such error does not appear ?

    &#xA;

  • Handling "NullReferenceException" when executing "ffmpeg.exe" process in C# [duplicate]

    1er juillet 2023, par FrostDream

    I'm trying to execute the "ffmpeg.exe" process in my C# application to process media files. However, I'm encountering a "NullReferenceException" when running the code. I've tried various approaches, including using a try-catch block, but the exception still persists. Here's the relevant code snippet :

    &#xA;

    bool isValidMedia = true;&#xA;&#xA;try&#xA;{&#xA;    Process process = new Process();&#xA;    process.StartInfo.FileName = "ffmpeg.exe";&#xA;    process.StartInfo.Arguments = $"-i \"{file}\" -f null -";&#xA;    process.StartInfo.UseShellExecute = false;&#xA;    process.StartInfo.RedirectStandardOutput = true;&#xA;    process.StartInfo.CreateNoWindow = true;&#xA;    process.OutputDataReceived &#x2B;= (sender, e) =>&#xA;    {&#xA;        if (!string.IsNullOrEmpty(e.Data))&#xA;        {&#xA;            int startIndex = e.Data.IndexOf("samples=") &#x2B; 8;&#xA;            button.Width = int.Parse(e.Data.Substring(startIndex, e.Data.IndexOf(" ") - startIndex)) / zoom * 100;&#xA;        }&#xA;        else&#xA;        {&#xA;            isValidMedia = false;&#xA;        }&#xA;    };&#xA;&#xA;    process.Start();&#xA;    process.BeginOutputReadLine();&#xA;    process.WaitForExit();&#xA;}&#xA;catch&#xA;{&#xA;    isValidMedia = false;&#xA;}&#xA;&#xA;if (!isValidMedia)&#xA;{&#xA;    MessageBox.Show("Not a valid media.");&#xA;    return;&#xA;}&#xA;&#xA;

    &#xA;

    I suspect that the issue may be related to the asynchronous execution of the event handler or the initialization of the ProcessStartInfo object. Can anyone please help me identify the cause of the "NullReferenceException" and provide guidance on how to resolve it ? Thank you in advance for your assistance.

    &#xA;