c2play updated with C4 support

Post Reply
crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

c2play updated with C4 support

Post by crashoverride »

A new version of c2play (command line video player) is available for C4 (note the "c4" branch):
https://github.com/OtherCrashOverride/c2play/tree/c4

The official Ubuntu minimal image was used for testing. If using a different image, ensure the user has read/write access to /dev/ge2d and /dev/ion. X11 is not currently supported.

The build instructions remain unchaged:
1) Install dependencies:

Code: Select all

sudo apt install libasound2-dev libavformat-dev libass-dev
2) Compile

Code: Select all

make c2play -j4
[edit]
It should also work on N2 since the same kernel is used. However, it has not been tested there yet.
These users thanked the author crashoverride for the post (total 3):
odroid (Tue Apr 27, 2021 3:56 pm) • Sebas_Ledesma (Tue Apr 27, 2021 11:32 pm) • nvl1109 (Thu Apr 29, 2021 5:38 pm)

User avatar
odroid
Site Admin
Posts: 37371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1785 times
Been thanked: 1139 times
Contact:

Re: c2play updated with C4 support

Post by odroid »

We've tried compiling on C4 Kernel 4.9.241-70 with the latest minimal image ubuntu-20.04-4.9-minimal-odroid-c4-hc4-20210128.img.xz.
But we met an error message.

Code: Select all

error: ‘CODEC_ID_MPEG2VIDEO’ was not declared in this scope; did you mean ‘AV_CODEC_ID_MPEG2VIDEO’?
We add AV_ and could build it.
But we met the following kernel error message once we ran it.

Code: Select all

root@odroid:~/c2play/c2play# [  147.564332@1] meson-fb meson-fb: create ion_client ffffffc0b54e6300, handle=ffffffc0887f7400
[  147.567167@1] meson-fb meson-fb: ion memory(1): created fb at 0x00000000ea400000, size 1 MiB
[  147.592135@2] meson-fb meson-fb: create ion_client ffffffc0b54e6300, handle=ffffffc088702cc0
[  147.594968@2] meson-fb meson-fb: ion memory(2): created fb at 0x00000000ea500000, size 1 MiB
[  147.610591@1] meson-fb meson-fb: create ion_client ffffffc0b54e6300, handle=ffffffc0887f7300
[  147.613412@1] meson-fb meson-fb: ion memory(3): created fb at 0x00000000ea600000, size 8 MiB
[  147.861767@3] video_port_init 663, vdec_init failed
[  147.861844@3] video_port_init  failed
[  147.865010@0] amstream_do_ioctl error :ffffffffffffffed, 401053c2
Property of ge2d and ion looks fine.

Code: Select all

root@odroid# ls -l /dev/ge2d
crw------- 1 root root 236, 0 Mar 17 21:36 /dev/ge2d
root@odroid# ls -l /dev/ion
crw------- 1 root root 10, 61 Mar 17 21:36 /dev/ion
Anything else we need to check?

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

I am investigating the issue. I still have the test system set up and checked a few things.

The image used to test was:

Code: Select all

$ sha1sum Downloads/ubuntu-20.04-4.9-minimal-odroid-c4-hc4-20210128.img.xz 
5167fc2fc6ee94faa5d75ba159e718ea98b3b1c8  Downloads/ubuntu-20.04-4.9-minimal-odroid-c4-hc4-20210128.img.xz
The kernel version of that image is:

Code: Select all

# uname -r
4.9.241-68

Code: Select all

# gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Code: Select all

root@c4test:~/c2play# grep -r "CODEC_ID_MPEG2VIDEO"
Binary file build/gmake/obj/Debug/MediaSourceElement.o matches
Binary file build/gmake/obj/Debug/SubtitleCodecElement.o matches
Binary file build/gmake/obj/Debug/MediaPlayer.o matches
Binary file build/gmake/obj/Debug/AudioCodec.o matches
Binary file build/gmake/obj/Debug/AlsaAudioSink.o matches
Binary file c2play matches
src/Media/MediaSourceElement.cpp:					case AV_CODEC_ID_MPEG2VIDEO:
[edit]
I performed "apt upgrade" and verified the new kernel also works:

