
Recherche avancée
Autres articles (61)
-
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 ;
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Soumettre améliorations et plugins supplémentaires
10 avril 2011Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)
Sur d’autres sites (11030)
-
Python-FFMPEG Corruption Problems
11 juillet 2023, par Gabriel Ruben GuzmanI'm repurposing some python code to generate gifs/mp4s showcasing nba player movements dot form. (With the 'frames' used in the gifs being generated by matplotlib).


The repo comes with two different functions for generating the gifs, watch_play and animate_play. Both of which use python command line functionalities to run ffmpeg and generate the mp4s.
I've been able to use the watch_play succesfully, bot every time I try using animate_play, which according to the documention is meant to be significantly faster than watch play, I run into the error showcased here.(I printed the cmd string being passed into the pipe, in the hopes it would make debugging easier)


I've tried generating gifs/mp4s of various size and added a decent bit of code to lessen the volume of data being processed. (I'm essentially repurposing the code just to generate clips, so I've been able to remove a lot of the pbp/tracking data logs to speed up the run time) But no matter what I've done, gotten some variation of the screenshotted error.


pipe: : corrupt input packet in stream 0
[rawvideo @ 0x55ccc0e2bb80] Invalid buffer size, packet size 691200 < expected frame_size 921600
Error while decoding stream #0:0 : Invalid argument


The code for animate_play


def animate_play(self, game_time=None, length=None, highlight_player=None,
 commentary=True, show_spacing=None):
 """
 Method for animating plays in game.
 Outputs video file of play in {cwd}/temp.
 Individual frames are streamed directly to ffmpeg without writing them
 to the disk, which is a great speed improvement over watch_play

 Args:
 game_time (int): time in game to start video
 (seconds into the game).
 Currently game_time can also be an tuple of length two
 with (starting_frame, ending_frame)if you want to
 watch a play using frames instead of game time.
 length (int): length of play to watch (seconds)
 highlight_player (str): If not None, video will highlight
 the circle of the inputed player for easy tracking.
 commentary (bool): Whether to include play-by-play commentary in
 the animation
 show_spacing (str) in ['home', 'away']: show convex hull
 spacing of home or away team.
 If None, does not show spacing.

 Returns: an instance of self, and outputs video file of play
 """
 if type(game_time) == tuple:
 starting_frame = game_time[0]
 ending_frame = game_time[1]
 else:
 game_time= self.start +(self.quarter*720)
 end_time= self.end +(self.quarter*720)
 length = end_time-game_time
 # Get starting and ending frame from requested 
 # game_time and length
 print('hit')
 print(len(self.moments))
 print(game_time)
 print(end_time)
 print(length)
 print(game_time+length)
 
 print(self.moments.game_time.min())
 print(self.moments.game_time.max())

 sys.exit()
 starting_frame = self.moments[self.moments.game_time.round() ==
 game_time].index.values[0]
 ending_frame = self.moments[self.moments.game_time.round() ==
 game_time + length].index.values[0]

 # Make video of each frame
 filename = "./temp/{game_time}.mp4".format(game_time=game_time)
 if commentary:
 size = (960, 960)
 else:
 size = (480, 480)
 cmdstring = ('ffmpeg',
 '-y', '-r', '20', # fps
 '-s', '%dx%d' % size, # size of image string
 '-pix_fmt', 'argb', # Stream argb data from matplotlib
 '-f', 'rawvideo','-i', '-',
 '-vcodec', 'libx264', filename)
 #print(pipe)
 #print(cmdstring)
 
 

 # Stream plots to pipe
 pipe = Popen(cmdstring, stdin=PIPE)
 print(cmdstring)
 for frame in range(starting_frame, ending_frame):
 print(frame)
 self.plot_frame(frame, highlight_player=highlight_player,
 commentary=commentary, show_spacing=show_spacing,
 pipe=pipe)
 print(cmdstring)
 pipe.stdin.close()
 pipe.wait()
 return self



The code for watch play


