ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.27k stars 628 forks source link

Video Resolution and FPS #1034

Closed The-Code-Monkey closed 5 years ago

The-Code-Monkey commented 5 years ago

Issue

Short description

Can't find any docs saying how to change the video resolution as its currently coming out at 640x480@8fps how do i change this and force a 720p or 1080p at a specific frame rate

Environment

Expected behavior

Should be able to change the encoding settings even if its just a dropdown.

maybe the possibility to choose different encoding formats too, e.g. h264, h265

Actual behavior

output video is 640x480@8fps

Steps to reproduce

  1. default package
SelimEmre commented 5 years ago

Hi @The-Code-Monkey,

Thank you for your interest. Unfortunately, Transcoding feature is in Enterprise Edition. Also, FPS feature can be set in WebRTC Enterprise Edition.

Best Regards, Selim

The-Code-Monkey commented 5 years ago

So I can't up the resolution in the non enterprise edition at all. Seems strange to limit me to 480p maybe you should up it to 720p and if you want over that you will need enterprise edition it's 2019 nothing should be playing in 480p

SelimEmre commented 5 years ago

Hi @The-Code-Monkey,

Sorry for the misunderstood. You can change Video Resolution in OBS. Please review this video tutorial: https://www.youtube.com/watch?v=w8c7w5DxZ5k

Best Regards, Selim

The-Code-Monkey commented 5 years ago

Oh I know about OBS I need to know how I can change the whole encoding settings the MP4 is coming out at 480p

The-Code-Monkey commented 5 years ago

What can I do about setting the FPS to 60 rather than it being random like it currently is

JonathanBristow commented 4 years ago

@The-Code-Monkey Did you work out how to change the res in the Ant Media server?

The-Code-Monkey commented 4 years ago

I think I did it's been a while but I had to use the source code find where there were references to 480 and change them and their counter parts to the resolution that I wanted

mekya commented 4 years ago

We've provided a solution. It's available in the 2.2.0-SNAPSHOT You can give add a property

settings.heightRtmpForwarding=720

Its default value is 360 https://github.com/ant-media/Ant-Media-Server-Common/blob/master/src/main/java/io/antmedia/AppSettings.java#L877

JonathanBristow commented 4 years ago

@mekya Do you have a link to any docs showing where and how to set these values?

JonathanBristow commented 4 years ago

@mekya Also - we can I get the SNAPSHOT releases?

mekya commented 3 years ago

TBH, I've provided a simple instructions for that.

We've provided a solution. It's available in the 2.2.0-SNAPSHOT You can give add a property

settings.heightRtmpForwarding=720 Its default value is 360 https://github.com/ant-media/Ant-Media-Server-Common/blob/master/src/main/java/io/antmedia/AppSettings.java#L877

The App Configuration settings are also documented here. https://github.com/ant-media/Ant-Media-Server/wiki/Application-Configuration-Documentation

mekya commented 3 years ago

Lastly, community snapshots are deployed the sonatype automatically

https://oss.sonatype.org/#nexus-search;gav~io.antmedia~ant-media-server~~~~kw,versionexpand

anuragtb commented 3 years ago

@mekya , we are facing same issue on ams 2.2.1 EE, can let me know the file, we we have to sepcify "settings.heightRtmpForwarding=720"

mekya commented 3 years ago

It's app's properties file.

For LiveApp -> /usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties

Vegas10128 commented 3 years ago

It's app's properties file.

For LiveApp -> /usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties

Tried that, does not work on newest community release.

mekya commented 3 years ago

Hi @Vegas10128 ,

I would like to answer and help you. But I'm not sure if you are going to complain about me and mad at me again :) I'm just trying to do my best under high load and pressure. If you have any advice or help, it's highly appreciated. Btw, I don't take any thing personal. No hard feelings about anything ;)

Anyway, let me share my test result.

  1. I've downloaded the latest version. https://github.com/ant-media/Ant-Media-Server/releases/download/ams-v2.3.0/ant-media-server-2.3.0-community-2.3.0-20210301_0825.zip
  2. I've installed it to our test server.
  3. Add following property to

settings.heightRtmpForwarding=720

/usr/local/antmedia/webapps/LiveApp/WEB-INF/red5-web.properties

  1. Save the file and restart the service

    sudo service antmedia restart

  2. Enable MP4 recording on the web panel

  3. Publish stream to https://domain:5443/LiveApp/

  4. Stop publishing

  5. Check the recording resolution with ffmpeg and it shows 720p for me.

    Screen Shot 2021-04-07 at 13 52 39