Code: Select all

root@c4test:~/c2play# uname -r
4.9.241-70
Last edited by crashoverride on Wed Apr 28, 2021 12:47 pm, edited 1 time in total.

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

@odroid,
Ensure you are using the "c4" branch:

Code: Select all

root@c4test:~/c2play# git clone -b c4 https://github.com/OtherCrashOverride/c2play.git
The error provided indicates that a different branch was used.
git log should show the following commit as the HEAD:

Code: Select all

commit 1bd3c14c824c62cad871559a0a3684b21f80bc80 (HEAD -> c4, origin/c4)
Author: OtherCrashOverride <OtherCrashOverride@user.noreply.github.com>
Date:   Tue Apr 27 00:31:10 2021 -0500

    Remove EGL/GLES.
[edit]
The 'AV_CODEC_ID_MPEG2VIDEO' value was already changed in the 'bionic' release:
https://github.com/OtherCrashOverride/c ... eea033a1a2

User avatar
neal
Posts: 247
Joined: Fri Apr 14, 2017 10:02 am
languages_spoken: Korean, English
Has thanked: 10 times
Been thanked: 18 times
Contact:

Re: c2play updated with C4 support

Post by neal »

@crashoverride

Yes, it was not using branch "c4".
Using "c4" branch, It could be built and play without issue.
Thanks.

[edit]
ODROID-N2 also can build and play without issue.
I could play 4K(3840x2160), 60fps movie clips on N2 with this c2play.
To build it, I had to install libegl1-mesa-dev or will be exposed "fatal error: EGL/egl.h: No such file or directory".

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

neal wrote:
Wed Apr 28, 2021 2:45 pm
To build it, I had to install libegl1-mesa-dev or will be exposed "fatal error: EGL/egl.h: No such file or directory".
I will investigate this. EGL is no longer used, but there may be a left over reference to it in the code.

User avatar
odroid
Site Admin
Posts: 37371
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1785 times
Been thanked: 1139 times
Contact:

Re: c2play updated with C4 support

Post by odroid »

crashoverride wrote:
Wed Apr 28, 2021 6:16 pm
I will investigate this. EGL is no longer used, but there may be a left over reference to it in the code.
C4 minimal image seems to have libegl1-mesa-dev package by default.

Anyway, @neal has added a build guide to the minimal image release notes.
C4: https://wiki.odroid.com/odroid-c4/os_im ... o_playback
N2: https://wiki.odroid.com/odroid-n2/os_im ... o_playback

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

There are remaining references to EGL/GLES located here:
https://github.com/OtherCrashOverride/c ... .h#L20-L21

The lines can be deleted to enable compilation without EGL/GLES headers. This change will be included in a future commit.

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

Hi @crashoverride,
Thank you for the update of c2play on C4.

Now I have a problem with playing RTSP stream using c2play on C4 (this is not happened on C2). The camera RTSP stream is working ok with kplayer.
I have cloned c2play on c4 branch, compile and try to play RTSP stream from our camera. But c2play always quit with an Exception thrown. Pls see log below.

Code: Select all

root@odroid:~# c2play rtsp://User:5h1e67665@10.10.1.10:554/video1
added device: /dev/input/event2
added device: /dev/input/event1
added device: /dev/input/event0
added device: /dev/input/mice
Device: /dev/input/event2
        bustype=3, vendor=1118, product=1920, version=273
        name=Microsoft Comfort Curve Keyboard 3000
InputDevice entering running state.
Device: /dev/input/event1
        bustype=3, vendor=1118, product=1920, version=273
        name=Microsoft Comfort Curve Keyboard 3000
InputDevice entering running state.
Device: /dev/input/event0
        bustype=16, vendor=7054, product=3308, version=1
        name=cec_input
