Video copy transcoding issue
Hi,
I’m trying to use EMS as a streaming service for passive viewers of a WebRTC room.
A this time I ingest video and audio as raw RTP using a SDP file description.
The video is H264, but audio is opus so I have to trancode it.
Here are my tries:
1/ Ingest video using such a SDP content :
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
m=video 51000 RTP/AVP 107
c=IN IP4 127.0.0.1
b=AS:0
a=rtpmap:107 H264/90000
a=fmtp:107 packetization-mode=1; sprop-parameter-sets=Z0LAH4yNQFAXvLAPCIRq,aM48gA==; profile-level-id=42C01F
a=control:trackID=1then pulling it with :
pullStream uri=file:///streams/demo1234-video.sdp localStreamName=demo-videoand test it as RTMP, RTSP, DAH and HLS with success in several browsers/players (except Safari but I think I will make a separate post for that) 2/ Ingest audio with :
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
m=audio 51004 RTP/AVP 111
c=IN IP4 127.0.0.1
a=rtpmap:111 opus/48000/2
a=fmtp:111 sprop-stereo=1
a=control:trackID=1then pull it with
transcode source=file:///streams/demo1234-audio.sdp destinations=demo-audio audioBitrates=48kand test it as RTMP and RTSP again with success (problem with DASH and HLS, but once again need a separate post). 3/ Finally tried to mux audio and video by merging SDP files as a unique one and pull it using a unique transcode call, adding ‘videoBitrates=copy’ to previous one. this time, audio still OK, but video is broken (just get frozen images time to time). As a double check, I pull the video only SDP with transcode, and I have the same effect on video. It seems that the transcode utility does not just passthrough the video stream. I didn’t find any relevant messages in logs. Is there a way to mux my 2 rtp streams without giving the video one to transcode ? Laurent.
1 Answers
Going further in tests, I tried direct access to evo-avconv command.
Seems that using the command spawn by EMS, lots of packet are lost :
/usr/bin/evo-avconv -y -re -i /streams/demo1234.sdp -c:v copy -b:a 48k -c:a libfaac -metadata streamName=demo demo.mp4And indeed resulting mp4 file is of poor quality But when trying the same without the -re parameter I got a good result :
avconv version 11.3, Copyright (c) 2000-2014 the Libav developers
built on Nov 5 2015 01:43:29 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
[h264 @ 0x2619f20] non-existing PPS 31 referenced
Last message repeated 1 times
[h264 @ 0x2619f20] decode_slice_header error
[h264 @ 0x2619f20] no frame!
[h264 @ 0x2619f20] non-existing PPS 31 referenced
Last message repeated 1 times
[h264 @ 0x2619f20] decode_slice_header error
[h264 @ 0x2619f20] no frame!
[sdp @ 0x26031c0] Estimating duration from bitrate, this may be inaccurate
Input #0, sdp, from '/streams/demo1234.sdp':
Metadata:
title : No Name
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 640x360, 29.97 fps, 90k tbn
Stream #0.1: Audio: opus, 48000 Hz, stereo, fltp
Output #0, mp4, to 'demo.mp4':
Metadata:
title : No Name
streamName : demo
encoder : Lavf56.1.0
Stream #0.0: Video: libx264, yuv420p, 640x360, q=2-31, 90k tbn, 90k tbc
Stream #0.1: Audio: libfaac, 48000 Hz, stereo, s16, 48 kb/s
Metadata:
encoder : Lavc56.1.0 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (opus (native) -> aac (libfaac))
Press ctrl-c to stop encoding
RTP: missed 7 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 3 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 1 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 1 packets
RTP: missed 2 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 3 packets
[NULL @ 0x2619f20] RTP: missed 2 packets
RTP: missed 2 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 5 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 2 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 4 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 1 packets
RTP: missed 2 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 2 packets
[NULL @ 0x2619f20] RTP: missed 1 packets
RTP: missed 3 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 2 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 5 packets
RTP: missed 3 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 4 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 2 packets
RTP: missed 3 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 3 packets
RTP: missed 1 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 1 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
RTP: missed 1 packets=-1.0 size= 3kB time=0.58 bitrate= 48.2kbits/s
[NULL @ 0x2619f20] RTP: missed 2 packets
^Cframe= 287 fps= 27 q=-1.0 Lsize= 893kB time=0.66 bitrate=11057.8kbits/s
video:883kB audio:4kB other streams:0kB global headers:0kB muxing overhead: 0.606540%
Received signal 2: terminating.
/usr/bin/evo-avconv -y -i /streams/demo1234.sdp -c:v copy -b:a 48k -c:a libfaac -metadata streamName=demo demo.mp4I then modified the emsTrancoder script to remove the -re option, but still not get satisfying result in video stream (audio is ok). I see that ‘-re’ stand for ‘read input at native frame rate’, not sure of what this mean if this option is not set. Resulting video files in my tests when I remove this option seems Ok, with correct video/audio synchronisation, however video part of RTMP/RTSP streams still not correct. –Laurent.
avconv version 11.3, Copyright (c) 2000-2014 the Libav developers
built on Nov 5 2015 01:43:29 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
[h264 @ 0x1894f20] non-existing PPS 36 referenced
Last message repeated 1 times
[h264 @ 0x1894f20] decode_slice_header error
[h264 @ 0x1894f20] no frame!
[sdp @ 0x187e1a0] Estimating duration from bitrate, this may be inaccurate
Input #0, sdp, from '/streams/demo1234.sdp':
Metadata:
title : No Name
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 640x360, 29.97 fps, 90k tbn
Stream #0.1: Audio: opus, 48000 Hz, stereo, fltp
Output #0, mp4, to 'demo.mp4':
Metadata:
title : No Name
streamName : demo
encoder : Lavf56.1.0
Stream #0.0: Video: libx264, yuv420p, 640x360, q=2-31, 90k tbn, 90k tbc
Stream #0.1: Audio: libfaac, 48000 Hz, stereo, s16, 48 kb/s
Metadata:
encoder : Lavc56.1.0 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (opus (native) -> aac (libfaac))
Press ctrl-c to stop encoding
^Cframe= 465 fps= 31 q=-1.0 Lsize= 1597kB time=15.50 bitrate= 843.8kbits/s
video:1486kB audio:97kB other streams:0kB global headers:0kB muxing overhead: 0.829798%
Received signal 2: terminating.