I'm sorry but I could not reproduce your report. If you mean something else, please let me know.

bgatienRoss commented 3 years ago

I'm still seeing videos come out at a max of 640x360.

I have this version of AMS image

  1. I created a brand new App.
  2. I added settings.heightRtmpForwarding=720 to the red5-web.properties file.
  3. I restarted the AMS.
  4. I changed the publish_with_timestamp.html so it has the following constraints:

image

  1. I enable recording.
  2. After I stream and stop, I use ffmep so see the settings, and it says it's at 640x360

image

I can't seem to get any stream to stream out at a higher quality than 640x360. What am I doing wrong?

mekya commented 3 years ago

Hi @bgatienRoss ,

I added settings.heightRtmpForwarding=720 to the red5-web.properties file. Are you sure that you've changed the correct red5-web.properties ?

Is it possible to just change the parameter and try in one of the default applications?

bgatienRoss commented 3 years ago

As far as I can tell, the default applications do not have that parameter.

I added it in this file: image

The VanilaAppCreatedByAMS is a brand new App I created using the "New Application" button in the DashBoard app.

I'm going to this page in order to publish a stream: image

The only thing I changed in that page's html is the media constraints.

I then go to the streams folder in the VanilaAppCreatedByAMS folder to see the recorded streams.

mekya commented 3 years ago

Hi @bgatienRoss ,

Sorry for the late reply.

I think you're using enterprise edition. In Enterprise Edition, if you want to use the height in RTMP forwarding. You should add 'rtmpForward' to the url.

