
Recherche avancée
Autres articles (78)
-
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 -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
Diogene : création de masques spécifiques de formulaires d’édition de contenus
26 octobre 2010, parDiogene est un des plugins ? SPIP activé par défaut (extension) lors de l’initialisation de MediaSPIP.
A quoi sert ce plugin
Création de masques de formulaires
Le plugin Diogène permet de créer des masques de formulaires spécifiques par secteur sur les trois objets spécifiques SPIP que sont : les articles ; les rubriques ; les sites
Il permet ainsi de définir en fonction d’un secteur particulier, un masque de formulaire par objet, ajoutant ou enlevant ainsi des champs afin de rendre le formulaire (...)
Sur d’autres sites (7668)
-
The screen recorder utility has failed to store the actual screen recording iOS
31 mai 2023, par manojI am getting the below issue when I run my code to record the screen on failure.


An unknown server-side error occurred while processing the command. Original error : The screen recorder utility has failed to store the actual screen recording at '/var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/202341-30610-87cfav.bsg2u/appium_3f7703.mp4'


Note : This issue is occurring during the tearDown.


the code is showing stop recording is failing and this issue is occurring for only one test class


public static File screenRecording(String prefix) throws IOException {
 File classpathRoot = new File(System.getProperty("user.dir"));
 String screenRec = ((CanRecordScreen) driver).stopRecordingScreen();
 byte[] screenRecord = Base64.decodeBase64(screenRec);
 String destinationPath = classpathRoot.getAbsolutePath() + "/screenRecordings/" + driver.getPlatformName()
 + " Video " + prefix + " " + new Date() + ".mp4";
 Path filePath = Paths.get(destinationPath);
 Files.write(filePath, screenRecord);
 File recordedFile = FileUtils.getFile(String.valueOf(filePath));
 return recordedFile;
 }



The same thing when I run it successfully is passing in other test


This is the thread that I was reffering


Appium stack


[ INFO ] 2023-05-26 13:38:51.636 [TestHelpers.PropertiesHelper.getRestartDeviceProperty(PropertiesHelper.java:181)] - Loading the 'RestartDevice' Property from the 'appiumTests.properties' file
[ INFO ] 2023-05-26 13:38:51.641 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:81)] - Building Appium Server...
[ INFO ] 2023-05-26 13:38:51.733 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:88)] - Appium server is built.
[ INFO ] 2023-05-26 13:38:51.733 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:89)] - Starting appium server...
[Appium] Welcome to Appium v1.22.2
[Appium] Non-default server args:
[Appium] port: 3022
[Appium] logFile: /Users/subh/IdeaProjects/tile_mobile_automation/logs/appium.log
[Appium] loglevel: info
[Appium] relaxedSecurityEnabled: true
[Appium] Appium REST http interface listener started on 0.0.0.0:3022
[HTTP] --> GET /wd/hub/status
[HTTP] {}
[HTTP] <-- GET /wd/hub/status 200 5 ms - 68
[HTTP] 
[ INFO ] 2023-05-26 13:38:53.069 [TestFixtures.BaseTestFixture.globalSetup(BaseTestFixture.java:91)] - Appium server started.