InputDevice entering running state.
Device: /dev/input/mice
EVIOCGBIT failed.
Using input device: Microsoft Comfort Curve Keyboard 3000
Using input device: Microsoft Comfort Curve Keyboard 3000
Using input device: cec_input
[tcp @ 0x55909d3cc0] Starting connection attempt to 10.10.1.10 port 554
[tcp @ 0x55909d3cc0] Successfully connected to 10.10.1.10 port 554
[rtsp @ 0x5590a13240] SDP:
v=0
o=- 1619767018512254 1 IN IP4 10.10.1.10
s=Video Session streamed by "Steinsvik"
i=Streaming Media v2016.01.08
t=0 0
a=tool:LIVE555 Streaming Media v2015.10.12
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:Video Session streamed by "Steinsvik"
a=x-qt-text-inf:Streaming Media v2016.01.08
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:32768
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=640020;sprop-parameter-sets=Z2QAIK2EAQwgCGEAQwgCGEAQwgCEO1AoA803AQEBAg==,aO48sA==
a=control:track1
m=application 0 RTP/AVP 97
c=IN IP4 0.0.0.0
b=AS:102400
a=rtpmap:97 vnd.onvif.metadata/90000
a=control:event                                                                                                                                                                                         [2/53]

[rtsp @ 0x5590a13240] setting jitter buffer size to 500
[rtsp @ 0x5590a13240] setting jitter buffer size to 500
Source Metadata:
        key=title, value=Video Session streamed by "Steinsvik"
        key=comment, value=Streaming Media v2016.01.08
[h264 @ 0x5590a161e0] Reinit context to 1280x960, pix_fmt: yuvj420p
[rtsp @ 0x5590a13240] max delay reached. need to consume packet
[rtsp @ 0x5590a13240] RTP: missed 17 packets
[h264 @ 0x5590a161e0] concealing 2003 DC, 2003 AC, 2003 MV errors in P frame
[rtsp @ 0x5590a13240] max delay reached. need to consume packet
[rtsp @ 0x5590a13240] RTP: missed 3 packets
[h264 @ 0x5590a161e0] Increasing reorder buffer to 1
[h264 @ 0x5590a161e0] cabac decode of qscale diff failed at 3 7
[h264 @ 0x5590a161e0] error while decoding MB 3 7, bytestream 44676
[h264 @ 0x5590a161e0] concealing 4286 DC, 4286 AC, 4286 MV errors in P frame
[rtsp @ 0x5590a13240] max delay reached. need to consume packet
[rtsp @ 0x5590a13240] RTP: missed 302 packets
[h264 @ 0x5590a161e0] cabac decode of qscale diff failed at 2 21
[h264 @ 0x5590a161e0] error while decoding MB 2 21, bytestream -1
[h264 @ 0x5590a161e0] concealing 3167 DC, 3167 AC, 3167 MV errors in P frame
[rtsp @ 0x5590a13240] max delay reached. need to consume packet
[rtsp @ 0x5590a13240] RTP: missed 25 packets
[rtsp @ 0x5590a13240] max delay reached. need to consume packet
[rtsp @ 0x5590a13240] RTP: missed 169 packets
Duration: -9223372036854.775391
Streams (count=2):
stream #0 - VIDEO/H264
        w=1280 h=960 fps=nan(0/0) SAR=(0/1)
stream #1 - DATA (0x0)
AmlCodec: amstream version : 2.0
AmlVideoSinkElement: calling base.
Element (VideoSink) Flush exited.
AmlVideoSinkElement: Flush exited.
Element (Source) Flush exited.
Element (VideoSink) ChangeState oldState=0 newState=1.
AmlVideoSink: ExtraData size=43
Element (Source) ChangeState oldState=0 newState=1.
AmlVideoSink - VIDEO/H264
        w=1280 h=960 fps=nan am_sysinfo.rate=0
