
Recherche avancée
Autres articles (58)
-
Participer à sa traduction
10 avril 2011Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
Actuellement MediaSPIP n’est disponible qu’en français et (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Les statuts des instances de mutualisation
13 mars 2010, parPour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...)
Sur d’autres sites (9123)
-
My python script using ffmpeg captures video content, but the captured content freezes in the middle and jumps frames
11 novembre 2022, par Supriyo MitraI am new to ffmpeg and I am trying to use it through a python script. The python functions that captures the video content is given below. The problem I am facing is that the captured content freezes at (uneven) intervals and skips a few frames every time it happens.


` def capturelivestream(self, argslist):
 streamurl, outnum, feedid, outfilename = argslist[0], argslist[1], argslist[2], argslist[3]
 try:
 info = ffmpeg.probe(streamurl, select_streams='a')
 streams = info.get('streams', [])
 except:
 streams = []
 if len(streams) == 0:
 print('There are no streams available')
 stream = {}
 else:
 stream = streams[0]
 for stream in streams:
 if stream.get('codec_type') != 'audio':
 continue
 else:
 break
 if 'channels' in stream.keys():
 channels = stream['channels']
 samplerate = float(stream['sample_rate'])
 else:
 channels = None
 samplerate = 44100
 process = ffmpeg.input(streamurl).output('pipe:', pix_fmt='yuv420p', format='avi', vcodec='libx264', acodec='pcm_s16le', ac=channels, ar=samplerate, vsync=0, loglevel='quiet').run_async(pipe_stdout=True)
 fpath = os.path.dirname(outfilename)
 fnamefext = os.path.basename(outfilename)
 fname = fnamefext.split(".")[0]
 read_size = 320 * 180 * 3 # This is width * height * 3
 lastcaptured = time.time()
 maxtries = 12
 ntries = 0
 while True:
 if process:
 inbytes = process.stdout.read(read_size)
 if inbytes is not None and inbytes.__len__() > 0:
 try:
 frame = (np.frombuffer(inbytes, np.uint8).reshape([180, 320, 3]))
 except:
 print("Failed to reshape frame: %s"%sys.exc_info()[1].__str__())
 continue # This could be an issue if there is a continuous supply of frames that cannot be reshaped
 self.processq.put([outnum, frame])
 lastcaptured = time.time()
 ntries = 0
 else:
 if self.DEBUG:
 print("Could not read frame for feed ID %s"%feedid)
 t = time.time()
 if t - lastcaptured > 30: # If the frames can't be read for more than 30 seconds...
 print("Reopening feed identified by feed ID %s"%feedid)
 process = ffmpeg.input(streamurl).output('pipe:', pix_fmt='yuv420p', format='avi', vcodec='libx264', acodec='pcm_s16le', ac=channels, ar=samplerate, vsync=0, loglevel='quiet').run_async(pipe_stdout=True)
 ntries += 1
 if ntries > maxtries:
 if self.DEBUG:
 print("Stream %s is no longer available."%streamurl)
 # DB statements removed here
 
 break # Break out of infinite loop.
 continue
 
 return None`




The function that captures the frames is as follows :



` def framewriter(self, outlist):
 isempty = False
 endofrun = False
 while True:
 frame = None
 try:
 args = self.processq.get()
 except: # Sometimes, the program crashes at this point due to lack of memory...
 print("Error in framewriter while reading from queue: %s"%sys.exc_info()[1].__str__())
 continue
 outnum = args[0]
 frame = args[1]
 if outlist.__len__() > outnum:
 out = outlist[outnum]
 else:
 if self.DEBUG == 2:
 print("Could not get writer %s"%outnum)
 continue
 if frame is not None and out is not None:
 out.write(frame)
 isempty = False
 endofrun = False
 else:
 if self.processq.empty() and not isempty:
 isempty = True
 elif self.processq.empty() and isempty: # processq queue is empty now and was empty last time
 print("processq is empty")
 endofrun = True
 elif endofrun and isempty:
 print("Could not find any frames to process. Quitting")
 break
 print("Done writing feeds. Quitting.")
 return None`



The scenario is as follows : There are multiple video streams from a certain website at any time during the day, and the program containing these functions has to capture them as they get streamed. The memory available to this program is 6GB and there could be upto 3 streams running at any instant. Given below is the relevant main section of the script that uses the functions given above.