[ffmpeg] Output #0, mp4, to '/var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/2023426-9341-y22m7g.0jfd/appium_eca508.mp4':
[ffmpeg] Metadata:
[ffmpeg] encoder : Lavf59.27.100
[ffmpeg] Stream #0:0: Video: h264 (avc1 / 0x31637661), yuvj420p(pc, bt470bg/unknown/unknown, progressive), 720x1280 [SAR 520:633 DAR 195:422], q=2-31, 25 fps, 12800 tbn
[ffmpeg] Metadata:
[ffmpeg] encoder : Lavc59.37.100 libx264
[ffmpeg] 
[ffmpeg] Side data:
[ffmpeg] cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[ffmpeg] 
[XCUITest] Starting screen capture on the device 'xxxxxxxx-xxxxxxxxxxxxxxxx' with command: 'ffmpeg -f mjpeg -i http://127.0.0.1:9100 -vf scale=720:1280 -vcodec h264 -y /var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/2023426-9341-y22m7g.0jfd/appium_eca508.mp4'. Will timeout in 1800000ms
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/start_recording_screen 200 621 ms - 12
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/device/terminate_app
[HTTP] {"bundleId":"com.apple.Preferences"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/device/terminate_app 200 6 ms - 15
[HTTP] 
[ INFO ] 2023-05-26 13:39:15.082 [TestFixtures.BaseTestFixture.setUp(BaseTestFixture.java:200)] - App Version is 2.115.0(7936)
<-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element 200 208 ms - 137
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/CC010000-0000-0000-1709-000000000000/click
[HTTP] {"id":"CC010000-0000-0000-1709-000000000000"}
[W3C (9a4d93a9)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Replacing sessionId 643ECEF8-D0E3-47D0-AE3D-3FC884C69235 with 9a4d93a9-b723-4e2e-abad-db859e5efeed
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/CC010000-0000-0000-1709-000000000000/click 200 805 ms - 65
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context
[HTTP] {}
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context 200 1 ms - 22
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element
[HTTP] {"using":"id","value":"OK"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element 200 309 ms - 137
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/displayed
[HTTP] {}
[W3C (9a4d93a9)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Replacing sessionId 643ECEF8-D0E3-47D0-AE3D-3FC884C69235 with 9a4d93a9-b723-4e2e-abad-db859e5efeed
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/displayed 200 134 ms - 65
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context
[HTTP] {}
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context 200 1 ms - 22
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element
[HTTP] {"using":"id","value":"OK"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element 200 253 ms - 137
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/text
[HTTP] {}
[W3C (9a4d93a9)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Replacing sessionId 643ECEF8-D0E3-47D0-AE3D-3FC884C69235 with 9a4d93a9-b723-4e2e-abad-db859e5efeed
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/text 200 117 ms - 65
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context
[HTTP] {}
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context 200 1 ms - 22
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element
[HTTP] {"using":"id","value":"OK"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element 200 247 ms - 137
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/click
[HTTP] {"id":"39020000-0000-0000-1709-000000000000"}
[W3C (9a4d93a9)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Replacing sessionId 643ECEF8-D0E3-47D0-AE3D-3FC884C69235 with 9a4d93a9-b723-4e2e-abad-db859e5efeed
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/39020000-0000-0000-1709-000000000000/click 200 778 ms - 65
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context
[HTTP] {}
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/context 200 1 ms - 22
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element
[HTTP] {"using":"id","value":"btn_add_tile"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element 200 285 ms - 137
[HTTP] 
[HTTP] --> GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/06010000-0000-0000-1709-000000000000/displayed
[HTTP] {}
[W3C (9a4d93a9)] Driver proxy active, passing request on via HTTP proxy
[WD Proxy] Replacing sessionId 643ECEF8-D0E3-47D0-AE3D-3FC884C69235 with 9a4d93a9-b723-4e2e-abad-db859e5efeed
[HTTP] <-- GET /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/element/06010000-0000-0000-1709-000000000000/displayed 200 133 ms - 65
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/app/reset
[HTTP] {}
[DevCon Factory] Releasing connections for xxxxxxxx-xxxxxxxxxxxxxxxx device on 9100 port number
[DevCon Factory] No cached connections have been found
[DevCon Factory] Releasing connections for xxxxxxxx-xxxxxxxxxxxxxxxx device on any port number
[DevCon Factory] Found cached connections to release: ["00008110-0004150236E8401E:8100"]
[DevCon Factory] Releasing the listener for 'xxxxxxxx-xxxxxxxxxxxxxxxx:8100'
[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:
[BaseDriver] appPushTimeout
[BaseDriver] app
[BaseDriver] automationName
[BaseDriver] deviceName
[BaseDriver] fullReset
[BaseDriver] newCommandTimeout
[BaseDriver] noReset
[BaseDriver] platformVersion
[BaseDriver] processArguments
[BaseDriver] showXcodeLog
[BaseDriver] udid
[BaseDriver] xcodeOrgId
[BaseDriver] xcodeSigningId
[BaseDriver] Session created with session id: 7950b9ef-eac2-4169-a035-2d183deacf68
[XCUITest] Determining device to run tests on: udid: 'xxxxxxxx-xxxxxxxxxxxxxxxx', real device: true
[XCUITest] Normalized platformVersion capability value '16.4.1' to '16.4'
[BaseDriver] Using local app '/Users/subh/IdeaProjects/tile_mobile_automation/apps/tile_appstore_adhoc.ipa'
[BaseDriver] Will reuse previously cached application at '/var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/2023426-9341-af6qqi.jfr2v/tile.app'
[WebDriverAgent] Using WDA path: '/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent'
[WebDriverAgent] Using WDA agent: '/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj'
[XCUITest] Setting up real device
[XCUITest] App installation succeeded after 14402ms
[DevCon Factory] Requesting connection for device xxxxxxxx-xxxxxxxxxxxxxxxx on local port 8100, device port 8100
[DevCon Factory] Successfully requested the connection for xxxxxxxx-xxxxxxxxxxxxxxxx:8100
[WebDriverAgent] Will reuse previously cached WDA instance at 'http://127.0.0.1:8100/' with 'com.facebook.WebDriverAgentRunner'. Set the wdaLocalPort capability to a value different from 8100 if this is an undesired behavior.
[WebDriverAgent] Using provided WebdriverAgent at 'http://127.0.0.1:8100/'
[WD Proxy] Determined the downstream protocol as 'W3C'
[XCUITest] Skipping setting of the initial display orientation. Set the "orientation" capability to either "LANDSCAPE" or "PORTRAIT", if this is an undesired behavior.
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/app/reset 200 18735 ms - 14
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/device/terminate_app
[HTTP] {"bundleId":"com.apple.Preferences"}
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/device/terminate_app 200 1046 ms - 14
INFO: Loading the 'SaveVideoOnSuccess' Property from the 'appiumTests.properties' file
[HTTP] 
[HTTP] --> POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/stop_recording_screen
[HTTP] {}
[DevCon Factory] Releasing connections for xxxxxxxx-xxxxxxxxxxxxxxxx device on 9100 port number
[DevCon Factory] No cached connections have been found
[XCUITest] The screen recorder utility has failed to store the actual screen recording at '/var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/2023426-9341-y22m7g.0jfd/appium_eca508.mp4'
[DevCon Factory] Releasing connections for xxxxxxxx-xxxxxxxxxxxxxxxx device on 9100 port number
[DevCon Factory] No cached connections have been found
[HTTP] <-- POST /wd/hub/session/9a4d93a9-b723-4e2e-abad-db859e5efeed/appium/stop_recording_screen 500 14 ms - 841
[HTTP] 

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: The screen recorder utility has failed to store the actual screen recording at '/var/folders/js/h2_7h9bj1fj8cn19tqcm8hnw0000gn/T/2023426-9341-y22m7g.0jfd/appium_eca508.mp4'
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'localhost', ip: 'fe80:0:0:0:8c8:c2c0:abb2:3b1a%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.2', java.version: '11.0.11'
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities {app: /Users/subh/IdeaProjects/ti..., appPushTimeout: 50000, automationName: XCUITest, browserName: , databaseEnabled: false, deviceName: Tile DEV QA?s iPhone, fullReset: true, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 30, noReset: false, platform: MAC, platformName: ios, platformVersion: 16.4.1, processArguments: {arguments: -com.apple.CoreData.Concurr...}, showXcodeLog: true, takesScreenshot: true, udid: xxxxxxxx-xxxxxxxxxxxxxxxx, webStorageEnabled: false, xcodeOrgId: XK64B7G5HB, xcodeSigningId: iPhone Developer}
Session ID: 9a4d93a9-b723-4e2e-abad-db859e5efeed

 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
 at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
 at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
 at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
 at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
 at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)
 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
 at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:45)
 at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
 at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
 at io.appium.java_client.screenrecording.CanRecordScreen.stopRecordingScreen(CanRecordScreen.java:72)
 at TestFixtures.BaseTestFixture.tearDown(BaseTestFixture.java:253)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
 at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:65)
 at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:381)
 at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:319)
 at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:803)
 at org.testng.internal.invokers.TestInvoker.runAfterConfigurations(TestInvoker.java:772)
 at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:748)
 at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220)
 at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
 at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945)
 at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193)
 at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
 at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
 at org.testng.TestRunner.privateRun(TestRunner.java:808)
 at org.testng.TestRunner.run(TestRunner.java:603)
 at org.testng.SuiteRunner.runTest(SuiteRunner.java:429)
 at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:423)
 at org.testng.SuiteRunner.privateRun(SuiteRunner.java:383)
 at org.testng.SuiteRunner.run(SuiteRunner.java:326)
 at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
 at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
 at org.testng.TestNG.runSuitesSequentially(TestNG.java:1249)
 at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
 at org.testng.TestNG.runSuites(TestNG.java:1092)
 at org.testng.TestNG.run(TestNG.java:1060)
 at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
 at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)





