Closed iamadityaaz closed 4 years ago
What is the meaning of App.js:106 Result:
line in the logs? Are you printing that in your app? It is printed three times and shows that that section of code is called three times.
I am attaching here the App.js 106
What is the meaning of
App.js:106 Result:
line in the logs? Are you printing that in your app? It is printed three times and shows that that section of code is called three times.
The issue is the code getting executed 3 times, even if I am trying to do it outside of loop.
When I look at the console output, I see that RNFFmpeg.executeWithArguments
for loop is executed just after printing App.js:106 Result:
. I'm asking why it is printed three times? Can I get an answer for that?
If you look at carefully to the console output, you can see that 2nd and 3rd executions start just after printing App.js:106 Result:
.
Also, those 2nd and 3rd executions start while 1st execution is still being executed. For me, this clearly shows that there are multiple threads running that section of code.
When I look at the console output, I see that
RNFFmpeg.executeWithArguments
for loop is executed just after printingApp.js:106 Result:
. I'm asking why it is printed three times? Can I get an answer for that?If you look at carefully to the console output, you can see that 2nd and 3rd executions start just after printing
App.js:106 Result:
.Also, those 2nd and 3rd executions start while 1st execution is still being executed. For me, this clearly shows that there are multiple threads running that section of code.
I am using
RNFFprobe.getMediaInformation(this.state.path).then(result => {
console.log('Result: ', result);
var seconds = result.duration / 1000;
let parts = parseInt(seconds / 30);
this.setState(
{
parts: parts,
},
() => {
console.log('parts : ', parts);
},
);
});
to get the information of the media, which is outside the loop then also this prints Result:
3 times ( This is the issue i am having) and the same
const result = await RNFFmpeg.executeWithArguments([
'-i',
this.state.path,
'-ss',
`${startTime}`,
'-t',
`${stopTime}`,
'-y',
'-c',
'copy',
`${this.state.path}-split-${index}.mp4`,
]);
if (!result.rc) {
console.log('Splitted succesfiully', index);
} else {
Alert.alert('Error', 'task failed');
}
this also gets printed 3 times.
... outside the loop then also this prints Result: 3 times ( This is the issue i am having)
If a log line (App.js:106 Result:
), which is outside of the RNFFmpeg.executeWithArguments
block is executed multiple times, then you shouldn't be blaming react-native-ffmpeg
for that, right?
... outside the loop then also this prints Result: 3 times ( This is the issue i am having)
If a log line (
App.js:106 Result:
), which is outside of theRNFFmpeg.executeWithArguments
block is executed multiple times, then you shouldn't be blamingreact-native-ffmpeg
for that, right?
The log line App.js:106 Result:
is inside RNFFprobe.getMediaInformation
.
RNFFprobe.getMediaInformation(this.state.path).then(result => {
console.log('Result: ', result);
var seconds = result.duration / 1000;
let parts = parseInt(seconds / 30);
this.setState(
{
parts: parts,
},
() => {
console.log('parts : ', parts);
},
);
});
What happens when you add a console.log
printing this.state.path
before RNFFprobe.getMediaInformation
? How many times that console.log
is executed?
What happens when you add a
console.log
printingthis.state.path
beforeRNFFprobe.getMediaInformation
? How many times thatconsole.log
is executed?
Sorry, actually i was calling trim function inside render function also, that was the reason it was getting called again and again.
Thank you
Description When i am trying to trim a video in multiple parts by using for loop to loop over it, it gets repeated execution of same commands multiple time (3 times) look at the image of the console. my code :
Expected behavior The log should be printed once only.
Current behavior but gets printed multiple times (3)
Screenshots
Logs
index.js:81 Environment