`itftennis = VideoBot(siteurl)
outlist = []
t = Thread(target=itftennis.framewriter, args=(outlist,))
t.daemon = True
t.start()
tp = Thread(target=handleprocesstermination, args=())
tp.daemon = True
tp.start()
# Create a database connection and as associated cursor object. We will handle database operations from main thread only.
# DB statements removed from here...
feedidlist = []
vidsdict = {}
streampattern = re.compile("\?vid=(\d+)$")
while True:
 streampageurls = itftennis.checkforlivestream()
 if itftennis.DEBUG:
 print("Checking for new urls...")
 print(streampageurls.__len__())
 if streampageurls.__len__() > 0:
 argslist = []
 newurlscount = 0
 for streampageurl in streampageurls:
 newstream = False
 sps = re.search(streampattern, streampageurl)
 if sps:
 streamnum = sps.groups()[0]
 if streamnum not in vidsdict.keys(): # Check if this stream has already been processed.
 vidsdict[streamnum] = 1
 newstream = True
 else:
 continue
 else:
 continue
 print("Detected new live stream... Getting it.")
 streamurl = itftennis.getstreamurlfrompage(streampageurl)
 print("Adding %s to list..."%streamurl)
 if streamurl is not None:
 # Now, get feed metadata...
 metadata = itftennis.getfeedmetadata(streampageurl)
 if metadata is None:
 continue
 # lines to get matchescounter omitted here...
 if matchescounter >= itftennis.__class__.MAX_CONCURRENT_MATCHES:
 break
 if newstream is True:
 newurlscount += 1
 outfilename = time.strftime("./videodump/" + "%Y%m%d%H%M%S",time.localtime())+".avi"
 out = open(outfilename, "wb")
 outlist.append(out) # Save it in the list and take down the number for usage in framewriter
 outnum = outlist.__len__() - 1
 # Save metadata in DB
 # lines omitted here....
 argslist.append([streamurl, outnum, feedid, outfilename]) 
 else:
 print("Couldn't get the stream url from page")
 if newurlscount > 0:
 for args in argslist:
 try:
 p = Process(target=itftennis.capturelivestream, args=(args,))
 p.start()
 processeslist.append(p)
 if itftennis.DEBUG:
 print("Started process with args %s"%args)
 except:
 print("Could not start process due to error: %s"%sys.exc_info()[1].__str__())
 print("Created processes, continuing now...")
 continue
 time.sleep(itftennis.livestreamcheckinterval)
t.join()
tp.join()
for out in outlist:
 out.close()`







Please accept my apologies for swamping with this amount of code. I wanted to provide maximum context to my problem. I have removed the absolutely irrelevant DB statements, but apart from that this is what the code looks like.


If you need to know anything else about the code, please let me know. What I would really like to know is if I am using the ffmpeg streams capturing statements correctly. The stream contains both video and audio components and I need to capture both. Hence I am making the following call :


process = ffmpeg.input(streamurl).output('pipe:', pix_fmt='yuv420p', format='avi', vcodec='libx264', acodec='pcm_s16le', ac=channels, ar=samplerate, vsync=0, loglevel='quiet').run_async(pipe_stdout=True)



Is this how it is supposed to be done ? More importantly, why do I keep getting the freezes in the output video. I have monitored the streams manually, and they are quite consistent. Frame losses do not happen when I view them on the website (at least it is not obviously noticeable). Also, I have run 'top' command on the host running the program. The CPU usage sometimes go over 100% (which, I came to understand from some answers on SO, is to be expected when running ffmpeg) but the memory usage usually remain below 30%. So what is the issue here. What do I need to do in order to fix this problem (other than learn more about how ffmpeg works).


Thanks


I have tried using various ffmpeg options (while trying to find similar issues that others encountered). I also tried running ffmpeg from command line for a limited period of time (11 mins), using the same options as used in the python code, and the captured content came out quite well. No freezes. No jumps in frames. But I need to use it in an automated way and there would be multiple streams at any time. Also, when I try playing the captured content using ffplay, I sometimes get the message "co located POCs unavailable" when these freezes happen. What does it mean ?


