
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (1)
-
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...)
Sur d’autres sites (1633)
-
C# .net mvc Process return encoding progress (FFMpeg) to client initiated with ajax
19 décembre 2014, par user1585895I am using FFMpeg to encode wav to mp3s, and on completion download the final .zip to the client.
All works great, and I can Debug.WriteLine the progress of the encoding, but I would like to return _percentage back to the client to do some UI updates based on the value of _percentage and if all encoding is done, Im not sure how to approach this.
My thinking is as follows :
- ajax post to CreateAndDownloadAlbum(List trackIds, int productId)
- loop through List and create a new Process, run
— parse StdError to get encoding percentage in myProcess_ErrorData(object source, DataReceivedEventArgs e)
— send _percentage value at timed intervals back to CreateAndDownloadAlbum
— update UI based on value of _percentage, when all is complete break and call public ActionResult SendFileDownload()
Any input would be great.
Thanks !
front end AJAX call to post list of file Ids to download
var data = $('#downloadAlbum').serialize();
$.ajax({
url: "/Admin/CreateAndDownloadAlbum",
method: "POST",
data: data,
dataType: 'json',
success: function(result) {
// wait here for _percentage
// if not 100, call again to get new _percentage value
// if 100, update UI, move to next file being encoded
// if all encoding is complete, call SendFileDownload() in controller
}
});then the controller code
[HttpPost]
public void CreateAndDownloadAlbum(List<trackstodownload> trackIds, int productId)
{
_numTracksToDownload = trackIds.Count;
var product = _productRepository.GetProductById(productId);
var artist = _artistRepository.GetArtistById(product.ArtistId);
var folderGuid = Guid.NewGuid();
_zipFolder = string.Concat(artist.ArtistName.ToUpper().Replace(" ", "_"), "[", product.ProductName.ToUpper().Replace(" ", "_"), "].zip");
_mp3FolderPath = Server.MapPath("/Files/" + productId + "/" + folderGuid);
_zipDownloadPath = Server.MapPath("/Delivery/" + _zipFolder);
if (!Directory.Exists(Server.MapPath("/Files/" + productId + "/" + folderGuid)))
{
Directory.CreateDirectory(Server.MapPath("/Files/" + productId + "/" + folderGuid));
}
foreach (var z in trackIds)
{
var track = _trackRepository.GetTrackById(z.TrackId);
var process = new Process();
var startInfo = new ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
FileName = "F:\\Development\\ffmpeg\\ffmpeg.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
var startFile = Path.Combine("F:\\Development","Files", track.ProductId.ToString(), track.TrackFileName);
var endFile = Path.Combine("F:\\Development", "Files", track.ProductId.ToString(), folderGuid.ToString(), track.TrackFileName.Replace(".wav", ".mp3"));
startInfo.Arguments = "-i " + startFile + " -b:a 320k " + endFile + " -stats";
process.StartInfo = startInfo;
process.EnableRaisingEvents = true;
process.Exited += myProcess_exited;
process.OutputDataReceived += myProcess_OutputData;
process.ErrorDataReceived += myProcess_ErrorData;
try
{
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
if (process.HasExited == false)
{
process.WaitForExit();
}
}
catch (Exception)
{
throw;
}
}
SendFileDownload();
}
public ActionResult SendFileDownload()
{
// zip and move to delivery folder
using (var zip = new ZipFile())
{
zip.AddDirectory(_mp3FolderPath, _zipFolder);
zip.Save(_zipDownloadPath);
}
// delete items in temp guid folder
var downloadedMessageInfo = new DirectoryInfo(_mp3FolderPath);
foreach (var f in downloadedMessageInfo.GetFiles())
{
f.Delete();
}
// delete temp folder
Directory.Delete(_mp3FolderPath);
// download file
string file = _zipDownloadPath;
return File(file, "application/force-download", Path.GetFileName(file));
}
public void myProcess_exited(Object source, EventArgs e)
{
Debug.WriteLine("myProcess_exited ===================================");
_duration = new TimeSpan(0, 0, 0);
_frameTime = new TimeSpan(0, 0, 0);
_percentage = 0;
_numEncodedTracks++; // using this to tell me if all tracks have been encoded
}
public void myProcess_OutputData(object source, DataReceivedEventArgs e)
{
}
public void myProcess_ErrorData(object source, DataReceivedEventArgs e)
{
string strMessage = e.Data;
if (!string.IsNullOrEmpty(strMessage) && (strMessage.Contains("Duration: ") || strMessage.Contains("size=")))
{
if (_duration != null)
{
if (strMessage.Contains("Duration: "))
{
_strDuration = strMessage.Substring(strMessage.IndexOf("Duration: ") + ("Duration: ").Length,
("00:00:00.00").Length);
char[] d_delHrMn = new char[] { ':' };
string[] d_tempHrMn = _strDuration.Split(d_delHrMn, StringSplitOptions.RemoveEmptyEntries);
char[] d_delSec = new char[] { '.' };
string[] d_tempSec = d_tempHrMn[2].Split(d_delSec, StringSplitOptions.RemoveEmptyEntries);
var d_hour = d_tempHrMn[0] == "0" ? 0 : Convert.ToInt32(d_tempHrMn[0]);
var d_min = d_tempHrMn[1] == "0" ? 0 : Convert.ToInt32(d_tempHrMn[1]);
var d_sec = d_tempSec[0] == "0" ? 0 : Convert.ToInt32(d_tempSec[0]);
_duration = new TimeSpan(d_hour, d_min, d_sec);
}
}
if (strMessage.Contains("size="))
{
_strFrameTime = strMessage.Substring(strMessage.IndexOf("time=") + ("time=").Length,
("00:00:00.00").Length);
char[] f_delHrMn = new char[] { ':' };
string[] f_tempHrMn = _strFrameTime.Split(f_delHrMn, StringSplitOptions.RemoveEmptyEntries);
char[] f_delSec = new char[] { '.' };
string[] f_tempSec = f_tempHrMn[2].Split(f_delSec, StringSplitOptions.RemoveEmptyEntries);
var f_hour = f_tempHrMn[0] == "0" ? 0 : Convert.ToInt32(f_tempHrMn[0]);
var f_min = f_tempHrMn[1] == "0" ? 0 : Convert.ToInt32(f_tempHrMn[1]);
var f_sec = f_tempSec[0] == "0" ? 0 : Convert.ToInt32(f_tempSec[0]);
_frameTime = new TimeSpan(f_hour, f_min, f_sec);
}
if (_strDuration != "00:00:00.00" && _strFrameTime != "00:00:00.00" && _percentage < 100)
{
_percentage = _frameTime.TotalMilliseconds / _duration.TotalMilliseconds * 100;
Debug.WriteLine(_percentage + " || " + _frameTime + " " + _duration);
}
}
}
</trackstodownload> -
Twitch stream with FFMpeg using multiple audio inputs [on hold]
23 décembre 2014, par Josh RaymondI’m using the following script to try and stream my linux desktop to Twitch.tv, I have the stream working, but I want to throw in 2 audio inputs into the stream (one for the game, and one for my mic)
Here’s the script
#! /bin/bash
INRES="1900x600"
OUTRES="800x600"
INAUD="pulse"
FPS="25
STREAM_KEY=$(cat ~/.twitch_key)
STREAM_URL="rtmp://live.twitch.tv/app/$STREAM_KEY"
ffmpeg \
-f alsa -ac 2 -i "$INAUD" \
-f x11grab -s "$INRES" -r "$FPS" -i :0.0+1280,0 \
-vcodec libx264 -s "$OUTRES" -pix_fmt yuv420p \
-acodec libmp3lame -threads 6 -qscale 5 -b 64KB \
-f flv -ar 44100 "$STREAM_URL"I use Pulseaudio and have pavucontrol, if that matters. The game would be on "Build-in Audio Analog Stereo" and the mic is from the recording device "Webcam C110 Analog Mono"
Thanks in advance.
-
ffmpeg progess bar not giving percent
3 décembre 2014, par BrettHi im trying to create a java program that shows the percent of a ffmpeg command , Im not sure where i am going wrong.
Its keeps giving me these results
run :
Total duration : 857.44 seconds.
Progress : 0.85%
Progress : 1.76%
Progress : 2.79%
Progress : 3.93%
Progress : 5.04%
Progress : 6.21%
Progress : 6000.27%
Progress : 6001.29%
Progress : 6002.46%
Progress : 6003.58%
Progress : 6004.59%
Progress : 6005.70%
Progress : 6006.77%
Progress : 12000.86%
Progress : 12001.97%
Progress : 12002.97%
Progress : 12004.03%
Progress : 12005.15%
Progress : 12006.27%
Progress : 18000.34%
Progress : 18001.46%
Progress : 18002.29%
Progress : 18003.41%
Progress : 18004.41%
Progress : 18005.50%
Progress : 18006.55%
Progress : 24000.52%
Progress : 24001.62%
Progress : 24002.74%
Progress : 24003.69%
Progress : 24004.76%
Progress : 24005.88%
Progress : 24006.94%
Progress : 30001.01%
Progress : 30002.16%
Progress : 30003.24%
Progress : 30004.25%
Progress : 30005.37%
Progress : 30006.44%
Progress : 36000.56%
Progress : 36001.60%
Progress : 36002.69%
Progress : 36003.73%
Progress : 36004.81%
Progress : 36005.93%
Progress : 42000.05%
Progress : 42001.18%
Progress : 42002.30%
Progress : 42003.41%
Progress : 42004.50%
Progress : 42005.60%
Progress : 42006.72%
Progress : 48000.84%
Progress : 48001.96%
Progress : 48003.08%
Progress : 48004.18%
Progress : 48005.09%
Progress : 48006.16%
Progress : 54000.22%
Progress : 54001.15%
Progress : 54002.20%
Progress : 54003.30%
Progress : 54004.42%
Progress : 54005.49%
Progress : 54006.38%
Progress : 60000.45%
Progress : 60001.57%
Progress : 60002.55%
Progress : 60003.64%
Progress : 60004.66%
Progress : 60005.62%
Progress : 60006.72%
Progress : 66000.67%
Progress : 66001.73%
Progress : 66002.75%
Progress : 66003.61%
Progress : 66004.71%
Progress : 66005.82%
Progress : 66006.81%
Progress : 72000.67%
Progress : 72001.73%
Progress : 72002.80%
Progress : 72003.87%
Progress : 72004.81%
Progress : 72005.71%
Progress : 72006.69%
Progress : 78000.73%
Progress : 78001.82%
Progress : 78002.91%
Progress : 78003.91%
Progress : 78004.98%
Progress : 78005.88%
Progress : 78006.49%
Progress : 84000.37%
Progress : 84001.12%
Progress : 84002.04%
BUILD SUCCESSFUL (total time : 49 seconds)But the file is created , i don’t know why im getting 0.00% any help would be awsome
..
It also complains some imports a not being used here are the imports.here is my code
import java.io.IOException;
import java.util.Scanner;
import static java.util.logging.Level.parse;
import java.util.regex.Pattern;
import javafx.util.Duration;
import static javax.management.Query.lt;
/**
*
* @author brett
*/
public class MashMeUp {
public static void main(String[] args) throws IOException {
ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-i", "C:\\Users\\brett\\Documents\\Telegraph_Road.mp4", "C:\\Users\\brett\\Documents\\out.mp4");
// ProcessBuilder pb = new ProcessBuilder(args);
final Process p = pb.start();
// create a new thread to get progress from ffmpeg command , override
// it's run method, and start it!
new Thread() {
public void run() {
Scanner sc = new Scanner(p.getErrorStream());
// Find duration
Pattern durPattern = Pattern.compile("(?<=Duration: )[^,]*");
String dur = sc.findWithinHorizon(durPattern, 0);
if (dur == null) {
throw new RuntimeException("Could not parse duration.");
}
String[] hms = dur.split(":");
double totalSecs = Integer.parseInt(hms[0]) * 3600
+ Integer.parseInt(hms[1]) * 60
+ Double.parseDouble(hms[2]);
System.out.println("Total duration: " + totalSecs + " seconds.");
// Find time as long as possible.
Pattern timePattern = Pattern.compile("(?<=time=)[\\d:.]*");
// TODO make regex that works with ffmpeg static build
String match;
String[] matchSplit;
while (null != (match = sc.findWithinHorizon(timePattern, 0))) {
matchSplit = match.split(":");
double progress = Double.parseDouble(matchSplit[2]) / totalSecs + Integer.parseInt(matchSplit[0]) * 3600 + Integer.parseInt(matchSplit[1]) * 60;
System.out.printf("Progress: %.2f%%%n", progress * 100);
}
}
}.start();
}
}