
Recherche avancée
Autres articles (104)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur
8 février 2011, parLa visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
Configuration de la boite multimédia
Dès (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
Sur d’autres sites (11606)
-
Popen ffmpeg process hang if run in shell and leaves a defunct process if run in background
12 janvier 2023, par dr__noobI have a script that runs the FFmpeg command. When I run the command in the background using the
&
operator it runs fine but leaves a zombie process. And when I remove the operator the process hangs and goes into thepipe_wait
state.

The code used to execute the FFmpeg command


def run_cmd(cmd:str,
 check:bool=False, 
 capture:bool=False,
 timeout:float=None,
 ) -> tuple[int,bytearray,bytearray]:
 import subprocess

 stdout_data,stderr_data = (bytearray(),bytearray()) if capture else (None,None)
 try:
 sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, )
 while any(data:=(sp.stdout.readline(),sp.stderr.readline())):
 out,err = data
 if out: stdout_data += out
 if err: stderr_data += err
 sp.communicate(timeout=timeout)
 return sp.returncode,stdout_data,stderr_data
 except subprocess.CalledProcessError as e:
 print("Called process error")
 raise e
 except subprocess.TimeoutExpired as e:
 sp.kill()
 print(f"{sp.pid} killed")
 if check:
 raise e
 except PermissionError as e:
 print("Permission error")
 if check:
 raise e



The command which is causing the issue is


nice -n 10 ffmpeg -loglevel verbose -hide_banner -y -threads 0 -i "/dev/shm/480TEST-1999963.dfw.480_1673030704/SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p.intermediate.mp4" -map 0:v:0? -q:v 1 -f rawvideo -pix_fmt "yuv420p" -an ./SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p_fifo_video.yuv -map 0:a:0? -q:a 1 -ac 2 -af "aresample=async=1:first_pts=0" -vn ./SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p_fifo_audio.wav > "./SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p.ffmpeg.demux.log" 2>&1 &



However, other FFmpeg commands are running fine without the last
&
. But this command will block if I remove the&
. If I keep it as it is, the process will later become a zombie(defunct). Can it be because it is actually anice -n 10
causing the issue ?

Example of a command running fine


ffmpeg -loglevel verbose -hide_banner -y -threads 0 -i "./SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p.ts" -r "59.94" -s:v "1280"x"720" -pix_fmt "yuv420p" -vcodec libx264 -x264-params qp="30" -af "aresample=async=1:first_pts=0" -crf 0 -q:a 1 -vf yadif=1 ./SBS_Plus_Test_Feed.480TEST-1999963.480.eng.p.intermediate.mp4 > "./p.intermediate.mp4.intermediate.ffmpeg.log" 2>&1



Till now I have tried other options like
-nostdin
andnull
suggested in ffmpeg hangs when run in background

Is there any other way run this without creating a zombie ?


-
How to gracefully terminate ffmpeg process alongside with ffprobe process ?
26 mars 2023, par duruburakI was able to terminate ffmpeg process gracefully when it's the only ongoing process. Now I also have ffprobe process alongside with ffmpeg process that tracks the progress of the ffmpeg process. It throws the following exception when I try to cancel the process. I tried to put the statements inside try & except blocks but I don't think it's a good solution. What's the proper way to achieve this job ?


P.S. The code might be a bit confusing, but I tried to create a small executable form out of my actual code, sorry about that.


import subprocess as sp
import shlex
import json
import time
import threading

def start_ffmpeg_thread(audio_part, video_part, path):

 global ffmpeg_process
 if (ffmpeg_process is None) or ffmpeg_process.poll():
 data = sp.run(shlex.split(f'ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 -of json "{video_part}"'), stdout=sp.PIPE).stdout
 dict = json.loads(data)
 tot_n_frames = float(dict['streams'][0]['nb_read_packets'])

 ffmpeg_process = sp.Popen(shlex.split(f'ffmpeg -y -loglevel error -i "{video_part}" -i "{audio_part}" -progress pipe:1 "{path}"'), stdout=sp.PIPE, stdin=sp.PIPE)

 q = [0]

 ffmpeg_progress_reader_thread = threading.Thread(target=ffmpeg_progress_reader, args=(ffmpeg_process, q))
 ffmpeg_progress_reader_thread.start()

 while True:
 if ffmpeg_process.poll() is not None:
 break

 n_frame = q[0]
 progress_percent = (n_frame/tot_n_frames)*100
 print(f"Progress: [%] {progress_percent}", end="\r")
 ffmpeg_progress_reader_thread.join()

def ffmpeg_progress_reader(procs, q):

 while True:
 if procs.poll() is not None:
 break

 progress_text = procs.stdout.readline()
 progress_text = progress_text.decode("utf-8")
 if progress_text.startswith("frame="):
 frame = int(progress_text.partition('=')[-1])
 q[0] = frame

def cancel_ffmpeg():

 time.sleep(10)
 global ffmpeg_process
 if (ffmpeg_process is not None) and (ffmpeg_process.poll() is None):
 ffmpeg_process.stdin.write('q'.encode("GBK"))
 ffmpeg_process.communicate()
 ffmpeg_process.wait()
 ffmpeg_process = None


ffmpeg_process = None

threading.Thread(target=cancel_ffmpeg).start()
start_ffmpeg_thread(<>, <>, <>)



Exception in thread Thread-2 (ffmpeg_progress_reader):
Traceback (most recent call last):
 File "D:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
 self.run()9.354796147248976
 File "D:\Python311\Lib\threading.py", line 975, in run
 self._target(*self._args, **self._kwargs)
 File "d:\Python Projects\main.py", line 82, in ffmpeg_progress_reader
 progress_text = procs.stdout.readline()
 ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL
Traceback (most recent call last):
 File "d:\Python Projects\main.py", line 101, in <module>
 start_ffmpeg_thread("aud.mp3", "vid.mp4", "output.mp4")
 File "d:\Python Projects\main.py", line 69, in start_ffmpeg_thread
 if ffmpeg_process.poll() is not None:
 ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'poll'
</module>


-
Revision 71554 : Google buzz ne fonctionne plus Désolé, Google Reader n’accepte plus le ...
4 avril 2013, par kent1@… — LogGoogle buzz ne fonctionne plus
Désolé, Google Reader n’accepte plus le favori intelligent "Noter dans Google Reader".