-
Catching ffmpeg stream in C# interrupts after a few seconds
15 septembre 2017, par ChrisI want to catch an ip-cam stream with ffmpeg in c# and send it with asp.net mvc web api to a client.
As a client I use also ffmpeg to test the api call.In my api controller I call the ffmpeg.exe with the proper arguments.
string argumentString = $"-i rtsp://{_user}:{_password}@{_ipAddress}/12 -nostdin -vcodec copy -f h264 pipe:1";
ProcessStartInfo startinfo = new ProcessStartInfo(HostingEnvironment.MapPath("~/App_Data/ffmpeg.exe"), argumentString);As you can see I am ignoring the standard input (
-nostdin
) and use the standard output to output the data (pipe:1
).But the client is always closing the connection after a few seconds (12-14).
Here the error message on the server (ASP.NET) :
And here the error message on the client (ffmpeg)
I tried several ways to catch the ip-cam stream.
Via the event
OutputDataReceived
:public HttpResponseMessage Get()
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new PushStreamContent((stream, content, context) =>
{
Process ffmpeg = new Process();
string argumentString = $"-i rtsp://{_user}:{_password}@{_ipAddress}/12 -nostdin -vcodec copy -f h264 pipe:1";
ProcessStartInfo startinfo = new ProcessStartInfo(HostingEnvironment.MapPath("~/App_Data/ffmpeg.exe"), argumentString);
startinfo.RedirectStandardError = true;
startinfo.RedirectStandardOutput = true;
startinfo.RedirectStandardInput = true;
startinfo.UseShellExecute = false;
startinfo.CreateNoWindow = true;
ffmpeg.StartInfo = startinfo;
ffmpeg.ErrorDataReceived += (s, e) =>
{
Debug.WriteLine(e.Data);
};
StreamWriter writer = new StreamWriter(stream);
ffmpeg.OutputDataReceived += (s, e) =>
{
writer.Write(e.Data);
};
ffmpeg.Start();
ffmpeg.BeginOutputReadLine();
ffmpeg.BeginErrorReadLine();
ffmpeg.WaitForExit();
}, new MediaTypeHeaderValue("video/mp4")),
};
return result;
}I also tried to do it without a StreamWriter, with every possible Encoding :
ffmpeg.OutputDataReceived += (s, e) =>
{
byte[] toBytes = Encoding.BigEndianUnicode.GetBytes(e.Data);
stream.Write(toBytes, 0, toBytes.Length);
stream.Flush();
};Via the underlying stream from StandardOutput :
public HttpResponseMessage Get()
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new PushStreamContent((stream, content, context) =>
{
Process ffmpeg = new Process();
string argumentString = $"-i rtsp://{_user}:{_password}@{_ipAddress}/12 -nostdin -vcodec copy -f h264 pipe:1";
ProcessStartInfo startinfo = new ProcessStartInfo(HostingEnvironment.MapPath("~/App_Data/ffmpeg.exe"), argumentString);
startinfo.RedirectStandardError = true;
startinfo.RedirectStandardOutput = true;
startinfo.RedirectStandardInput = true;
startinfo.UseShellExecute = false;
startinfo.CreateNoWindow = true;
ffmpeg.StartInfo = startinfo;
ffmpeg.Start();
byte[] buffer = new byte[512];
int length = 0;
while ((length = ffmpeg.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
{
stream.Write(buffer, 0, length);
stream.Flush();
}
}, new MediaTypeHeaderValue("video/mp4")),
};
return result;
}But the result is always the same.
When I do not send the data to the client it is working fine :
public HttpResponseMessage Get()
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new PushStreamContent((stream, content, context) =>
{
Process ffmpeg = new Process();
string argumentString = $"-i rtsp://{_user}:{_password}@{_ipAddress}/12 -nostdin -vcodec copy -f h264 pipe:1";
ProcessStartInfo startinfo = new ProcessStartInfo(HostingEnvironment.MapPath("~/App_Data/ffmpeg.exe"), argumentString);
startinfo.RedirectStandardError = true;
startinfo.RedirectStandardOutput = true;
startinfo.RedirectStandardInput = true;
startinfo.UseShellExecute = false;
startinfo.CreateNoWindow = true;
ffmpeg.StartInfo = startinfo;
ffmpeg.Start();
byte[] buffer = new byte[512];
int length = 0;
while ((length = ffmpeg.StandardOutput.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
{
//stream.Write(buffer, 0, length);
//stream.Flush();
}
}, new MediaTypeHeaderValue("video/mp4")),
};
return result;
}So what is wrong with my code ?
-
FFmpeg WASM writeFile Stalls and Doesn't Complete in React App with Ant Design
26 février, par raiyan khanI'm using FFmpeg WebAssembly (WASM) in a React app to process and convert a video file before uploading it. The goal is to resize the video to 720p using FFmpeg before sending it to the backend.