def watch_play(self, game_time=None, length=None, highlight_player=None,
 commentary=True, show_spacing=None):

 """
 DEPRECIATED. See animate_play() for similar (fastere) method

 Method for viewing plays in game.
 Outputs video file of play in {cwd}/temp

 Args:
 game_time (int): time in game to start video
 (seconds into the game).
 Currently game_time can also be an tuple of length
 two with (starting_frame, ending_frame) if you want
 to watch a play using frames instead of game time.
 length (int): length of play to watch (seconds)
 highlight_player (str): If not None, video will highlight
 the circle of the inputed player for easy tracking.
 commentary (bool): Whether to include play-by-play
 commentary underneath video
 show_spacing (str in ['home', 'away']): show convex hull
 of home or away team.
 if None, does not display any convex hull

 Returns: an instance of self, and outputs video file of play
 """
 print('hit this point ')
 warnings.warn(("watch_play is extremely slow. "
 "Use animate_play for similar functionality, "
 "but greater efficiency"))

 if type(game_time) == tuple:
 starting_frame = game_time[0]
 ending_frame = game_time[1]
 else:
 # Get starting and ending frame from requested game_time and length
 game_time= self.start +(self.quarter*720)
 end_time= self.end +(self.quarter*720)
 length = end_time-game_time


 starting_frame = self.moments[self.moments.game_time.round() ==
 game_time].index.values[0]
 ending_frame = self.moments[self.moments.game_time.round() ==
 game_time + length].index.values[0]
 #print(self.moments.head(2))
 #print(starting_frame)
 #print(ending_frame)
 print(len(self.moments))
 # Make video of each frame
 title = str(starting_frame)+'-'+str(ending_frame)
 for frame in range(starting_frame, ending_frame):
 print(frame)
 self.plot_frame(frame, highlight_player=highlight_player,
 commentary=commentary, show_spacing=show_spacing)
 command = ('ffmpeg -framerate 20 -start_number {starting_frame} '
 '-i %d.png -c:v libx264 -r 30 -pix_fmt yuv420p -vf '
 '"scale=trunc(iw/2)*2:trunc(ih/2)*2" {title}'
 '.mp4').format(starting_frame=starting_frame,title=title)
 os.chdir('temp')
 os.system(command)
 os.chdir('..')

 # Delete images
 for file in os.listdir('./temp'):
 if os.path.splitext(file)[1] == '.png':
 os.remove('./temp/{file}'.format(file=file))

 return self'



-
ffmpeg on android exception
25 avril 2017, par Yuriy AizenbergI want to create project with two parts :
- RTSP local stream
- RTSP local player
I use next library ffmpeg
At first, initialize ffmpeg :
private void runFFMPEG() {
fFmpeg = FFmpeg.getInstance(this);
try {
fFmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
@Override
public void onFailure() {
new Long(1);
}
@Override
public void onSuccess() {
new Long(1);
}
@Override
public void onStart() {
new Long(1);
}
@Override
public void onFinish() {
play();
}
});
} catch (FFmpegNotSupportedException e) {
e.printStackTrace();
}Next call method play :
private void play() {
String ip = "10.10.0.2";
Uri parse = Uri.parse("rtsp://" + ip);
LibVLC libVLC = new LibVLC(TheApplication.getInstance());
MediaPlayer mediaPlayer = new MediaPlayer(libVLC);
mediaPlayer.setMedia(new Media(libVLC, parse));
mediaPlayer.play();
mediaPlayer.setEventListener(new MediaPlayer.EventListener() {
@Override
public void onEvent(MediaPlayer.Event event) {
new Long(1);
}
});
try {
fFmpeg.execute(new String[]{"ffmpeg -re -stream_loop -1 -i /storage/emulated/0/akgld-c8mxm.opus -acodec libopus -ac 1 -ab 96k -vn -f rtsp rtsp://" + ip + ":5545"}, new FFmpegExecuteResponseHandler() {
@Override
public void onSuccess(String message) {
new Long(1);
}
@Override
public void onProgress(String message) {
new Long(1);
}
@Override
public void onFailure(String message) {
new Long(1);
}
@Override
public void onStart() {
}
@Override
public void onFinish() {
new Long(1);
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
}But raise onFailure with next argument
ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[NULL @ 0xf741a000] Unable to find a suitable output format for 'ffmpeg -re -stream_loop -1 -i /storage/emulated/0/akgld-c8mxm.opus -acodec libopus -ac 1 -ab 96k -vn -f rtsp rtsp://10.10.0.2:5545'
ffmpeg -re -stream_loop -1 -i /storage/emulated/0/akgld-c8mxm.opus -acodec libopus -ac 1 -ab 96k -vn -f rtsp rtsp://10.10.0.2:5545: Invalid argumentWhat im doing wrong ? Maybe exists more easier ways to resolve this task ? Thanks.
-
Connect FFServer multiple instances
3 mars 2020, par absentioI am trying to deploy FFServer on Kubernetes and try to use the power of distributed systems.
It’s the first time I am using both and so I am a bit confused.
Got my Kubernetes setup working on my bare metal server, LoadBalancer and CNI are working flawlessly. I then created an FFServer deployment and a FFServer service. Then I made an NFS storage to share ffserver.conf and feed files, but there is something strange happening.All my ffserver k8s pods load the ffserver.conf file with not problem, then when I start to stream using ffmpeg the loadbalancer gives my stream to one of my server(i’ll call it pod1). The problem is that I can get the stream played if connecting directly to pod1 but will not work if i try to get it from pod2 although pod2 could read the feed.ffm written from pod1.
NFS storage is setup with ReadWriteMany. How could I get it to work ? Is there any way to use multiple ffserver without having to ffmpeg to all of them one by one ?