Command line video player

Post Reply
User avatar
HeinrichG
Posts: 46
Joined: Wed Jul 05, 2017 11:19 pm
languages_spoken: english, german
ODROIDs: C2
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by HeinrichG » Fri Jul 07, 2017 10:22 pm

Sounds cool.

But, the question is, TV stream is not the same like video file stream? Or?
Regards,
Heinrich

rpcameron
Posts: 278
Joined: Sat Apr 30, 2016 7:24 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by rpcameron » Fri Jul 07, 2017 10:30 pm

HeinrichG wrote:Sounds cool.

But, the question is, TV stream is not the same like video file stream? Or?
In short, yes: a TV stream is exactly like a video file stream.

Generally, TV streams are nothing more than MPEG-TS streams, perhaps with some additional data or program streams embedded. However, nearly every video player that can handle MPEG-TS can handle a live TV stream.

Usually, this meant MPEG2 video and AC3/DTS audio (and possibly teletext or dvbsub as well). Many providers are now using h.264 for their video streams, although Germany's DVB-T2 has moved to h.265. I am uncertain if audio codecs are changing, but here in the US they are all essentially still AC3 as that is the ATSC standard (which most cable operators send as well).

User avatar
HeinrichG
Posts: 46
Joined: Wed Jul 05, 2017 11:19 pm
languages_spoken: english, german
ODROIDs: C2
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by HeinrichG » Fri Jul 07, 2017 10:56 pm

Ah, okay, I see.

Thank you very much for explanation :)
Regards,
Heinrich

User avatar
HeinrichG
Posts: 46
Joined: Wed Jul 05, 2017 11:19 pm
languages_spoken: english, german
ODROIDs: C2
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by HeinrichG » Sun Jul 23, 2017 2:26 am

@crashoverride: Which kernel version are you using? It's important for me to know, because I'm implementing a kernel driver for bus connection for my car. My C2 is a DVD-Changer replacement.

Many thanks!
Regards,
Heinrich

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

Re: Command line video player

Post by crashoverride » Sun Jul 23, 2017 3:29 am

Testing is done with the official Ubuntu image using the official kernel 3.14:
https://github.com/hardkernel/linux/tre ... dc2-3.14.y

User avatar
HeinrichG
Posts: 46
Joined: Wed Jul 05, 2017 11:19 pm
languages_spoken: english, german
ODROIDs: C2
Location: Germany
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by HeinrichG » Sun Jul 23, 2017 9:40 pm

Thank you for a fast answer.

So, I've to implement the discovering of device without device tree support.

EDIT: Oh, no, 3.14 is supporting device tree :)
Regards,
Heinrich

spongman
Posts: 22
Joined: Sat Mar 04, 2017 12:32 pm
languages_spoken: english
ODROIDs: c2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by spongman » Thu Aug 03, 2017 4:49 am

can you verify that any of these VOBs play with c2play-x11? http://www.digital-digest.com/movies/mo ... ype=studio

i don't see any errors, but i just get a blank screen...

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

Re: Command line video player

Post by crashoverride » Mon Aug 07, 2017 8:48 pm

spongman wrote:can you verify that any of these VOBs play with c2play-x11?
I tested the first video on the list "Trailer: 20th Century Fox". It plays without any issues.

Testing was done using the 'next' branch:
https://github.com/OtherCrashOverride/c2play/tree/next

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 5:28 pm

Would you have any clue what keys to use to adjust the volume when using c2play? The volume button on my Dell AC511 USB sound bar does not do anything either the following two keys:
- = decrease volume
+ = increase volume

Any suggestion how to fix it?

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Wed Aug 09, 2017 5:31 pm

Can you run evtest, select your keyboard and press those keys to see what codes are sent to the operating system?

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 6:04 pm

Here you go the output of the evtest command:

Input device ID: bus 0x3 vendor 0xe8f product 0x20 version 0x110
Input device name: "GASIA PS2toUSB Adapter"
Supported events:
----------------------------------------
Event code 74 (KEY_KPMINUS)
Event code 75 (KEY_KP4)
Event code 76 (KEY_KP5)
Event code 77 (KEY_KP6)
Event code 78 (KEY_KPPLUS)
---------------------------------------
Properties:
Testing ... (interrupt to exit)