Problem :


Everything works up to fetching the file and confirming it's loaded into memory, but FFmpeg hangs at ffmpeg.writeFile() and does not proceed further. No errors are thrown.


Code Snippet :


- 

-
Loading FFmpeg


const loadFFmpeg = async () => {
 if (loaded) return; // Avoid reloading if 
 already loaded

 const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd';
 const ffmpeg = ffmpegRef.current;
 ffmpeg.on('log', ({ message }) => {
 messageRef.current.innerHTML = message;
 console.log(message);
 });
 await ffmpeg.load({
 coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 });
 setLoaded(true);
 };

 useEffect(() => {
 loadFFmpeg()
 }, [])



-
Fetching and Writing File


const convertVideoTo720p = async (videoFile) => {
 console.log("Starting video 
 conversion...");



 const { height } = await getVideoMetadata(videoFile);
 console.log(`Video height: ${height}`);

 if (height <= 720) {
 console.log("No conversion needed.");
 return videoFile;
 }

 const ffmpeg = ffmpegRef.current;
 console.log("FFmpeg instance loaded. Writing file to memory...");

 const fetchedFile = await fetchFile(videoFile);
 console.log("File fetched successfully:", fetchedFile);

 console.log("Checking FFmpeg memory before writing...");
 console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);

 if (!ffmpeg.isLoaded()) {
 console.error("FFmpeg is not fully loaded yet!");
 return;
 }

 console.log("Memory seems okay. Writing file to FFmpeg...");
 await ffmpeg.writeFile('input.mp4', fetchedFile); // ❌ This line hangs, nothing after runs
 console.log("File successfully written to FFmpeg memory.");
 };









