
Recherche avancée
Autres articles (66)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...) -
Librairies et binaires spécifiques au traitement vidéo et sonore
31 janvier 2010, parLes logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
Binaires complémentaires et facultatifs flvtool2 : (...)
Sur d’autres sites (9861)
-
Cancelling ffpeg launched as a C# process
22 avril 2016, par DarwinIcesurferI’m launching ffmpeg in a c# process to encode a video. In a command window, ffmpeg can be interrupted by pressing CTRL-C. I have tried to achieve the same effect by closing the process, however ffmpeg does not appear to close (it is still visible in task manager and it does not release the handle on the file it was encoding)
How can ffmpeg be interrupted programatically ?
static Process proc;
static BackgroundWorker bw;
public void EncodeVideoWithProgress(string filename, string arguments, BackgroundWorker worker, DoWorkEventArgs e)
{
proc = new Process();
// assign the backgroud worker to a class member variable so all function within the class will have access
bw = worker;
proc.StartInfo.FileName = "ffmpeg";
proc.StartInfo.Arguments = "-i " + " \"" + filename + "\" " + arguments;
proc.StartInfo.UseShellExecute = false;
proc.EnableRaisingEvents = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.CreateNoWindow = true;
proc.ErrorDataReceived += new DataReceivedEventHandler(NetErrorDataHandler);
proc.Start();
proc.BeginErrorReadLine();
proc.WaitForExit();
}
private static void NetErrorDataHandler(object sendingProcess,
DataReceivedEventArgs errLine)
{
if (bw.CancellationPending)
{
proc.CloseMainWindow();
proc.Close();
}
else
{
// do other tasks
}
} -
Using C# and ffmpeg to rip audio from an .mp4, ffmpeg stuck until closing the calling application
19 juillet 2018, par user3806186I happened to find this answer :
https://stackoverflow.com/questions/44981454/c-sharp-extract-mp3-file-from-mp4-file#=And it seems to work, However, the conversion process gets stuck, and it only resumes after I have closed the application that called ffmpeg to run.
The following code is responsible for the launch of ffmpeg :
(The commented lines are just from testing on how to fix the hanging)public static string ConvertToMp3(string inputFile, string outputFile = "extracted_audio.mp3")
{
Console.WriteLine("Converting mp3 to " + Path.GetFullPath("extracted_audio.mp3"));
string mp3out = "";
try
{
if (ffmpegProcess != null)
ffmpegProcess.Kill();
ffmpegProcess = new Process();
ffmpegProcess.StartInfo.UseShellExecute = false;
ffmpegProcess.StartInfo.RedirectStandardInput = true;
ffmpegProcess.StartInfo.RedirectStandardOutput = true;
ffmpegProcess.StartInfo.RedirectStandardError = true;
ffmpegProcess.StartInfo.CreateNoWindow = true;
ffmpegProcess.StartInfo.FileName = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + @"\bin\ffmpeg.exe";
ffmpegProcess.StartInfo.Arguments = "-i " + Path.GetFullPath(inputFile) + " -vn -f mp3 -ab 320k output " + Path.GetFullPath(outputFile);
ffmpegProcess.Start();
ffmpegProcess.StandardOutput.ReadToEnd();
mp3out = ffmpegProcess.StandardError.ReadToEnd();
//ffmpegProcess.WaitForExit();
if (!ffmpegProcess.HasExited)
{
//ffmpegProcess.Kill();
}
}
catch (InvalidOperationException e)
{
Console.WriteLine("mp3 conversion failed: " + e.Message);
return "";
}
return mp3out;
}I have no idea what causes the halting, any ideas ?
-
Allowing downloads of partial video files from Django
18 janvier 2019, par DataVisI have a Django app that allows users to make/save ’clips’ of video files, that is keep timestamps of start and end times of video files to save in playlists. I would like users to be able to download clips (and playlists as well) they have saved.
I have done quite a bit of research on the topic and have gotten ffmpeg working from my terminal to save partial clips (though I’ve struggled to figure out pathnames for using subprocess.call with ffmpeg), and I have also gotten moviepy working via the terminal to save partial clips.
I’m struggling to figure out how to incorporate this into my Django app so that users can click a link and subsequently begin a download of a specific clip (or playlist). I believe I will want to use celery to avoid tying up the server but I’m not even to the point where I can offload a task as I can’t figure out how to :
- ’Clip’ the original, longer video file to make it shorter (do I need to make a local copy of a new file first ?).
- Send a response as a download to the user.
Here is my models.py :
class Match(models.Model):
game_id = models.IntegerField(primary_key=True,
validators=[MinValueValidator(1)],db_column="game_id")
wide = models.FileField(upload_to='games/2018/',blank=True,null=True)
class Playlist(models.Model):
name = models.CharField(default='',null=True,blank=True,max_length=200)
created_by = models.ForeignKey(User,related_name="playlists",on_delete=models.CASCADE)
created = models.DateTimeField(editable=False)
modified = models.DateTimeField()
def save(self, *args, **kwargs):
''' On save, update timestamps '''
if not self.id:
entries = Playlist.objects.order_by('-id')
try:
self.id = entries[0].id + 1
except IndexError:
# we don't have any PlaylistEntries yet, so we just start @ 0
self.id = 0
self.created = timezone.now()
self.modified = timezone.now()
return super(Playlist, self).save(*args, **kwargs)
class Clip(models.Model):
name = models.CharField(default='',null=True,blank=True,max_length=200)
game_id = models.ForeignKey(Match,related_name="clips",on_delete=models.CASCADE,
db_column="game_id",null=True,blank=True)
clipstart = models.IntegerField(null=True,blank=True)
clipend = models.IntegerField(null=True,blank=True)
playlist = models.ForeignKey(Playlist,related_name="clips",on_delete=models.CASCADE,
db_column="playlist",null=True,blank=True)
created_by = models.ForeignKey(User,related_name="clips",on_delete=models.CASCADE)
created = models.DateTimeField(editable=False)
modified = models.DateTimeField()
duration = models.IntegerField(null=True,blank=True)
def save(self, *args, **kwargs):
''' On save, update timestamps '''
if not self.id:
entries = Clip.objects.order_by('-id')
try:
self.id = entries[0].id + 1
except IndexError:
# we don't have any PlaylistEntries yet, so we just start @ 0
self.id = 0
self.created = timezone.now()
self.modified = timezone.now()
self.duration = int(self.clipend) - int(self.clipstart)
return super(Clip, self).save(*args, **kwargs)And views.py where I’m struggling (I’m not sure if I’m working with FileField properly etc) :
from moviepy.editor import *
def ClipDownload(request,pk,*args,**kwargs):
this_clip = models.Clip.objects.filter(pk=pk)
file_name = this_clip[0].game_id.wide
p = VideoFileClip(file_name,audio=False).subclip(this_clip.clipstart,this_clip.clipend)
response = HttpResponse(p, content_type='application/force-download')
response['Content-Disposition'] = 'attachment; filename=%s' % this_clip.name
response['Content-Length'] = os.path.getsize(file_name)
return responseThe current code is not working, I’m getting the proper Clip but I’m not able to make a subclip of the FileField as I’m getting an attribute error :
AttributeError: 'FieldFile' object has no attribute 'endswith'
I would be very appreciative if someone can point me in the right direction to get the file downloading so I can move on to trying to incorporate it into celery ?