Event: time 1502269210.058692, -------------- SYN_REPORT ------------
Event: time 1502269212.883522, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70057
Event: time 1502269212.883522, type 1 (EV_KEY), code 78 (KEY_KPPLUS), value 1
Event: time 1502269212.979552, -------------- SYN_REPORT ------------
Event: time 1502269216.716659, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70056
Event: time 1502269216.716659, type 1 (EV_KEY), code 74 (KEY_KPMINUS), value 1
Event: time 1502269216.716659, -------------- SYN_REPORT ------------

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

Re: Command line video player

Post by crashoverride » Wed Aug 09, 2017 6:25 pm

c2play does not have any interaction with volume. If you are using X11, the volume keys are handled by the desktop environment (MATE, LXDE, etc). If you are using fbdev, there is nothing managing the keys/volume unless you add it.

[edit]
If you are using X11 and the volume keys are not working, it is likely because c2play has grabbed the device for exclusive access preventing X11 from seeing the key events.

[edit2]
You can disabled "grab" mode for devices by commenting out the following lines:
https://github.com/OtherCrashOverride/c ... pp#L74-L79

Code: Select all

	long arg = 1;
	io = ioctl(fd, EVIOCGRAB, arg);
	if (io < 0)
	{
		throw Exception("EVIOCGRAB failed.\n");
	}

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 6:44 pm

How do I know if I am using X11 or fbdev? Which file should I look for to do that?

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

Re: Command line video player

Post by crashoverride » Wed Aug 09, 2017 6:59 pm

If you only see black console with white text, then you are using fbdev. If you see a graphical environment with colors, menus, and icons, then you are using X11.

If you are using fbdev, the command is "c2play". If you are using X11, the command is "c2play-x11".

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 7:53 pm

I am using Ubuntu MATE environment to perform all the daily task. I open videos using c2play-X11 command in the MATE terminal. That means I should use X11.

You said "You can disabled "grab" mode for devices by commenting out the following lines: https://github.com/OtherCrashOverride/c ... pp#L74-L79" -- how should I do this? Which file to alter those lines?

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

Re: Command line video player

Post by crashoverride » Wed Aug 09, 2017 8:04 pm

raduj wrote:Which file to alter those lines?
The file is evident from the link. In the place where you cloned the git repo for c2play, the file will be:
src/UI/InputDevice.cpp

It currently reads (lines 74 through 79):

Code: Select all

   long arg = 1;
   io = ioctl(fd, EVIOCGRAB, arg);
   if (io < 0)
   {
      throw Exception("EVIOCGRAB failed.\n");
   }
Change it to:

Code: Select all

   //long arg = 1;
   //io = ioctl(fd, EVIOCGRAB, arg);
   //if (io < 0)
   //{
   //   throw Exception("EVIOCGRAB failed.\n");
   //}
Then issue the "make c2play-x11" command again to rebuild with the changes.

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 8:27 pm

I have commented those lines and issued again "make c2play-x11" command. But still I can't adjust the volume with + and - keys. The interesting thing I have noticed is once I launch the c2player the NumLock and all the numeric keys don't respond anymore.

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Wed Aug 09, 2017 8:45 pm

Make sure you're running the new c2play-x11, and not the old one from /usr/local/bin. Either run a make install or copy it manually to override the old one.

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Wed Aug 09, 2017 9:15 pm

What would be the full steps to run the new c2play-x11?

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Wed Aug 09, 2017 10:35 pm

In case you're running it locally, from the build directory try ./c2play-x11 /path/to/movie.mp4. In case you're testing it through odroid.c2.video.helper, then you need to copy the new c2play-x11 to /usr/local/bin and overwrite the old one.

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Thu Aug 10, 2017 4:55 pm

This is what I did and I can adjust now the volume only using the knob on the AC511 bar. Still no luck with using + and - keys