Debugging Steps I've Tried :


- 

- Ensured FFmpeg is fully loaded before calling
writeFile()

✅ffmpeg.isLoaded()
returnstrue
. - Checked file fetch process :
✅
fetchFile(videoFile)
successfully returns aUint8Array
. - Tried renaming the file to prevent caching issues
✅ Used a unique file name like
video_${Date.now()}.mp4
, but no change - Checked browser console for errors :
❌ No errors are displayed.
- Tried skipping FFmpeg and uploading the raw file instead :
✅ Upload works fine without FFmpeg, so the issue is specific to FFmpeg.












Expected Behavior


- 

ffmpeg.writeFile('input.mp4', fetchedFile);
should complete and allow FFmpeg to process the video.




Actual Behavior


- 

- Execution stops at
writeFile
, and no errors are thrown.




Environment :


- 

- React : 18.x
- FFmpeg WASM Version : @ffmpeg/ffmpeg@0.12.15
- Browser : Chrome 121, Edge 120
- Operating System : Windows 11










Question :
Why is FFmpeg's
writeFile()
stalling and never completing ?
How can I fix or further debug this issue ?

Here is my full code :




import { useNavigate } from "react-router-dom";
import { useEffect, useRef, useState } from 'react';
import { Form, Input, Button, Select, Space } from 'antd';
const { Option } = Select;
import { FaAngleLeft } from "react-icons/fa6";
import { message, Upload } from 'antd';
import { CiCamera } from "react-icons/ci";
import { IoVideocamOutline } from "react-icons/io5";
import { useCreateWorkoutVideoMutation } from "../../../redux/features/workoutVideo/workoutVideoApi";
import { convertVideoTo720p } from "../../../utils/ffmpegHelper";
import { FFmpeg } from '@ffmpeg/ffmpeg';
import { fetchFile, toBlobURL } from '@ffmpeg/util';


