Automatic Transcoding of published Streams fails
Hi,
I just wanted to inform you of a small issue that I encountered. Maybe someone will encounter the same problem, or have additional information regarding this.
I was trying to get evostream to automatically provide a low-quality version of a stream which I published in high quality. I managed to achieve this by adding a "transcode"-api function to evostream web services and adding a plugin which calls this function everytime a stream with a specific name was published.
In the end I could observe how the transcode()-api call arrived at evostream but the evo-avconv binary failed to retrieve the rtsp-stream from evostream for transcoding.
[...]
/thelib/src/netio/epoll/tcpacceptor.cpp:189 Inbound connection accepted: (Far: 127.0.0.1:56488; Near: 127.0.0.1:7777) CTCP(22) <-> TCP(74) <-> IHTT(75) <-> H4C(76) <-> [IJSONCLI(77)]
/thelib/src/application/baseclientapplication.cpp:291 Protocol [ORPC(70)] unregistered from application: evostreamms
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 17->16 IOHT_TCP_CARRIER
/applications/evorouter/src/protocols/cli/cliappprotocolhandler.cpp:606 command: transcode
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 16->15 IOHT_TCP_CARRIER
/thelib/src/application/baseclientapplication.cpp:291 Protocol [IJSONCLI(77)] unregistered from application: evostreamms
/thelib/src/application/baseclientapplication.cpp:291 Protocol [ORPC(73)] unregistered from application: evostreamms
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 15->14 IOHT_TCP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 14->15 IOHT_TCP_CARRIER
/thelib/src/netio/epoll/tcpacceptor.cpp:189 Inbound connection accepted: (Far: 127.0.0.1:37296; Near: 127.0.0.1:5544) CTCP(20) <-> TCP(78) <-> [RTSP(79)]
/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp:2596 Unsupported audio codec for RTSP output
/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp:2625 Unsupported video codec for RTSP output
/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp:677 Unable to compute SDP
/thelib/src/protocols/rtp/rtspprotocol.cpp:393 Unable to handle content
/thelib/src/netio/epoll/tcpcarrier.cpp:95 Unable to read data from connection: (Far: 127.0.0.1:37296; Near: 127.0.0.1:5544) CTCP(20) <-> [TCP(78)] <-> RTSP(79). Signaling upper protocols failed
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 15->14 IOHT_TCP_CARRIER
rtsp://127.0.0.1:5544/myStream2m: Invalid data found when processing input
/thelib/src/application/baseclientapplication.cpp:291 Protocol [RTSP(79)] unregistered from application: evostreamms
[...]
As you see, SDP cannot be executed successfully. However, invoking avconv manually with the exact command line would work just fine.
After several hours debugging i found that apparently the rtsp-stream is not immediately available when a rtmp-stream has been published, which causes the transcoding to fail with the output indicated above. I resolved this issue by adding a short delay right before calling the avconv binary in the "emsTranscoder.sh" scriptfile (line numbers might vary slightly, because I might have inserted debugging instructions here and there):
220
221 # Run the binary
222 sleep 1
223 exec $TRANSCODER_BIN -loglevel error $TRANSCODE
224
Now the output is as expected and the transcoded stream is available for streaming:
[...]
/applications/evorouter/src/protocols/cli/cliappprotocolhandler.cpp:606 command: transcode
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 16->15 IOHT_TCP_CARRIER
/thelib/src/application/baseclientapplication.cpp:291 Protocol [IJSONCLI(106)] unregistered from application: evostreamms
/thelib/src/application/baseclientapplication.cpp:291 Protocol [ORPC(102)] unregistered from application: evostreamms
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 15->14 IOHT_TCP_CARRIER
/thelib/src/streaming/baseoutstream.cpp:435 Audio codec AUNK not supported by stream type OFHLS
/thelib/src/application/baseclientapplication.cpp:233 Protocol handler not activated for protocol type DRM in application evostreamms
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 14->15 IOHT_TCP_CARRIER
/thelib/src/netio/epoll/tcpacceptor.cpp:189 Inbound connection accepted: (Far: 127.0.0.1:37308; Near: 127.0.0.1:5544) CTCP(21) <-> TCP(107) <-> [RTSP(108)]
/thelib/src/application/baseclientapplication.cpp:297 Stream ONP(10) with name `myStream2m` from protocol RTSP(108) registered to origin application `evostreamms`
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 15->16 IOHT_TCP_CONNECTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 16->17 IOHT_UDP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 17->18 IOHT_UDP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 18->19 IOHT_UDP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 19->20 IOHT_UDP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 20->21 IOHT_TCP_CARRIER
/thelib/include/netio/epoll/tcpconnector.h:114 Outbound connection established: (Far: 127.0.0.1:80; Near: 127.0.0.1:53754) CTCP(22) <-> TCP(117) <-> OHTT2(118) <-> [ORPC(119)]
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 21->20 IOHT_TCP_CONNECTOR
/thelib/src/application/baseclientapplication.cpp:291 Protocol [ORPC(119)] unregistered from application: evostreamms
/thelib/src/netio/epoll/iohandlermanager.cpp:130 Handlers count changed: 20->19 IOHT_TCP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 19->20 IOHT_TCP_CARRIER
/thelib/src/protocols/liveflv/baseliveflvappprotocolhandler.cpp:45 protocol (Far: 127.0.0.1:41240; Near: 127.0.0.1:6666) CTCP(22) <-> TCP(120) <-> [ILFL(121)] registered to app evostreamms
/thelib/src/netio/epoll/tcpacceptor.cpp:189 Inbound connection accepted: (Far: 127.0.0.1:41240; Near: 127.0.0.1:6666) CTCP(22) <-> TCP(120) <-> [ILFL(121)]
/thelib/src/application/baseclientapplication.cpp:297 Stream INLFLV(11) with name `myStream100k` from protocol ILFL(121) registered to origin application `evostreamms`
/thelib/src/application/baseclientapplication.cpp:297 Stream OFHLS(12) with name `myStream100k` from protocol PT(122) registered to origin application `evostreamms`
[...]
Hopefully I can save some future googler from the many hours I spent debugging on this one 😉
best,
benny