
Recherche avancée
Autres articles (55)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (5408)
-
VB.NET FFMPEG Stops
18 mars 2012, par Mcqueen_23Hi evryone i'm trying to convert files using ffmpeg
my codes only fetched
— -Skip--- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Enrique Iglesias - Tonight.mp4' : Metadata : major_brand : mp42 minor_version : 0 compatible_brands : isommp42 creation_time : 2011-03-20 19:07:02 Duration : 00:03:50.05, start : 0.000000, bitrate : 219 kb/s Stream #0.0(und) : Video : h264, yuv420p, 480x360 [PAR 1:1 DAR 4:3], 117 kb/s, 29.97 fps, 59.75 tbr, 1k tbn, 59.83 tbc Metadata : creation_time : 1970-01-01 00:00:00 Stream #0.1(und) : Audio : aac, 44100 Hz, stereo, s16, 95 kb/s Metadata : creation_time : 2011-03-20 19:07:03 Output #0, mp3, to 'Enrique Iglesias - Tonight.mp3' : Metadata : major_brand : mp42 minor_version : 0 compatible_brands : isommp42 TDEN : 2011-03-20 19:07:02 TSSE : Lavf52.94.0 Stream #0.0(und) : Audio : libmp3lame, 44100 Hz, stereo, s16, 64 kb/s Metadata : creation_time : 2011-03-20 19:07:03and cannot i cannot get the next lines ung
Proccess.ErrorDataReceived
eventHere are my Codes
Public Structure ItemStruct
Public ID, URL, FileName, FileExt, ConvertExt, ConvertQuery As String
Public FileSize As Int64
Public Method, status As Method
Public prog_bar As ProgressBar
Public DeleteOrigin, TrimStart, TrimEnd As Boolean
End Structure
Friend Class Converter
Public busy As Boolean = False
Private _Item As ItemStruct
Public Event ProgressChange(ByVal id As String, ByVal percent As Integer, ByVal etr As TimeSpan)
Public Event ConvertFinish(ByVal id As String)
Private m As Threading.Thread
Private WithEvents timer As New Timer With {.Interval = 100}
Public Sub New()
End Sub
Public Sub New(ByVal item As ItemStruct)
_Item = item
m = New Threading.Thread(AddressOf Convert)
End Sub
Public Sub Start()
m.Start()
timer.Start()
End Sub
Private duration As Decimal = 0.0F
Private current As Decimal = 0.0F
Private varIsSet As Boolean = False
Private Sub Convert()
Dim cmd As String = _Item.ConvertQuery
Dim inputName As String = _Item.URL
Dim fName As String = _Item.FileName & _Item.FileExt
Dim dir As String = _Item.URL.Replace(fName, "")
Dim ouputName As String = dir & _Item.FileName & "." & _Item.ConvertExt
cmd = Replace(cmd, "--i", inputName)
cmd = Replace(cmd, "--o", ouputName)
cmd = cmd.Remove(0, 6)
cmd = cmd.Trim
Dim proc As New Process
With proc.StartInfo
.FileName = Path.Combine(Application.StartupPath, "ffmpeg.exe")
.Arguments = cmd
proc.EnableRaisingEvents = False
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardError = True
.RedirectStandardOutput = True
.RedirectStandardInput = True
AddHandler proc.ErrorDataReceived, AddressOf UpdateData
proc.Start()
proc.BeginErrorReadLine()
End With
End Sub
Public Sub Cancel()
m.Abort()
End Sub
Private Sub UpdateData(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
Dim s As String = e.Data
If s.Contains("Duration: ") Then
duration = GetDuration(s)
ElseIf s.Contains("frame=") Then
current = GetTime(s)
Else
Dim proc As Process = DirectCast(sender, Process)
Dim m As Match = Regex.Match(s, "^File\ '(.*?)'\ already\ exists", RegexOptions.IgnoreCase)
If m.Success Then
Dim w As StreamWriter = proc.StandardInput
If MessageBox.Show("File '" & m.Groups(1).ToString & "' already exists." & vbNewLine & "Do you want to Overwrite existing file?", "Overwrite", MessageBoxButtons.YesNo) = DialogResult.Yes Then
w.WriteLine("y")
Else
w.WriteLine("n")
End If
End If
'RaiseEvent ConvertFinish(_Item.ID)
'proc.WaitForExit()
'proc.Close()
End If
Debug.Print(s)
If Not duration And Not current Then varIsSet = False Else varIsSet = True
End Sub
Private Function GetDuration(ByVal s As String) As Double
Dim m As Match = Regex.Match(s, "Duration: ((.*?), (.*))")
If m.Success Then
Dim duration As String = m.Groups(2).ToString
Return TimeSpan.Parse(duration).TotalSeconds
End If
Return Nothing
End Function
Private Function GetTime(ByVal s As String) As Double
Dim m As Match = Regex.Match(s, "(.*) time=(.*) bitrate")
If m.Success Then
Dim currentTime As String = m.Groups(2).ToString
Return TimeSpan.Parse(currentTime).TotalSeconds
End If
Return Nothing
End Function
Private Sub timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick
If varIsSet Then
Dim etr As TimeSpan = TimeSpan.FromSeconds(CInt(current / duration))
etr = New TimeSpan(etr.Hours, etr.Minutes, etr.Seconds)
RaiseEvent ProgressChange(_Item.ID, CInt((current / duration) * 100 * 100), etr)
End If
End Sub
End Class -
node.js ffmpeg spawn child_process unexpected data output and not possible to kill or stop
1er septembre 2021, par PLNR
I'm rather new to backend stuff, so please excuse, if my question is trivial.

For an Intranet project, I want to present a video element in a webpage (React, HLS.js Player) with the possibility reload the stream in case it hung.

The video sources are mpeg-ts streams delivered as udp multicast.

A small node.js / express server should handle the ffmpeg commands, to transcode the multicast to hls to display them in a browser.



My Problem is, that I am unable to stop the process...

I've tried to SIGINT, SIGTERM the process with it's pid, but the encoding is just going on.

Here is the code I wrote for transcoding so far :


const express = require("express");
const { spawn, exec } = require("child_process");
const cors = require("cors");
const process = require("process")

let ls;
let pid;

const app = express();

app.use(cors());

app.get('/cam/:source', (body) => {
 const cam = body.params.source;
 console.log(cam);

 let source = "udp://239.1.1.1:4444";
 let stream = "/var/www/html/streams/tmp/cam1.m3u8"


 stream = spawn("ffmpeg", ["-re", "-i", source, "-c:v", "libx264", "-crf", "21", "-preset", "veryfast", "-c:a", "aac", "-b:a", "128k", "-ac", "2", "-f", "hls", "-hls_list_size", "5", "-hls_flags", "delete_segments", stream], {detached: true});

 pid = stream.pid;

 stream.stdout.on("data", data => {
 console.log(`stdout: ${data}`);
 });

 stream.stderr.on("data", data => {
 console.log(`stderr: ${data}`);
 console.log("pid: ", pid);
 });

 stream.on("error", error => {
 console.log(`error: ${error.message}`);
 });

 stream.on("close", code => {
 console.log(`child process exited with code ${code}`);
 });
})

app.get('/cam/quit', () => {
 process.kill(pid, 'SIGINT')
})

app.listen(5000, ()=> {
 console.log('Listening');
})



On requesting the /cam/quit i would expect the process to stop... but it doesn't.

I've tried :

app.get('/cam/quit', () => {
 process.kill(pid, 'SIGINT')
})



app.get('/cam/quit', () => {
 process.kill(stream.pid, 'SIGINT')
})



app.get('/cam/quit', () => {
 stream.kill(pid, 'SIGINT')
})



app.get('/cam/quit', () => {
 stream.kill(0, 'SIGINT')
})



But none of this worked... do I miss something ? Is there something I need to change ?


Problem 2 - Output :

The output is emitted on stderr... even the process is working as expected.

This is maybe only cosmetics, but it makes me wondering.

Here is the terminal output :

[nodemon] starting `node server.js`
Listening
camera stream reloaded
stderr: ffmpeg version 4.3.2-0+deb11u1ubuntu1 Copyright (c) 2000-2021 the FFmpeg developers
 built with gcc 10 (Ubuntu 10.2.1-20ubuntu1)
 configuration: --prefix=/usr --extra-version=0+deb11u1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
 libavutil 56. 51.100 / 56. 51.100
 libavcodec 58. 91.100 / 58. 91.100
 libavformat 58. 45.100 / 58. 45.100
 libavdevice 58. 10.100 / 58. 10.100
 libavfilter 7. 85.100 / 7. 85.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 7.100 / 5. 7.100
 libswresample 3. 7.100 / 3. 7.100
 libpostproc 55. 7.100 / 55. 7.100

pid: 4206
stderr: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'udp://239.1.1.1':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 creation_time : 
pid: 4206
stderr: 1970-01-01T00:00:00.000000Z
 encoder : Lavf52.54.0
 Duration: 01:55:59.20, start: 0.000000, bitrate: 1436 kb/s
 Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x384 [SAR 1:1 DAR 15:8], 1272 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
 Metadata:
 creation_time : 1970-01-01T00:00:00.000000Z
 handler_name : VideoHandler
 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)
 Metadata:
 creation_time : 1970-01-01T00:00:00.000000Z
 handler_name : SoundHandler

