
Recherche avancée
Autres articles (44)
-
Utilisation et configuration du script
19 janvier 2011, parInformations spécifiques à la distribution Debian
Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
Récupération du script
Le script d’installation peut être récupéré de deux manières différentes.
Via svn en utilisant la commande pour récupérer le code source à jour :
svn co (...) -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)
Sur d’autres sites (5660)
-
ffprobe filter videos by duration, command prints but does not return duration
22 juillet 2021, par jcuI am attempting to use ffprobe to filter through videos by their duration. I was using :


vid_length = subprocess.call(f"ffprobe -i {local_vids_2[count]} -show_entries format=duration -v quiet -of csv='p=0'", shell = True)
print("VIDEO LENGTH IS:", vid_length, "FOR: ", count)



While I DO get the duration printed to my command prompt by the shell command, I noticed I DON'T get it returned as a variable like I need. Instead it's returning 0, so I get something like :
VIDEO URL IS: 100_scaled.mp4 FOR: 0 11.883000 VIDEO LENGTH IS: 0 FOR: 0
andVIDEO URL IS: 101_scaled.mp4 FOR: 1 56.171000 VIDEO LENGTH IS: 0 FOR: 1
etc.

I have also tried
vid_length = subprocess.call(f"ffprobe -i {local_vids_2[count]} -show_entries format=duration -v quiet -of csv=%s % ('p=0')", shell = True)
based on what I read in this post but that hasn't worked either.

Is there a way I can get this command to return anything ? Or do I need something else that will return the video length for coding purposes ? Thank You.


-
Python subprocess or os.system not working with ffmpeg
13 février 2024, par confusedI'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 SmithFollowing 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 infname
) :

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

</module>


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