odroid@odroid64:~$ cd c2play/
odroid@odroid64:~/c2play$ sudo cp c2play-x11 /usr/local/bin/c2play-x11

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Thu Aug 10, 2017 5:22 pm

Do the keys work for adjusting volume when c2play-x11 is not running?

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Thu Aug 10, 2017 6:13 pm

This is the output of the evtest command:
odroid@odroid64:~$ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0: Dell Dell AC511 USB SoundBar
/dev/input/event1: GASIA PS2toUSB Adapter
/dev/input/event2: cec_input
/dev/input/event3: vt-input
/dev/input/event4: GASIA PS2toUSB Adapter
/dev/input/event5: meson-ir
/dev/input/event6: MCE IR Keyboard/Mouse (meson-ir)
/dev/input/event7: lircd
Select the device event number [0-7]: 1
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xe8f product 0x20 version 0x110
Input device name: "GASIA PS2toUSB Adapter"
Supported events:
Event type 0 (EV_SYN)
---------------------------------------------------------
Event code 69 (KEY_NUMLOCK)
Event code 70 (KEY_SCROLLLOCK)
--------------------------------------------------
Event code 74 (KEY_KPMINUS)
------------------------------------------------------
Event code 78 (KEY_KPPLUS)
-----------------------------------------------------
Event code 113 (KEY_MUTE)
Event code 114 (KEY_VOLUMEDOWN)
Event code 115 (KEY_VOLUMEUP)
-------------------------------------------------------

Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Event type 17 (EV_LED)
Event code 0 (LED_NUML) state 1
Event code 1 (LED_CAPSL) state 0
Event code 2 (LED_SCROLLL) state 0
Key repeat handling:
Repeat type 20 (EV_REP)
Repeat code 0 (REP_DELAY)
Value 250
Repeat code 1 (REP_PERIOD)
Value 33
Properties:
Testing ... (interrupt to exit)
Event: time 1502355862.910707, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70058
Event: time 1502355862.910707, type 1 (EV_KEY), code 96 (KEY_KPENTER), value 0
Event: time 1502355862.910707, -------------- SYN_REPORT ------------
Event: time 1502355862.997518, type 17 (EV_LED), code 0 (LED_NUML), value 0
Event: time 1502355862.997518, -------------- SYN_REPORT ------------
Event: time 1502355867.776157, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70057
Event: time 1502355867.776157, type 1 (EV_KEY), code 78 (KEY_KPPLUS), value 1
Event: time 1502355867.776157, -------------- SYN_REPORT ------------
+Event: time 1502355867.856181, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70057
Event: time 1502355867.856181, type 1 (EV_KEY), code 78 (KEY_KPPLUS), value 0
Event: time 1502355867.856181, -------------- SYN_REPORT ------------
Event: time 1502355872.785638, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70053
Event: time 1502355872.785638, type 1 (EV_KEY), code 69 (KEY_NUMLOCK), value 1
Event: time 1502355872.785638, -------------- SYN_REPORT ------------
Event: time 1502355872.937681, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70053
Event: time 1502355872.937681, type 1 (EV_KEY), code 69 (KEY_NUMLOCK), value 0
Event: time 1502355872.937681, -------------- SYN_REPORT ------------
Event: time 1502355876.810828, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70056
Event: time 1502355876.810828, type 1 (EV_KEY), code 74 (KEY_KPMINUS), value 1
Event: time 1502355876.810828, -------------- SYN_REPORT ------------
-Event: time 1502355876.890853, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70056
Event: time 1502355876.890853, type 1 (EV_KEY), code 74 (KEY_KPMINUS), value 0
Event: time 1502355876.890853, -------------- SYN_REPORT ------------

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Thu Aug 10, 2017 6:40 pm

I see the keys are registered, but does ALSA, Pulseaudio take that into account?

raduj
Posts: 38
Joined: Wed Dec 07, 2016 6:24 pm
languages_spoken: english
ODROIDs: N/A
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by raduj » Thu Aug 10, 2017 7:49 pm

I can see the volume is increasing/decreasing when pressing +/- keys in ALSA mixer window opened with the following command:

odroid@odroid64:~$ alsamixer

little-ant
Posts: 6
Joined: Thu Aug 10, 2017 11:24 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by little-ant » Mon Aug 14, 2017 12:12 pm

crashoverride wrote:c2play is updated with support for FLAC audio.

Additionally, experimental support for separate video and audio streams in implemented in the "dualstream" branch:
https://github.com/OtherCrashOverride/c2play/issues/12
https://github.com/OtherCrashOverride/c ... dualstream

./c2play-x11 http://video_stream --dual https://audio_stream
Hi @crashoverride.
Can c2play play dual video streams synchronously?

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

Re: Command line video player

Post by crashoverride » Mon Aug 14, 2017 5:36 pm

little-ant wrote:Can c2play play dual video streams synchronously?
The current design accounts for only a single video stream on a single device. You should elaborate on the scenario of dual video streams since I am uncertain what the use case is. I will add that when the 4.x kernel with V4L codec interfaces becomes available, there will be more flexibility in what scenarios are possible.

little-ant
Posts: 6
Joined: Thu Aug 10, 2017 11:24 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by little-ant » Mon Aug 14, 2017 6:25 pm

my case is I want to play/watch two videos at the same time.
I’ve tried with mpv player and mplayer by opening two instances at the same time but they’re quite slow when playing two 1K videos.
I found that c2paly use hardware video acceleration so I want to ask about possibility of playing two videos at the same time ( I have a 4K screen :D )

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

Re: Command line video player

Post by crashoverride » Mon Aug 14, 2017 7:21 pm

That is a scenario that is currently unsupported. c2play uses the hardware video layer for presentation. This limits it to a single, full screen output. If the 4.x kernel exposes multiple video planes (I am uncertain if there is one or two) and the V4L codecs maintain multiple codec contexts (I am uncertain if the current amlvideo does or not), then the feature could be added. There may be support in Android for doing it, but I have never used Android on C2. Android, while based on the linux kernel, provides a standardized API and model for video and graphics.

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Sat Sep 23, 2017 7:13 pm

Trying to modify c2play samples to play mp4 h264 encoded video on C1

Code: Select all

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './data/media/eps_3_2014.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.40.101
  Duration: 00:00:29.02, start: 0.021333, bitrate: 7677 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080, 7550 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Decoding thread implementation:

Code: Select all


   init_display();

   FILE_LOG(logDEBUG) << "hwplayer::playerThreadFunc(" << videoStmIdx << ")";

   AVStream* stream = formatCtx_->streams[videoStmIdx];

   double frameRate = av_q2d(stream->avg_frame_rate);
   FILE_LOG(logDEBUG) << "avg_frame_rate=" << frameRate;

   codec_para_t codecContext = { 0 };
   codecContext.am_sysinfo.param = 0;

   codecContext.stream_type = STREAM_TYPE_ES_VIDEO;
   codecContext.video_type = VFORMAT_H264;
   codecContext.has_video = 1;
   codecContext.noblock = 0;
   codecContext.am_sysinfo.width = stream->codecpar->width;
   codecContext.am_sysinfo.height = stream->codecpar->height;
   codecContext.am_sysinfo.format = VIDEO_DEC_FORMAT_H264;
   codecContext.am_sysinfo.rate = 96000.0 / frameRate;
   codecContext.am_sysinfo.param = (void *)(EXTERNAL_PTS | SYNC_OUTSIDE);

   int err = codec_init(&codecContext);
   if (err != 0) {
      FILE_LOG(logERROR) << "codec_init failed " << err;
      return;

   AVPacket packet;
   while (av_read_frame(formatCtx_, &packet) >= 0) {
      // Is this a packet from the video stream?
      if (packet.stream_index == videoStmIdx) {

         int left = packet.size;
         while (left > 0) {
            FILE_LOG(logDEBUG) << packet.pos << ": sz=" << packet.size << ", "
               "left=" << left;

            int pos = packet.size - left;
            int read = codec_write(&codecContext, packet.data + pos, left);
            if (read < 0) {
               FILE_LOG(logWARNING) << "hw codec write err=" << err << " "
                  "err=" << errno << ", EAGAIN=" << EAGAIN;
               codec_reset(&codecContext);
               break;
            }

            left -= read;
         }
      }
      av_packet_unref(&packet);
   }

   codec_close(&codecContext);

   restore_display();

codec_write consumes data without errors, but nothing on the screen, could someone please advice what to check first?

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

Re: Command line video player

Post by crashoverride » Sun Sep 24, 2017 5:43 pm

extphy wrote:Trying to modify c2play samples to play mp4 h264 encoded video on C1
The hardware decoder expects h264 Annex B formatted streams. Mp4 strips this info. You will need to manually send the "extra data":
https://github.com/OtherCrashOverride/c ... #L842-L895

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Sun Sep 24, 2017 9:32 pm

Thank you crashoverride!

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Tue Sep 26, 2017 2:51 pm

crashoverride wrote:
extphy wrote:Trying to modify c2play samples to play mp4 h264 encoded video on C1
The hardware decoder expects h264 Annex B formatted streams. Mp4 strips this info. You will need to manually send the "extra data":
https://github.com/OtherCrashOverride/c ... #L842-L895
Seems that av_bitstream_filter_filter is also worth try: http://libav-user.ffmpeg.narkive.com/II ... to-annex-b

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Tue Sep 26, 2017 6:51 pm

crashoverride wrote:
extphy wrote:Trying to modify c2play samples to play mp4 h264 encoded video on C1
The hardware decoder expects h264 Annex B formatted streams. Mp4 strips this info. You will need to manually send the "extra data":
https://github.com/OtherCrashOverride/c ... #L842-L895
Crashoverride, could you please clarify, do we have to limit speed of feeding data into codec_write(), assuming we have codec_para_t.noblock==0?

I see that without some reasonable sleep between av_read_frame calls, it gets EOF long before video is completely displayed on the screen, what a kind of effect is it?

Code: Select all

   codec_para_t codecContext = { 0 };
   codecContext.am_sysinfo.param = 0;

   codecContext.stream_type = STREAM_TYPE_ES_VIDEO;
   codecContext.video_type = VFORMAT_H264;
   codecContext.has_video = 1;
   codecContext.has_audio = 0;
   codecContext.noblock = 0;
   codecContext.am_sysinfo.width = stream->codecpar->width;
   codecContext.am_sysinfo.height = stream->codecpar->height;
   codecContext.am_sysinfo.format = VIDEO_DEC_FORMAT_H264;
   codecContext.am_sysinfo.rate = 96000.0 / frameRate;
   codecContext.am_sysinfo.param = (void *)(EXTERNAL_PTS | SYNC_OUTSIDE);

   err = codec_init(&codecContext);
   if (err != 0) {
      FILE_LOG(logERROR) << "codec_init failed " << err;
      av_bsf_free(&bsf);
      return;
   }

   err = codec_init_cntl(&codecContext);
   if (err != 0) {
      FILE_LOG(logERROR) << "codec_init_cntl failed " << err;
      av_bsf_free(&bsf);
      return;
   }
   codec_set_cntl_avthresh(&codecContext, AV_SYNC_THRESH);
   codec_set_cntl_syncthresh(&codecContext, codecContext.has_audio);
   
   AVPacket packet;
   while (true) {

      unsigned int usecs = 10000; // this delay helps to see more video on the screen
      usleep(usecs);

      err = av_read_frame(formatCtx_, &packet);
      if (err < 0) {
         string errStr(averr2str(err));
         FILE_LOG(logDEBUG) << "read err=" << err << ", "
            "errstr=" << errStr;
         break;
      }

      // Is this a packet from the video stream?
      if (packet.stream_index == videoStmIdx) {

         err = av_bsf_send_packet(bsf, &packet);
         if (err < 0) {
            FILE_LOG(logERROR) << "cannot send packet to bsf";
            continue;
         }

         err = av_bsf_receive_packet(bsf, &packet);
         if (err < 0) { // TODO check EAGAIN
            FILE_LOG(logERROR) << "cannot recieve packet";
            continue;
         }

         codec_checkin_pts(&codecContext, packet.pts);

         int left = packet.size;
         while (left > 0) {
            FILE_LOG(logDEBUG) << packet.pos << ": sz=" << packet.size << ", "
               "left=" << left << ", pts=" << packet.pts;

            int pos = packet.size - left;
            int read = codec_write(&codecContext, packet.data + pos, left);
            if (read < 0) {
               FILE_LOG(logWARNING) << "hw codec write err=" << err << " "
                  "err=" << errno << ", EAGAIN=" << EAGAIN;
               codec_reset(&codecContext);
               break;
            }

            left -= read;
         }
      }
      av_packet_unref(&packet);
   }


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

Re: Command line video player

Post by crashoverride » Wed Sep 27, 2017 6:44 am

extphy wrote:do we have to limit speed of feeding data into codec_write(), assuming we have codec_para_t.noblock==0?
"noblock" is used for asynchronous codec operation. if "noblock" is set to zero, writes to the codec will block code execution until data can be accepted or an error occurs. If "noblock" is non-zero, writes will return immediately whether successful or not. The return code indicates whether an error occured in both circumstances. "noblock" mode is intended to be used with "poll"[1] to asynchronously signal when the codec is ready for data. c2play currently uses "blocking" mode.[2]

[1] http://man7.org/linux/man-pages/man2/poll.2.html
[2] https://github.com/OtherCrashOverride/c ... #L428-L472

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Thu Sep 28, 2017 5:14 pm

crashoverride wrote:
extphy wrote:do we have to limit speed of feeding data into codec_write(), assuming we have codec_para_t.noblock==0?
"noblock" is used for asynchronous codec operation. if "noblock" is set to zero, writes to the codec will block code execution until data can be accepted or an error occurs. If "noblock" is non-zero, writes will return immediately whether successful or not. The return code indicates whether an error occured in both circumstances. "noblock" mode is intended to be used with "poll"[1] to asynchronously signal when the codec is ready for data. c2play currently uses "blocking" mode.[2]

[1] http://man7.org/linux/man-pages/man2/poll.2.html
[2] https://github.com/OtherCrashOverride/c ... #L428-L472
Thanks a lot! It appears to be that I just didn't wait enough after codec feeding end, codec continues to decode video even after last successful write operation.

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Fri Sep 29, 2017 5:47 pm

crashoverride wrote:
extphy wrote:do we have to limit speed of feeding data into codec_write(), assuming we have codec_para_t.noblock==0?
"noblock" is used for asynchronous codec operation. if "noblock" is set to zero, writes to the codec will block code execution until data can be accepted or an error occurs. If "noblock" is non-zero, writes will return immediately whether successful or not. The return code indicates whether an error occured in both circumstances. "noblock" mode is intended to be used with "poll"[1] to asynchronously signal when the codec is ready for data. c2play currently uses "blocking" mode.[2]

[1] http://man7.org/linux/man-pages/man2/poll.2.html
[2] https://github.com/OtherCrashOverride/c ... #L428-L472
Could you please clarify, what is the common way to feed decoder using noblock=0 mode? It seems that decoder can control decoding speed itself, but it would process tail data even after last successful write from client side, moreover, decoder can decode with invalid speed in such a case, probably we have to control speed of feeding data into decoder in any case?

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

Re: Command line video player

Post by crashoverride » Sat Sep 30, 2017 9:40 pm

extphy wrote:what is the common way to feed decoder using noblock=0 mode?
The link posted earlier illustrates how its done in c2play:
https://github.com/OtherCrashOverride/c ... #L428-L472
Data is thrown at the codec and it takes what it can, when it can. Note that the amount of data accepted may be lower than the amount provided. You need to ensure you take this into consideration as c2play does.
extphy wrote:It seems that decoder can control decoding speed itself, but it would process tail data even after last successful write from client side
The codec has internal buffers that it fills from the data provided to it. This is why after data is no longer sent, playback continues.
extphy wrote: decoder can decode with invalid speed in such a case
The codec can either maintain its own presentation rate, or run as-fast-as-possible (freerun mode).
extphy wrote:we have to control speed of feeding data into decoder in any case?
In noblobk=0 mode, the codec will block code execution when its buffers are full. Execution is resumed when free buffers are available again or an error/timeout occurs. Its important to check the return result from the write operation:
https://github.com/OtherCrashOverride/c ... #L428-L472

C2play reads the presentation time stamps from the codec to determine when playback has finished. When the codec PTS no longer advances, all the codec buffers are empty (if the codec is not paused):
https://github.com/OtherCrashOverride/c ... pp#L38-L43

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Tue Oct 03, 2017 6:34 pm

Thank's a lot! Seems that it's enough to track pts change to detect end of stream. Also I've noticed that pts checkin without audio stream decoding leads to fast tail playback, do you happen to know does it make sense to do pts checkin without audio stream at all? Is it a feature to av sync?

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

Re: Command line video player

Post by crashoverride » Wed Oct 04, 2017 5:26 am

The only reason to do a PTS check-in is to maintain sync with something external. Audio is usually the "master clock" and informs the video of the current PTS. If there is no audio, it only makes sense to check-in a PTS if the source is live.

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Thu Oct 12, 2017 6:11 pm

crashoverride wrote:The only reason to do a PTS check-in is to maintain sync with something external. Audio is usually the "master clock" and informs the video of the current PTS. If there is no audio, it only makes sense to check-in a PTS if the source is live.
Thank you! BTW, do you happen to know, do C1 HW decoder play everything from its internal buffer after data feed stopped? I noticed that it stop slightly before last frames but play the rest in case we start to feed it e.g. with the same stream from beginning.

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

Re: Command line video player

Post by crashoverride » Fri Oct 13, 2017 10:20 am

I have not observed any codec behavior differences between C1 and C2. c2play is usable on both. There is an API difference as illustrated here:
https://github.com/OtherCrashOverride/c ... #L437-L467

csucsu
Posts: 26
Joined: Tue Jul 12, 2016 12:14 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by csucsu » Sun Dec 17, 2017 7:50 pm

Hi,

is it possible to play more streams on the same screen without x11 somehow? For example 4 low-bitrate stream in a 2x2 matrix. Is there any hardware limitation about it?

best regards, csucsu

User avatar
mad_ady
Posts: 7900
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 499 times
Been thanked: 348 times
Contact:

Re: Command line video player

Post by mad_ady » Sun Dec 17, 2017 9:46 pm

If it's low bitrate, you don't need hardware decoding.
Alternatively you could multiplex the 4 streams with ffmpeg and generate a single video stream that you could play back with the current player.

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

Re: Command line video player

Post by crashoverride » Mon Dec 18, 2017 11:04 am

csucsu wrote:Is there any hardware limitation about it?
I am not aware of any hardware limitations preventing it. However, there are numerous software limitations.

A unique codec state (context) will be required for each stream. I do not know if this is currently supported or not. When the V4L2 codec interface is available in Kernel 4.x, this should provide the requirement.

Unique decode buffers are required for each codec context. This is theoretically possible in kernel 3.x (I have never tried it). The kernel 4.x should also provide this ability.

Finally, the GE2D hardware blitter can be used to composite each video stream to a common framebuffer. This is currently possible today.

The caveat is that the codecs and GE2D require CMA memory. This make dynamic allocation difficult and will require a memory pool to be reserved.

This type of use case (2x2 video display) is more suited to the XU4 hardware. V4L2 codec interfaces are currently available in its kernel 4.x to maintain unique contexts. It also has a G2D hardware blitter. Most importantly, it has IOMMU interfaces for all its hardware blocks removing memory restrictions (virtual memory support).

extphy
Posts: 80
Joined: Mon Aug 17, 2015 4:20 pm
languages_spoken: english, russian
ODROIDs: Cx, XU4, U3
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by extphy » Tue Dec 19, 2017 4:43 pm

csucsu wrote:Hi,

is it possible to play more streams on the same screen without x11 somehow? For example 4 low-bitrate stream in a 2x2 matrix. Is there any hardware limitation about it?

best regards, csucsu
I actually do that with x2 h264 streams (1080 half screen for each), one HW + one SW decoded, the fps for SW decoded stream is very depends on bitrate of course, rich dynamic video decoding will be a bottleneck, but smth simple as an object moving through scene can be decoded / displayed with good fps on non-X11 setup (assuming the frame isn't full size)

jdforce
Posts: 12
Joined: Mon Mar 12, 2018 12:58 am
languages_spoken: english
ODROIDs: Odroid c2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by jdforce » Mon Mar 12, 2018 4:23 am

Hi,
I just got a C2 and need a OMXplayer replacement.
Installed ubuntu mate and upgraded it. Version after the upgrade is Linux odroid64 3.14.79-117 (obtained with uname -a)
Then installed the dependencies you indicate on git (sudo apt install libasound2-dev libavformat-dev libass-dev). Well, had to install git first because it was not installed.
When tried to compile it failed. Digging into the forum I found that also needed to install mali-x11 package.

Now it compiled but when run from a terminal (am using the desktop), using a mp4 video that plays fine with ffplay:

c2play ~/media/myvideo.mp4
It displays fine, full screen, with a lot of overlay text messages. When it exits, the desktop is black, like it lost the background. the terminal is usable but basically is black, so the desktop has lost some graphic properties.

if I run c2play-x11, then it is worst, because all becomes black, except the terminal area, which is black but with a lot of messages, from which the notorious error messages are
EVIOCGBIT failed
eglGetDisplay failed

Then I have to log off to recover the desktop graphics.
I tried to run the cube example with sudo /usr/share/arm_mali_examples/opengles_20/cube/cube on a terminal emulator and it fails with "Failed to create EGL surface at src/EGLRuntime.cpp:297.
When run it cd on a framebuffer (ctrl-alt-F2) it does show the rainbow cube rotating.

Perhaps is there some dependencies not met? I understand that at this time the c2player is able to work in terminal or in a graphic environment.
Please advise, thanks.

JD

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

Re: Command line video player

Post by crashoverride » Mon Mar 12, 2018 4:57 am

c2play and c2play-x11 are mutually exclusive. You will use one or the other but not both. The one used depends on whether you have the mali-fbdev or mali-x11 package installed.

c2play-x11 is tested with the official Ubuntu 16.04 Mate image (not minimal). The mali-x11 package is already installed in this image.

Neither c2play nor c2play-x11 supports VT switching (CTRL+ALT+Fn).

To troubleshoot, flash the official Ubuntu Mate image to a spare, unused SD card. Do not update the image. Follow the instructions for building c2play-x11. If any errors are encountered, post the output in this forum tread.

Perhaps in the future @mdrjr can package c2play/c2play-x11 to make installation possible with a simple 'apt install'.

jdforce
Posts: 12
Joined: Mon Mar 12, 2018 12:58 am
languages_spoken: english
ODROIDs: Odroid c2
Has thanked: 0
Been thanked: 0
Contact:

Re: Command line video player

Post by jdforce » Mon Mar 12, 2018 7:37 am

Yes, I understand that they are mutual. For the tests I ran both, one after the other, first inside the desktop environment and then on a frame buffer terminal. What am interested more is in the desktop version.

Am having trouble to determine which version of Ubuntu you mention as official. because when going here https://odroid.in/ubuntu_16.04lts/ there are a number of versions. Initially I picked the newer one (2017-09-27) but it didn't boot. So I installed the one from 2016-02-26 from http://east.us.odroid.in/ubuntu_16.04lts/ which I found to be the one that boots, and ran the upgrade procedure described in the download pages.
Kindly ask to point me to the right files to use.

JD

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

Re: Command line video player

Post by crashoverride » Mon Mar 12, 2018 8:03 am

jdforce wrote:Kindly ask to point me to the right files to use.
https://odroid.in/ubuntu_16.04lts/ubunt ... 927.img.xz

For flash instructions, see here:
https://wiki.odroid.com/troubleshooting ... hing_tools

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 3 guests