AmlVideoSinkElement: got marker buffer Marker=2
Header (pkt.size=2037e):
1a 28 c4 f9 63 9e ec d3 59 fd b8 fe cd 1e 9e df
isAnnexB=0
isShortStartCode=0
Invalid NAL length=438879481, pkt->size=131966
terminate called after throwing an instance of 'Exception'
Aborted

From the same camera stream, I record into mp4 file with command:

Code: Select all

ffmpeg -i rtsp://User:5h1e67665@10.10.1.10:554/video1 -vcodec copy -acodec copy -y ~/video.mp4
and play the recorded video by c2play c2play ~/video.mp4, c2play works fine, no error or exception.

Do you have any idea to investigate more, or to resolve this problem? Thank you.

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

nvl1109 wrote:
Thu Apr 29, 2021 5:51 pm
Do you have any idea to investigate more, or to resolve this problem?
The log shows that libavformat is passing invalid packets to the decoder. This may be due to a behavior change in libavformat. Kplayer appears to use its own version instead of the system version used by c2play.

The exception that is thrown is because c2play detects that the data is invalid:
https://github.com/OtherCrashOverride/c ... k.cpp#L383

A possible work-around would be to change the "throw Exception();" to "break;" so that the packet is ignored. However, I do not have a way to test this. c2play is only designed to work with reliable streams. Unreliable streams like MPEG-TS and RTSP are not supported.
These users thanked the author crashoverride for the post:
nvl1109 (Thu Apr 29, 2021 6:27 pm)

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

crashoverride wrote:
Thu Apr 29, 2021 6:21 pm
A possible work-around would be to change the "throw Exception();" to "break;" so that the packet is ignored.
I have tried this. Then got many ignored packets.
And nothing was shown on display

Code: Select all

Invalid NAL length=-1881633649, pkt->size=187915
Invalid NAL length=-536301644, pkt->size=51893
Invalid NAL length=-533135428, pkt->size=90333
Invalid NAL length=-531562561, pkt->size=88249
Invalid NAL length=-531058762, pkt->size=53793
Invalid NAL length=-522145868, pkt->size=51831
Invalid NAL length=-521621577, pkt->size=54415
Invalid NAL length=1677729965, pkt->size=134499
Invalid NAL length=-536281144, pkt->size=76733
Invalid NAL length=-535756864, pkt->size=75214
Invalid NAL length=-535253074, pkt->size=51884
Invalid NAL length=-534728787, pkt->size=56024
Invalid NAL length=-534184004, pkt->size=81934
Invalid NAL length=-533680203, pkt->size=51885
Invalid NAL length=-533135416, pkt->size=86256
Invalid NAL length=-532631629, pkt->size=53328
Invalid NAL length=-532086851, pkt->size=87948
Invalid NAL length=-531590145, pkt->size=41907
Invalid NAL length=-531038276, pkt->size=90438
Invalid NAL length=-530541569, pkt->size=40844
Invalid NAL length=-530010186, pkt->size=59567
Invalid NAL length=-529465412, pkt->size=86553
Invalid NAL length=-528961614, pkt->size=53839
Invalid NAL length=-528416831, pkt->size=86894
Invalid NAL length=-527892543, pkt->size=82917

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

I have no way to reproduce this issue for debuggin. I do not have any RTSP devices and can not locate any public streams.

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

I was able to reproduce the issue using VLC as a local RTSP server. The issue is caused by partial data being passed to c2play. This defeats the format identification discovery (Annex B). Based on FFMPEG source code, the RTP payload is always output as Annex B. The following patch works around the issue:

Code: Select all

diff --git a/src/Media/AmlVideoSink.cpp b/src/Media/AmlVideoSink.cpp
index a1be1ec..f9c84f5 100755
--- a/src/Media/AmlVideoSink.cpp
+++ b/src/Media/AmlVideoSink.cpp
@@ -380,7 +380,9 @@ void AmlVideoSinkElement::ProcessBuffer(AVPacketBufferSPTR buffer)
                                        if (nalLength < 0 || nalLength > pkt->size)
                                        {
                                                printf("Invalid NAL length=%d, pkt->size=%d\n", nalLength, pkt->size);
-                                               throw Exception();
+
+                                               isAnnexB = true;
+                                               break;
                                        }
 
                                        nalHeader[0] = 0;