pid: 4206
stderr: Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
 Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help

pid: 4206
stderr: [libx264 @ 0x5616b38b5440] using SAR=1/1

pid: 4206
stderr: [libx264 @ 0x5616b38b5440] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2

pid: 4206
stderr: [libx264 @ 0x5616b38b5440] profile High, level 3.0, 4:2:0, 8-bit

pid: 4206
stderr: [libx264 @ 0x5616b38b5440] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=21.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, hls, to '/var/www/html/streams/tmp/aft.m3u8':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf58.45.100
 Stream #0:0(und): Video: h264 (libx264), yuv420p, 720x384 [SAR 1:1 DAR 15:8], q=-1--1, 25 fps, 90k tbn, 25 tbc (default)
 Metadata:
 creation_time : 1970-01-01T00:00:00.000000Z
 handler_name : VideoHandler
 encoder : Lavc58.91.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
 Stream #0:1(und): Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s (default)
 Metadata:
 creation_time : 1970-01-01T00:00:00.000000Z
 handler_name : SoundHandler
 encoder : Lavc58.91.100 aac

pid: 4206
stderr: frame= 8 fps=0.0 q=0.0 size=N/A time=00:00:00.46 bitrate=N/A speed=0.931x 
pid: 4206
stderr: frame= 21 fps= 21 q=26.0 size=N/A time=00:00:00.96 bitrate=N/A speed=0.95x 
pid: 4206
stderr: frame= 33 fps= 22 q=26.0 size=N/A time=00:00:01.49 bitrate=N/A speed=0.982x 
pid: 4206
stderr: frame= 46 fps= 23 q=26.0 size=N/A time=00:00:02.00 bitrate=N/A speed=0.989x 
pid: 4206
stderr: frame= 58 fps= 23 q=26.0 size=N/A time=00:00:02.49 bitrate=N/A speed=0.986x 
pid: 4206



