Video distortion problem

Manab Kumar Mal

New Member
Hello,
We are using flashphoner for live video recording and we are playing this video with our default video player. When we are playing this video, the video has distorted. There is some problem in playing the video. Please give some suggestion, how we will resolve this distortion problem.
We have subscribed and our subscription key is -- XXXXXXXX-XXXX-XXXX-XXXX-XXXXXCB1586E.
Name: Arpita Bose
Email: Info@natitsolved.com
Company: NATIT SOLVED PVT LTD

Please check this link -- https://drive.google.com/file/d/1084js7sYgGjljoKBhTvZFsbyE6NDT6Fc/view
 

Max

Administrator
Staff member
Please provide more details how do you stream.
1. What is streamer (Device model, OS version, Browser version).
2. What is player (Device model, OS version, Browser version).
3. Is this reproduced when you stream to our demo server: https://demo.flashphoner.com
4. WCS server version.
Any other details that you would mark as important.
 

Manab Kumar Mal

New Member
1. My iPhone 5S Device model is MF357HN/A and OS Version is 12.0.1(16A404).
2. I’m using AVPlayer as player.
3. I’m using “wss://demo.flashphoner.com:8443/manab” to connect with WCS server. And using "https://wcs5-eu.flashphoner.com” is for recording url’s streaming path.
-> For connecting with the server I’m writing this type of code —
- (FPWCSApi2Session *)connect
{
FPWCSApi2SessionOptions *options = [[FPWCSApi2SessionOptions alloc] init];
NSURL *url =[[NSURL alloc] initWithString:_connectUrl.text];
options.urlServer = [NSString stringWithFormat:mad:"%@://%@:%@", url.scheme, url.host, url.port];
streamName =[NSString stringWithFormat:mad:"iFaceYouLive_%@",[Global getRandNum]];
options.appKey = @"defaultApp";
NSError *error;
session = [FPWCSApi2 createSession:eek:ptions error:&error];
if (error)
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:mad:"Failed to connect"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle:mad:"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self onDisconnected];
}];
[alert addAction:eek:kButton];
[self presentViewController:alert animated:YES completion:nil];
return nil;
}
[session on:kFPWCSSessionStatusEstablished callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onConnected:rSession];
}];
[session on:kFPWCSSessionStatusDisconnected callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onDisconnected];
}];
[session on:kFPWCSSessionStatusFailed callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onDisconnected];
}];
[session connect];
return session;
}

-> And for the publishing the video I’m using this code —
- (FPWCSApi2Stream *)publishStream
{
FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init];
options.name = streamName;
options.record = true;
options.display = remotevideoView;
options.constraints = [[FPWCSApi2MediaConstraints alloc] initWithAudio:YES videoWidth:remotevideoView.frame.size.width videoHeight:remotevideoView.frame.size.height];
NSError *error;
if (frontCamera)
{
remotevideoView.transform=CGAffineTransformMakeScale(-1.0, 1.0);
}
else
{
remotevideoView.transform=CGAffineTransformMakeScale(1.0, 1.0);
}
publishStream = [session createStream:eek:ptions error:&error];
[SVProgressHUD dismiss];
[self.view setUserInteractionEnabled:YES];
[self createTimer];
if (!publishStream)
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:mad:"Failed to publish"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle:mad:"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self onUnpublished];
}];
[alert addAction:eek:kButton];
[self presentViewController:alert animated:YES completion:nil];
return nil;
}
[publishStream on:kFPWCSStreamStatusPublishing callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onPublishing:rStream];
}];
[publishStream on:kFPWCSStreamStatusResize callback:^(FPWCSApi2Stream *rStream){
}];
[publishStream on:kFPWCSStreamStatusUnpublished callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onUnpublished];
recordedFile = [rStream getRecordName];
if ([recordedFile length]>0)
{
[self uploadVideoToLocalServer];
}
}];
[publishStream on:kFPWCSStreamStatusFailed callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onUnpublished];
}];
if(![publishStream publish:&error])
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:mad:"Failed to publish"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle:mad:"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[self onUnpublished];
}];
[alert addAction:eek:kButton];
[self presentViewController:alert animated:YES completion:nil];
}
return publishStream;
}

4.
My WCS server version is “5.0.33”.
 

Max

Administrator
Staff member
Hello.
Please check if your live stream is distorted: play it in browser or in example iOS Player application while streaming.
Also please check if there is any distortion in records you make in our iOS Stream Recording example using our demo server and your server.
 

Manab Kumar Mal

New Member
Hi Max,
Thanks for your valuable reply, There was the problem as well with example app which you provided. The internet connection is stable. Please guide us, I have already shared teh code with you, I have already purchased your license. Please help us, we are really in trouble. Please tell us which code you want to check again, I will share the code with you.
 

Max

Administrator
Staff member
Hello.
It looks like WebRTC issue. When you streaming WebRTC video, the resolution can be adjusted on the fly. So, the mp4 file of the recorded chat ended up having wonderfully different frame dimensions. Specifically, a sequence of 640×480 resolution, then a sequence of 320×240 etc. Such non-typical videos play normally in VLC without artifacts or anything, but the components to play video playback via HTTP that are built into iOS produce green artifacts when the resolution of a video changes in the bit stream.
You can use WebRTC VOD feature to workaround this. Please refer to this article.
 

Max

Administrator
Staff member
Hello.
You should do the following:
1. Copy record file to WCS_HOME/media folder using on_record_hook script as described here. Please note that if you are using Amazon instance sudo is necessary to make any file operation, see point 3 here.
2. Set vod://record_name.mp4 as streamName parameter to play a file record_name.mp4, or vod-live://... if a number of subscribers should play it simultaneously.
 

Manab Kumar Mal