`https://example.com:5443/WebRTCAppEE/index.html?rtmpForward=true``

Please take a look at this line as well -> https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/index.html#L498

Please keep in mind that WebRTC ingest and RTMP forward includes a transcoding and it'll scale the height to settings.heightRTMPForwarding value. I mean it's not a true way for having all cases.

bgatienRoss commented 2 years ago

Hi Mekya,

Thanks for getting back to me.

Two questions:

  1. I'm not sure what you mean by WebRTC ingest and TRMP forward includes a transcoding.

Does this mean it takes a lower quality video and converts it to higher quality on the AMS side? Will this introduce latency to the video? We want the highest quality video we can with the lowest latency. If this introduces latency, is there another way to force the videos to stream with higher quality than 640x360 direct from the source?

  1. I still can't get it to work. If I change my websocket url to include the rtmpForward=true, as in the example, my stream no longer publishes.

Here is the change I made: image

When I try and publish with that change, I now get an error in the console:

error callback: "server_error_check_logs"

I assume this means to check the ant-media-server.log. But I'm not sure what I should be looking for. I'm seeing lines like these:

2021-10-28 10:11:28,711 [https-jsse-nio2-0.0.0.0-5443-exec-23] WARN i.a.filter.TokenFilterManager - hash undefined is not valid 2021-10-28 10:11:28,739 [vert.x-worker-thread-7] INFO io.antmedia.muxer.HLSMuxer - cannot write video frame to muxer. Error: Invalid argument

But I'm not sure if they are related or not.

If I remove the rtmpFoward=true, that error callback goes away, and it streams again.

mekya commented 2 years ago

Hi Mekya,

Thanks for getting back to me.

Two questions:

  1. I'm not sure what you mean by WebRTC ingest and TRMP forward includes a transcoding.

Does this mean it takes a lower quality video and converts it to higher quality on the AMS side? Will this introduce latency to the video? We want the highest quality video we can with the lowest latency. If this introduces latency, is there another way to force the videos to stream with higher quality than 640x360 direct from the source?

Yes, it may takes a lower quality video and increase the resolution. Actually it does not mean that it increases the quality. It does not add to much latency a couple of hundred of milliseconds. However, it consume processing resources..

If you publish live stream with RTMP, you can keep the quality same all the time. However, it introduces some bufferings if the network is not stable. If you publish live stream with WebRTC, it adjusts the resolution/quality according to the network conditions.

  1. I still can't get it to work. If I change my websocket url to include the rtmpForward=true, as in the example, my stream no longer publishes.

Here is the change I made: image

When I try and publish with that change, I now get an error in the console:

error callback: "server_error_check_logs"

I assume this means to check the ant-media-server.log. But I'm not sure what I should be looking for. I'm seeing lines like these:

2021-10-28 10:11:28,711 [https-jsse-nio2-0.0.0.0-5443-exec-23] WARN i.a.filter.TokenFilterManager - hash undefined is not valid 2021-10-28 10:11:28,739 [vert.x-worker-thread-7] INFO io.antmedia.muxer.HLSMuxer - cannot write video frame to muxer. Error: Invalid argument

But I'm not sure if they are related or not.

If I remove the rtmpFoward=true, that error callback goes away, and it streams again.

I think there are some configuration issues on your end or there is a bug on Ant Media Server, could you please let me know environment and content of the properties file so that I can try to reproduce on my end?

bgatienRoss commented 2 years ago

Thank you for looking into it. Let me know if you need more information than the following.

We are running on an Ubuntu server:

/usr/local/antmedia/webapps/BenG/WEB-INF$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic
rossvideo@dteantserver:/usr/local/antmedia/webapps/BenG/WEB-INF$

Here is my red5 properties file:

#Thu Oct 28 10:00:07 EDT 2021
settings.dataChannelPlayerDistrubution=all
db.app.name=BenG
settings.s3AccessKey=
settings.webRTCFrameRate=30
settings.enableTimeTokenForPlay=false
settings.vodFolder=
settings.webRTCEnabled=true
settings.jwtControlEnabled=false
settings.h265Enabled=false
periscope.clientId=Q90cMeG2gUzC6fImXcp2SvyVqwVSvGDlsFsRF4Uia9NR1M-Zru
facebook.clientSecret=6c02b406d3e94426c5553c3c9bc17345
settings.dataChannelEnabled=false
settings.objectDetectionEnabled=false
settings.h264Enabled=true
db.name=beng
settings.stalkerDBServer=
settings.stalkerDBPassword=
settings.dashMuxingEnabled=false
webapp.virtualHosts=*
settings.hashControlPlayEnabled=true
webapp.contextPath=/BenG
facebook.clientId=1898164600457124
settings.playTokenControlEnabled=false
settings.publishTokenControlEnabled=false
settings.vp8Enabled=false
settings.s3BucketName=
settings.stalkerDBUsername=
settings.allowedPublisherCIDR=
settings.heightRtmpForwarding=720
periscope.clientSecret=dBCjxFbawo436VSWMvuD5SDSZoSdhew_-Fvrh5QhrBXuKoelVM
settings.playJwtControlEnabled=false
settings.webhookAuthenticateURL=
webapp.dbName=beng.db
settings.hlsTime=2
settings.acceptOnlyStreamsInDataStore=false
settings.previewGenerate=false
youtube.clientSecret=HDwoClZhJzPshtmnWjSJSHjx
settings.tokenControlEnabled=false
db.type=mapdb
db.password=
settings.forceAspectRationInTranscoding=false
settings.deleteHLSFilesOnEnded=true
settings.encoderSettingsString=[]
settings.addDateTimeToMp4FileName=false
youtube.clientId=183604002006-3ojdgvmqp7rcc6d66atkkhk7p0btie9j.apps.googleusercontent.com
settings.listenerHookURL=
settings.hlsListSize=5
settings.streamFetcherRestartPeriod=0
settings.hlsEncryptionKeyInfoFile=
db.user=
settings.s3Endpoint=
settings.timeTokenSubscriberOnly=false
settings.hlsPlayListType=
settings.deleteDASHFilesOnEnded=true
settings.publishJwtControlEnabled=false
settings.jwtSecretKey=
settings.s3SecretKey=
settings.enableTimeTokenForPublish=false
settings.hlsMuxingEnabled=false
settings.mp4MuxingEnabled=false
settings.maxResolutionAccept=0
tokenHashSecret=B\!jW)[}[\!eM9HD3@
settings.jwtStreamSecretKey=
settings.webMMuxingEnabled=false
settings.remoteAllowedCIDR=127.0.0.1,10.62.122.165,192.168.86.223,172.17.1.175
settings.createPreviewPeriod=5000     
settings.ipFilterEnabled=true
settings.s3RegionName=
settings.previewOverwrite=false
settings.s3RecordingEnabled=false
db.host=localhost
settings.hashControlPublishEnabled=true
mekya commented 2 years ago

Hi @bgatienRoss ,

I think the problem is about settings.hashControlPublishEnabled=true . Is it possible to make all security stuff to false and try to stream?

I think there is a bug in Ant Media Server. It likely does not accept stream through WebRTC to RTMP when the settings.hashControlPublishEnabled=true