-
avcodec/vp8 : Do not use num_coeff_partitions in thread/buffer setup
30 septembre 2015, par Michael Niedermayeravcodec/vp8 : Do not use num_coeff_partitions in thread/buffer setup
The variable is not a constant and can lead to race conditions
Fixes : repro.webm (not reproducable with FFmpeg alone)
Found-by : Dale Curtis <dalecurtis@google.com>
Tested-by : Dale Curtis <dalecurtis@google.com>
Signed-off-by : Michael Niedermayer <michael@niedermayer.cc> -
Fatal error detected by JRE : libavcodec involved
16 novembre 2015, par hdfI’m experiencing this issue whenever I’m trying to run my java program. Could someone give me a clues on how to fix it ?
EDIT : the issue only occurs after a new environment has been set up.
#
# A fatal error has been detected by the Java Runtime Environment:
#
#
#
# JRE version: OpenJDK Runtime Environment (7.0_85-b01) (build 1.7.0_85-b01)
# Java VM: OpenJDK 64-Bit Server VM (24.85-b03 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 2.6.1
# Distribution: Ubuntu 14.04 LTS, package 7u85-2.6.1-5ubuntu0.14.04.1
# Problematic frame:
# C [libavcodec.so.52.123.0+0x442060]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
# http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- T H R E A D ---------------
Current thread (0x00007f8f70141800): JavaThread "threadpool-14" daemon [_thread_in_native, id=14508, stack(0x00007f8fa73a0000,0x00007f8fa74a1000)]
siginfo:si_signo=SIGSEGV: si_errno=0, si_code=128 (), si_addr=0x0000000000000000
Registers:
RAX=0x00007f8f701d2110, RBX=0x00007f8fa65030d0, RCX=0x00007f8fa688efd0, RDX=0x00007f8fa68904b0
RSP=0x00007f8fa749f380, RBP=0x00007f8fa749f3d8, RSI=0x000000000000000c, RDI=0x00007f8f701d2110
R8 =0x0000000000000000, R9 =0x0000000000000000, R10=0x00007f8fc5eb56e0, R11=0x00007f8fc591af50
R12=0x0000000000000000, R13=0x00007f8f701419d8, R14=0x00007f8fa749f578, R15=0x00007f8f70141800
RIP=0x00007f8fa688f060, EFLAGS=0x0000000000010202, CSGSFS=0x0000000000000033, ERR=0x0000000000000000
TRAPNO=0x000000000000000d
Top of Stack: (sp=0x00007f8fa749f380)
0x00007f8fa749f380: 00007f8fa688f1a5 00007f8fa688ffe5
0x00007f8fa749f390: 00007f8fa6890025 00007f8fa6890065
0x00007f8fa749f3a0: 00007f8fa68900a5 00007f8fa68900e5
0x00007f8fa749f3b0: 00007f8fa6890125 00007f8fa68904b5
0x00007f8fa749f3c0: 00007f8fa6890678 00007f8fa7198f31
0x00007f8fa749f3d0: 0000000000000000 00007f8f70158540
0x00007f8fa749f3e0: 00007f8fa749f468 00007f8fa71966ae
0x00007f8fa749f3f0: 0000000776cfa560 0000000776cfa560...
Instructions: (pc=0x00007f8fa688f060)
0x00007f8fa688f040: c4 e3 5d 0c c0 55 c5 e4 5c c8 c5 e4 58 c0 c5 fc
0x00007f8fa688f050: 29 07 c5 fc 29 4f 20 c3 0f 1f 84 00 00 00 00 00
0x00007f8fa688f060: c5 fc 28 57 40 c5 fc 28 5f 60 c5 ec 5c fb c5 ec
0x00007f8fa688f070: 58 d3 c5 c4 57 3d 26 e0 13 00 c5 ec c6 df be c5
Register to memory mapping:
RAX=0x00007f8f701d2110 is an unknown value
RBX=0x00007f8fa65030d0: av_fft_calc+0 in /usr/local/lib/libavcodec.so.52.123.0 at 0x00007f8fa644d000
RCX=0x00007f8fa688efd0: <offset 0x441fd0="0x441fd0"> in /usr/local/lib/libavcodec.so.52.123.0 at 0x00007f8fa644d000
RDX=0x00007f8fa68904b0: <offset 0x4434b0="0x4434b0"> in /usr/local/lib/libavcodec.so.52.123.0 at 0x00007f8fa644d000
RSP=0x00007f8fa749f380 is pointing into the stack for thread: 0x00007f8f70141800
RBP=0x00007f8fa749f3d8 is pointing into the stack for thread: 0x00007f8f70141800
RSI=0x000000000000000c is an unknown value
RDI=0x00007f8f701d2110 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x0000000000000000 is an unknown value
R10=0x00007f8fc5eb56e0: <offset 0xe006e0="0xe006e0"> in /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so at 0x00007f8fc50b5000
R11=0x00007f8fc591af50: <offset 0x865f50="0x865f50"> in /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so at 0x00007f8fc50b5000
R12=0x0000000000000000 is an unknown value
R13=0x00007f8f701419d8 is an unknown value
R14=0x00007f8fa749f578 is pointing into the stack for thread: 0x00007f8f70141800
R15=0x00007f8f70141800 is a thread
Stack: [0x00007f8fa73a0000,0x00007f8fa74a1000], sp=0x00007f8fa749f380, free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libavcodec.so.52.123.0+0x442060]
</offset></offset></offset></offset>This occurs on different physical instances so chances are pretty low it’s hardware issue. Thanks !