const AddWorkoutVideo = () => {
 const [videoFile, setVideoFile] = useState(null);
 const [imageFile, setImageFile] = useState(null);
 const [loaded, setLoaded] = useState(false);
 const ffmpegRef = useRef(new FFmpeg());
 const videoRef = useRef(null);
 const messageRef = useRef(null);
 const [form] = Form.useForm();
 const [createWorkoutVideo, { isLoading }] = useCreateWorkoutVideoMutation()
 const navigate = useNavigate();

 const videoFileRef = useRef(null); // Use a ref instead of state


 // Handle Video Upload
 const handleVideoChange = ({ file }) => {
 setVideoFile(file.originFileObj);
 };

 // Handle Image Upload
 const handleImageChange = ({ file }) => {
 setImageFile(file.originFileObj);
 };

 // Load FFmpeg core if needed (optional if you want to preload)
 const loadFFmpeg = async () => {
 if (loaded) return; // Avoid reloading if already loaded

 const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd';
 const ffmpeg = ffmpegRef.current;
 ffmpeg.on('log', ({ message }) => {
 messageRef.current.innerHTML = message;
 console.log(message);
 });
 await ffmpeg.load({
 coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 });
 setLoaded(true);
 };

 useEffect(() => {
 loadFFmpeg()
 }, [])

 // Helper: Get video metadata (width and height)
 const getVideoMetadata = (file) => {
 return new Promise((resolve, reject) => {
 const video = document.createElement('video');
 video.preload = 'metadata';
 video.onloadedmetadata = () => {
 resolve({ width: video.videoWidth, height: video.videoHeight });
 };
 video.onerror = () => reject(new Error('Could not load video metadata'));
 video.src = URL.createObjectURL(file);
 });
 };

 // Inline conversion helper function
 // const convertVideoTo720p = async (videoFile) => {
 // // Check the video resolution first
 // const { height } = await getVideoMetadata(videoFile);
 // if (height <= 720) {
 // // No conversion needed
 // return videoFile;
 // }
 // const ffmpeg = ffmpegRef.current;
 // // Load ffmpeg if not already loaded
 // // await ffmpeg.load({
 // // coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 // // wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 // // });
 // // Write the input file to the ffmpeg virtual FS
 // await ffmpeg.writeFile('input.mp4', await fetchFile(videoFile));
 // // Convert video to 720p (scale filter maintains aspect ratio)
 // await ffmpeg.exec(['-i', 'input.mp4', '-vf', 'scale=-1:720', 'output.mp4']);
 // // Read the output file
 // const data = await ffmpeg.readFile('output.mp4');
 // console.log(data, 'data from convertVideoTo720p');
 // const videoBlob = new Blob([data.buffer], { type: 'video/mp4' });
 // return new File([videoBlob], 'output.mp4', { type: 'video/mp4' });
 // };
 const convertVideoTo720p = async (videoFile) => {
 console.log("Starting video conversion...");

 // Check the video resolution first
 const { height } = await getVideoMetadata(videoFile);
 console.log(`Video height: ${height}`);

 if (height <= 720) {
 console.log("No conversion needed. Returning original file.");
 return videoFile;
 }

 const ffmpeg = ffmpegRef.current;
 console.log("FFmpeg instance loaded. Writing file to memory...");

 // await ffmpeg.writeFile('input.mp4', await fetchFile(videoFile));
 // console.log("File written. Starting conversion...");
 console.log("Fetching file for FFmpeg:", videoFile);
 const fetchedFile = await fetchFile(videoFile);
 console.log("File fetched successfully:", fetchedFile);
 console.log("Checking FFmpeg memory before writing...");
 console.log(`File size: ${fetchedFile.length} bytes (~${(fetchedFile.length / 1024 / 1024).toFixed(2)} MB)`);

 if (fetchedFile.length > 50 * 1024 * 1024) { // 50MB limit
 console.error("File is too large for FFmpeg WebAssembly!");
 message.error("File too large. Try a smaller video.");
 return;
 }

 console.log("Memory seems okay. Writing file to FFmpeg...");
 const fileName = `video_${Date.now()}.mp4`; // Generate a unique name
 console.log(`Using filename: ${fileName}`);

 await ffmpeg.writeFile(fileName, fetchedFile);
 console.log(`File successfully written to FFmpeg memory as ${fileName}.`);

 await ffmpeg.exec(['-i', 'input.mp4', '-vf', 'scale=-1:720', 'output.mp4']);
 console.log("Conversion completed. Reading output file...");

 const data = await ffmpeg.readFile('output.mp4');
 console.log("File read successful. Creating new File object.");

 const videoBlob = new Blob([data.buffer], { type: 'video/mp4' });
 const convertedFile = new File([videoBlob], 'output.mp4', { type: 'video/mp4' });

 console.log(convertedFile, "converted video from convertVideoTo720p");

 return convertedFile;
 };


 const onFinish = async (values) => {
 // Ensure a video is selected
 if (!videoFileRef.current) {
 message.error("Please select a video file.");
 return;
 }

 // Create FormData
 const formData = new FormData();
 if (imageFile) {
 formData.append("image", imageFile);
 }

 try {
 message.info("Processing video. Please wait...");

 // Convert the video to 720p only if needed
 const convertedVideo = await convertVideoTo720p(videoFileRef.current);
 console.log(convertedVideo, 'convertedVideo from onFinish');

 formData.append("media", videoFileRef.current);

 formData.append("data", JSON.stringify(values));

 // Upload manually to the backend
 const response = await createWorkoutVideo(formData).unwrap();
 console.log(response, 'response from add video');

 message.success("Video added successfully!");
 form.resetFields(); // Reset form
 setVideoFile(null); // Clear file

 } catch (error) {
 message.error(error.data?.message || "Failed to add video.");
 }

 // if (videoFile) {
 // message.info("Processing video. Please wait...");
 // try {
 // // Convert the video to 720p only if needed
 // const convertedVideo = await convertVideoTo720p(videoFile);
 // formData.append("media", convertedVideo);
 // } catch (conversionError) {
 // message.error("Video conversion failed.");
 // return;
 // }
 // }
 // formData.append("data", JSON.stringify(values)); // Convert text fields to JSON

 // try {
 // const response = await createWorkoutVideo(formData).unwrap();
 // console.log(response, 'response from add video');

 // message.success("Video added successfully!");
 // form.resetFields(); // Reset form
 // setFile(null); // Clear file
 // } catch (error) {
 // message.error(error.data?.message || "Failed to add video.");
 // }
 };

 const handleBackButtonClick = () => {
 navigate(-1); // This takes the user back to the previous page
 };

 const videoUploadProps = {
 name: 'video',
 // action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
 // headers: {
 // authorization: 'authorization-text',
 // },
 // beforeUpload: (file) => {
 // const isVideo = file.type.startsWith('video/');
 // if (!isVideo) {
 // message.error('You can only upload video files!');
 // }
 // return isVideo;
 // },
 // onChange(info) {
 // if (info.file.status === 'done') {
 // message.success(`${info.file.name} video uploaded successfully`);
 // } else if (info.file.status === 'error') {
 // message.error(`${info.file.name} video upload failed.`);
 // }
 // },
 beforeUpload: (file) => {
 const isVideo = file.type.startsWith('video/');
 if (!isVideo) {
 message.error('You can only upload video files!');
 return Upload.LIST_IGNORE; // Prevents the file from being added to the list
 }
 videoFileRef.current = file; // Store file in ref
 // setVideoFile(file); // Store the file in state instead of uploading it automatically
 return false; // Prevent auto-upload
 },
 };

 const imageUploadProps = {
 name: 'image',
 action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
 headers: {
 authorization: 'authorization-text',
 },
 beforeUpload: (file) => {
 const isImage = file.type.startsWith('image/');
 if (!isImage) {
 message.error('You can only upload image files!');
 }
 return isImage;
 },
 onChange(info) {
 if (info.file.status === 'done') {
 message.success(`${info.file.name} image uploaded successfully`);
 } else if (info.file.status === 'error') {
 message.error(`${info.file.name} image upload failed.`);
 }
 },
 };
 return (
 <>
 <div classname="flex items-center gap-2 text-xl cursor-pointer">
 <faangleleft></faangleleft>
 <h1 classname="font-semibold">Add Video</h1>
 </div>
 <div classname="rounded-lg py-4 border-[#79CDFF] border-2 shadow-lg mt-8 bg-white">
 <div classname="space-y-[24px] min-h-[83vh] bg-light-gray rounded-2xl">
 <h3 classname="text-2xl text-[#174C6B] mb-4 border-b border-[#79CDFF]/50 pb-3 pl-16 font-semibold">
 Adding Video
 </h3>
 <div classname="w-full px-16">
 / style={{ maxWidth: 600, margin: '0 auto' }}
 >
 {/* Section 1 */}
 {/* <space direction="vertical" style="{{"> */}
 {/* <space size="large" direction="horizontal" classname="responsive-space"> */}
 <div classname="grid grid-cols-2 gap-8 mt-8">
 <div>
 <space size="large" direction="horizontal" classname="responsive-space-section-2">

 {/* Video */}
 Upload Video}
 name="media"
 className="responsive-form-item"
 // rules={[{ required: true, message: 'Please enter the package amount!' }]}
 >
 <upload maxcount="{1}">
 <button style="{{" solid="solid">
 <span style="{{" 600="600">Select a video</span>
 <iovideocamoutline size="{20}" color="#174C6B"></iovideocamoutline>
 </button>
 </upload>
 

 {/* Thumbnail */}
 Upload Image}
 name="image"
 className="responsive-form-item"
 // rules={[{ required: true, message: 'Please enter the package amount!' }]}
 >
 <upload maxcount="{1}">
 <button style="{{" solid="solid">
 <span style="{{" 600="600">Select an image</span>
 <cicamera size="{25}" color="#174C6B"></cicamera>
 </button>
 </upload>
 

 {/* Title */}
 Video Title}
 name="name"
 className="responsive-form-item-section-2"
 >
 <input type="text" placeholder="Enter video title" style="{{&#xA;" solid="solid" />
 
 </space>
 </div>
 </div>

 {/* </space> */}
 {/* </space> */}


 {/* Submit Button */}
 
 <div classname="p-4 mt-10 text-center mx-auto flex items-center justify-center">
 
 <span classname="text-white font-semibold">{isLoading ? 'Uploading...' : 'Upload'}</span>
 
 </div>
 
 
 </div>
 </div>
 </div>
 >
 )
}

export default AddWorkoutVideo







Would appreciate any insights or suggestions. Thanks !


-