and so on...



Any help would be highly appreciated !

Many thanks in advance

-
pyqt5 gui dependent on ffmpeg compiled with pyinstaller doesn't run on other machines ?
19 octobre 2022, par SorenI am trying to create a simple Pyqt5 GUI for Windows 10 that uses OpenAI's model Whisper to transcribe a sound file and outputting the results in an Excel-file. It works on my own computer where I have installed the necessary dependencies for Whisper as stated on their github i.e. FFMEG. I provide a minimal example of my code below :


# Import library
import whisper
import os
from PyQt5 import QtCore, QtGui, QtWidgets
import pandas as pd
import xlsxwriter


class Ui_Dialog(QtWidgets.QDialog):
 
 
 # Define functions to use in GUI
 
 # Define function for selecting input files
 def browsefiles(self, Dialog):
 
 
 # Make Dialog box and save files into tuple of paths
 files = QtWidgets.QFileDialog().getOpenFileNames(self, "Select soundfiles", os.getcwd(), "lyd(*mp2 *.mp3 *.mp4 *.m4a *wma *wav)")
 
 self.liste = []
 for url in range(len(files[0])):
 self.liste.append(files[0][url]) 

 
 def model_load(self, Dialog):
 
 # Load picked model
 self.model = whisper.load_model(r'C:\Users\Søren\Downloads\Whisper_gui\models' + "\\" + self.combo_modelSize.currentText() + ".pt") ##the path is set to where the models are on the other machine
 
 
 def run(self, Dialog):
 
 # Make list for sound files
 liste_df = []
 
 
 # Running loop for interpreting and encoding sound files
 for url in range(len(self.liste)):
 
 # Make dataframe
 df = pd.DataFrame(columns=["filename", "start", "end", "text"])
 
 # Run model
 result = self.model.transcribe(self.liste[url])
 
 # Extract results
 for i in range(len(result["segments"])):
 start = result["segments"][i]["start"]
 end = result["segments"][i]["end"]
 text = result["segments"][i]["text"]
 
 df = df.append({"filename": self.liste[url].split("/")[-1],
 "start": start, 
 "end": end, 
 "text": text}, ignore_index=True)
 
 # Add detected language to dataframe
 df["sprog"] = result["language"]
 
 
 liste_df.append(df)
 
 
 
 # Make excel output
 
 # Concatenate list of dfs
 dataframe = pd.concat(liste_df)
 
 
 # Create a Pandas Excel writer using XlsxWriter as the engine.
 writer = pd.ExcelWriter(self.liste[0].split(".")[0] + '_OUTPUT.xlsx', engine='xlsxwriter')
 writer_wrap_format = writer.book.add_format({"text_wrap": True, 'num_format': '@'})


 # Write the dataframe data to XlsxWriter. Turn off the default header and
 # index and skip one row to allow us to insert a user defined header.
 dataframe.to_excel(writer, sheet_name="Output", startrow=1, header=False, index=False)

 # Get the xlsxwriter workbook and worksheet objects.
 #workbook = writer.book
 worksheet = writer.sheets["Output"]

 # Get the dimensions of the dataframe.
 (max_row, max_col) = dataframe.shape

 # Create a list of column headers, to use in add_table().
 column_settings = [{'header': column} for column in dataframe.columns]

 # Add the Excel table structure. Pandas will add the data.
 worksheet.add_table(0, 0, max_row, max_col - 1, {'columns': column_settings})

 # Make the columns wider for clarity.
 worksheet.set_column(0, max_col - 1, 12)
 
 in_col_no = xlsxwriter.utility.xl_col_to_name(dataframe.columns.get_loc("text"))
 
 worksheet.set_column(in_col_no + ":" + in_col_no, 30, writer_wrap_format)

 # Close the Pandas Excel writer and output the Excel file.
 writer.save()
 writer.close()
 
 
 ## Design setup
 
 def setupUi(self, Dialog):
 Dialog.setObjectName("Dialog")
 Dialog.resize(730, 400)
 
 self.select_files = QtWidgets.QPushButton(Dialog)
 self.select_files.setGeometry(QtCore.QRect(40, 62, 81, 31))
 font = QtGui.QFont()
 font.setPointSize(6)
 self.select_files.setFont(font)
 self.select_files.setObjectName("select_files")
 
 
 
 
 self.combo_modelSize = QtWidgets.QComboBox(Dialog)
 self.combo_modelSize.setGeometry(QtCore.QRect(40, 131, 100, 21))
 font = QtGui.QFont()
 font.setPointSize(6)
 self.combo_modelSize.setFont(font)
 self.combo_modelSize.setObjectName("combo_modelSize")
 
 
 self.runButton = QtWidgets.QPushButton(Dialog)
 self.runButton.setGeometry(QtCore.QRect(40, 289, 71, 21))
 font = QtGui.QFont()
 font.setPointSize(6)
 self.runButton.setFont(font)
 self.runButton.setObjectName("runButton")
 
 
 

 self.retranslateUi(Dialog)
 QtCore.QMetaObject.connectSlotsByName(Dialog)
 
 
 
 modelSize_options = ['Chose model', 'tiny', 'base', 'small', 'medium', 'large']
 self.combo_modelSize.addItems(modelSize_options)
 
 # Do an action!
 self.select_files.clicked.connect(self.browsefiles)
 self.combo_modelSize.currentIndexChanged.connect(self.model_load)
 self.runButton.clicked.connect(self.run)
 
 
 
 

 def retranslateUi(self, Dialog):
 _translate = QtCore.QCoreApplication.translate
 Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
 self.runButton.setText(_translate("Dialog", "Go!"))
 self.select_files.setText(_translate("Dialog", "Select"))