New Member
Hi Max,
Thank you for the feedback. The script you have given there we are already using there to transfer the file to specific directory. But when we are putting vod:// before the url of the video it is not recognizing. Can you please tell me how to play that url in ios or android or web?
Original URL: https://natitsol.in:8888/client/rec...E-20910C3D1584-iiabkki005tad8omrrgr121slr.mp4 : it is working
As you said to do: vod://natitsol.in:8888/client/records/stream-7608750A-3BAE-4E0D-B84E-20910C3D1584-iiabkki005tad8omrrgr121slr.mp4 : Not working, please tell us the way how to play that file?
 

Max

Administrator
Staff member
Hello
This file is located in folder /usr/local/FlashphonerWebCallServer/records
You can share this folder in your web server, i.e. apache
Code:
ln -sf /usr/local/FlashphonerWebCallServer/records myrecords
Then it will be available via your web server url.
 

Max

Administrator
Staff member
Hello.
To play the file via VOD, you should place it to /usr/local/FlashphonerWebCallServer/media folder. On client side, file should be requested as
vod://stream-7608750A-3BAE-4E0D-B84E-20910C3D1584-iiabkki005tad8omrrgr121slr.mp4
No file path should be included.
 

Manab Kumar Mal

New Member
Hi Max,
Thank you for the resolution, but still we are not getting your point about how to play the file? You are asking to call the url as vod://file_name.mp4, tell me if we put that to some player like avplayer or vlc player, how do these players understand where that file exist, there should be some remote url like http://full_path_url_of_the_file.mp4, Please let me know how to play that file in client side, we still not getting your point.
 

Max

Administrator
Staff member
Hello.
To play this file as VOD you should use WCS iOS SDK, for example (iOS Player application):
Code:
- (FPWCSApi2Stream *)playStream {
    FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
    FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init];
    options.name = "vod://file_name.mp4";
    options.display = _remoteDisplay;
    NSError *error;
    FPWCSApi2Stream *stream = [session createStream:options error:nil];
    ...
To play this file in another player you should download it from server. But in this case you can not workaround WebRTC resize issue. Although, VLC probably can handle it.
 

Manab Kumar Mal

New Member
Hi Max,
Thank you for your feedback, when I am publishing the stream the .recording = ON, so file is saved in the server. That file I want to play without downloading, please tell me the way how we can play that file without distortion? also are you sure VLC player do the trick? Because once I had added that framework but it was not working, instead VLC player bundle size is almost 1 GB size, so if you kindly confirm then we can make progress with that vlc player kit.
 
Last edited:

Max

Administrator
Staff member
Hello.
Thank you for your feedback, when I am publishing the stream the .recording = ON, so file is saved in the server. That file I want to play without downloading, please tell me the way how we can play that file without distortion?
To play your recording without downloading and without distorsion:
1) Place your recording to WCS_HOME/media folder
2) Play it using WCS iOS SDK, as we shown in this post. Don't use AVPlayer or VLC player.
Please build our Player example and check how it works.
 

Manab Kumar Mal

New Member
Hi Admin,
Thank you for your support.
1. We keeping the recordings in WCS_HOME/media folder in the wss server.
2. Playing it using following code:

- (FPWCSApi2Stream *)playStream {
localvideoView.hidden = NO;
FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init];
options.name = streamName; /*vod://stream-67327F8D-E05E-44B0-AE99-943A31758360-uvh8lm4ko8vfqjknfbi2a4akl3.mp4*/

options.display = localvideoView;
NSError *error;
playStream = [session createStream:eek:ptions error:nil];
if (!playStream) {
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:mad:"Failed to play"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* okButton = [UIAlertAction
actionWithTitle:mad:"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self onStopped];
}];

[alert addAction:eek:kButton];
[self presentViewController:alert animated:YES completion:nil];
return nil;
}
[playStream on:kFPWCSStreamStatusPlaying callback:^(FPWCSApi2Stream *rStream){
//[self changeStreamStatus:rStream];
//[self onPlaying:rStream];
}];

[playStream on:kFPWCSStreamStatusNotEnoughtBandwidth callback:^(FPWCSApi2Stream *rStream){
NSLog(@"Not enough bandwidth stream %@, consider using lower video resolution or bitrate. Bandwidth %ld bitrate %ld", [rStream getName], [rStream getNetworkBandwidth] / 1000, [rStream getRemoteBitrate] / 1000);
//[self changeStreamStatus:rStream];
}];

[playStream on:kFPWCSStreamStatusStopped callback:^(FPWCSApi2Stream *rStream){
//[self changeStreamStatus:rStream];
[self onStopped];
}];
[playStream on:kFPWCSStreamStatusFailed callback:^(FPWCSApi2Stream *rStream){
//[self changeStreamStatus:rStream];
[self onStopped];
}];
if(![playStream play:&error]) {
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:mad:"Failed to play"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* okButton = [UIAlertAction
actionWithTitle:mad:"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {

}];

[alert addAction:eek:kButton];
[self presentViewController:alert animated:YES completion:nil];
}
return playStream;
}

But all time it is going to the failed callback, i.e in following:

[playStream on:kFPWCSStreamStatusFailed callback:^(FPWCSApi2Stream *rStream){
//[self changeStreamStatus:rStream];
[self onStopped];
}];

Please help us to solve the issue, we can not understand why this problem is happening. The physical file exist on the server path, we have checked and it is running fine from browser, but it is not running as you asked to play by vod://file_name.mp4
 

Max

Administrator
Staff member
Please update your server to the latest build from this page. If you prefer to use 5.0 branch, please update to latest build 5.0.3530. Then, check if our example applications (Two Way Streaming or Player) can play this file.
Also, please collect server logs when you try to play VOD as described here and send us to support@flashphoner.com. We have to check if server streams VOD successfully before debug an application.
 
Top