These users thanked the author crashoverride for the post (total 2):
nvl1109 (Fri Apr 30, 2021 9:15 am) • odroid (Fri Apr 30, 2021 9:18 am)

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

Thank you for the quick patch. I have applied, and result is:

Code: Select all

AmlVideoSinkElement: got marker buffer Marker=2                                                       
Header (pkt.size=4c26):                                                                               
2a 80 f0 68 1d 04 12 8b 30 ea 98 53 c4 19 3c 3f 
isAnnexB=0                                                                                            
isShortStartCode=0                                 
Invalid NAL length=713093224, pkt->size=19494
codec_write max attempts exceeded.                                                                    
AmlVideoSink - VIDEO/H264                                                                             
        w=1280 h=960 fps=59.940060 am_sysinfo.rate=1602 
AmlVideoSinkElement::ProcessBuffer - SendData Failed.
[rtsp @ 0x5571019750] max delay reached. need to consume packet
[rtsp @ 0x5571019750] RTP: missed -50279 packets                                                      
[rtsp @ 0x5571019750] RTP: PT=60: bad cseq 06e3 expected=cb4a                                         
[rtsp @ 0x5571019750] max delay reached. need to consume packet                                       
[rtsp @ 0x5571019750] RTP: missed -50278 packets                                                      
codec_write max attempts exceeded.                                                                    
AmlVideoSink - VIDEO/H264                                                                             
        w=1280 h=960 fps=59.940060 am_sysinfo.rate=1602                                               
AmlVideoSinkElement::ProcessBuffer - SendData Failed.                                                 
[rtsp @ 0x5571019750] max delay reached. need to consume packet                                       
[rtsp @ 0x5571019750] RTP: missed 15307 packets                                                       
[rtsp @ 0x5571019750] RTP: PT=60: bad cseq 4fc0 expected=13f5                                         
[rtsp @ 0x5571019750] max delay reached. need to consume packet                                       
[rtsp @ 0x5571019750] RTP: missed 15308 packets                                                       
codec_write max attempts exceeded.                                                                    
AmlVideoSink - VIDEO/H264     
        w=1280 h=960 fps=59.940060 am_sysinfo.rate=1602 
AmlVideoSinkElement::ProcessBuffer - SendData Failed.
[rtsp @ 0x5571019750] max delay reached. need to consume packet
[rtsp @ 0x5571019750] RTP: missed 15317 packets                                                       
[rtsp @ 0x5571019750] RTP: PT=60: bad cseq 98fc expected=5d27                                         
[rtsp @ 0x5571019750] max delay reached. need to consume packet                                       
[rtsp @ 0x5571019750] RTP: missed 15318 packets                                                       
codec_write max attempts exceeded.                                                                    
AmlVideoSink - VIDEO/H264    
Looks like no video was shown (remote working, but the camera is too far from the display :D).
crashoverride wrote:
Thu Apr 29, 2021 6:21 pm
The log shows that libavformat is passing invalid packets to the decoder. This may be due to a behavior change in libavformat. Kplayer appears to use its own version instead of the system version used by c2play.
Do you think compiling libavformat from source and link c2play with new libavformat will solve the problem?

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

nvl1109 wrote:
Fri Apr 30, 2021 9:18 am
Do you think compiling libavformat from source and link c2play with new libavformat will solve the problem?
The output log shows two things happening:
1) "codec_write max attempts exceeded." - This indicates the hardware codec kernel driver is "locked up". When c2play detects this, it resets the codec.
2) "RTP: missed 15308 packets " - While the codec reset is happening, data loss is occurring.

Check the output of dmesg for messages from the kernel driver. This may provide additional clues as to why it is locked up. Also try rebooting the C4.

User avatar
rooted
Posts: 8512
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 740 times
Been thanked: 345 times
Contact:

Re: c2play updated with C4 support

Post by rooted »

Thank you for integrating C4 support, I have seen several people wanting to use it in their projects.

Such as booting straight into playing videos.

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

crashoverride wrote:
Fri Apr 30, 2021 3:03 pm
The output log shows two things happening:
1) "codec_write max attempts exceeded." - This indicates the hardware codec kernel driver is "locked up". When c2play detects this, it resets the codec.
2) "RTP: missed 15308 packets " - While the codec reset is happening, data loss is occurring.

Check the output of dmesg for messages from the kernel driver. This may provide additional clues as to why it is locked up. Also try rebooting the C4.
Thank you for suggestion. I am waiting for C4 arrival to continue the debugging. I will get back to you soon.

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

crashoverride wrote:
Fri Apr 30, 2021 3:03 pm
nvl1109 wrote:
Fri Apr 30, 2021 9:18 am
Do you think compiling libavformat from source and link c2play with new libavformat will solve the problem?
The output log shows two things happening:
1) "codec_write max attempts exceeded." - This indicates the hardware codec kernel driver is "locked up". When c2play detects this, it resets the codec.
2) "RTP: missed 15308 packets " - While the codec reset is happening, data loss is occurring.

Check the output of dmesg for messages from the kernel driver. This may provide additional clues as to why it is locked up. Also try rebooting the C4.
Hi @crashoverride,

I have found that the problem is not in c2play, but it is in the aml-libs package. The libavformat was used from that package. If I don't install aml-libs before compiling c2play, c2play will work without issue.

On another hand, c2play is high latency on RTSP stream playing. It is about 2 seconds at starting, but the latency is decreasing time to time, after 30minutes continue playing, the latency could be 100-200ms.
I have made the similar code (using your AmlCodec class, but the RTSP client is live555 (customized testRTSPClient example from live555)), and got the same behavior with latency.
Kplayer (in aml-libs package) plays the same RTSP stream with very good latency all the time (about 300ms).

Do you think the problem with latency is about timestamp of hardware decoder or any idea?

PS:
If I run kplayer once, then quit kplayer, and then run c2play, the latency is so low from starting of c2play. This effect is kept for all other times c2play running. So I think kplayer has done some settings in VPU for getting low latency. Just don't know what is that setting :)

crashoverride
Posts: 5358
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 448 times
Contact:

Re: c2play updated with C4 support

Post by crashoverride »

nvl1109 wrote:
Mon May 03, 2021 6:42 pm
Do you think the problem with latency is about timestamp of hardware decoder or any idea?
C2play was not designed for live streaming. In a live streaming scenario, it is necessary for the source to provide a reference clock.

C2play typically uses audio to provide the reference clock.
https://github.com/OtherCrashOverride/c ... k.cpp#L366

If an audio stream is not present, the clock is derived by the hardware codec. Over time, either clock will diverge from the source. The result will be a varying latency that drifts over time. To correct this, the clock will need to be derived from the stream (RTP/MPEG-TS).

nvl1109 wrote:
Mon May 03, 2021 6:42 pm
If I run kplayer once, then quit kplayer, and then run c2play, the latency is so low from starting of c2play. This effect is kept for all other times c2play running. So I think kplayer has done some settings in VPU for getting low latency. Just don't know what is that setting
It is likely setting "Free Run". This disables the clock used by the hardware codec and processes video in real-time instead. An example can be found here:
https://github.com/OtherCrashOverride/m ... #L113-L130

[edit]
It should also be possible to set "Free Run" mode using sysfs:

Code: Select all

echo "1" | sudo tee /sys/class/video/freerun_mode 
These users thanked the author crashoverride for the post:
nvl1109 (Mon May 03, 2021 8:08 pm)

nvl1109
Posts: 28
Joined: Fri Aug 11, 2017 3:41 pm
languages_spoken: english
ODROIDs: C2
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: c2play updated with C4 support

Post by nvl1109 »

You are right. Thank you for detail clarifications. Have a nice day :)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 2 guests