if __name__ == "__main__":
 import sys
 app = QtWidgets.QApplication(sys.argv)
 Dialog = QtWidgets.QDialog()
 ui = Ui_Dialog()
 ui.setupUi(Dialog)
 Dialog.show()
 sys.exit(app.exec_())



I compile this app with pyinstaller using the following code. I had some issues to begin with so I found other with similar problems and ended up with this :


pyinstaller --onedir --hidden-import=pytorch --collect-data torch --copy-metadata torch --copy-metadata tqdm --copy-metadata tokenizers --copy-metadata importlib_metadata --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree" --hidden-import="sklearn.tree._utils" --copy-metadata regex --copy-metadata requests --copy-metadata packaging --copy-metadata filelock --copy-metadata numpy --add-data "./ffmpeg/*;./ffmpeg/" --hidden-import=whisper --copy-metadata whisper --collect-data whisper minimal_example_whisper.py


When I take the outputtet dist directory and try to run the app on another Windows machine without FFMPEG installed (or Whisper or any other things), I get the following error from the terminal as I push the "run" button in the app (otherwise the app does run).


C:\Users\Søren>"G:\minimal_example_whisper\minimal_example_whisper.exe"
whisper\transcribe.py:70: UserWarning: FP16 is not supported on CPU; using FP32 instead
Traceback (most recent call last):
 File "minimal_example_whisper.py", line 45, in run
 File "whisper\transcribe.py", line 76, in transcribe
 File "whisper\audio.py", line 111, in log_mel_spectrogram
 File "whisper\audio.py", line 42, in load_audio
 File "ffmpeg\_run.py", line 313, in run
 File "ffmpeg\_run.py", line 284, in run_async
 File "subprocess.py", line 951, in __init__
 File "subprocess.py", line 1420, in _execute_child
FileNotFoundError: [WinError 2] Den angivne fil blev ikke fundet



I suspect this has something to do with FFMPEG not being installed on the other machines system ? Does anyone have an automatic solution for this when compiling the app or can it simply only run on machines that has FFMPEG installed ?


Thanks in advance !