Owersun / mymfc

mymfc
8 stars 2 forks source link

CDVDVideoCodecC1: Failed to open C1 Amlogic Codec #1

Open SamuelBrucksch opened 8 years ago

SamuelBrucksch commented 8 years ago

I always get the error that it failed to open the codec. I use an odroid c1+ and i tried the aml-libs that are delivered from odroid as debian package and i compiled it myself from here: https://github.com/mdrjr/c1_aml_libs

Tried running as root as well but didnt make a difference. Can you help me setting up the codec correctly so that this works?

Thanks!!

Owersun commented 8 years ago

Hello, do you use the c1_aml branch? The master branch is for Samsung Exynos chips, it uses different process.

SamuelBrucksch commented 8 years ago

Yes i use the c1 aml branch... What i do is i either use the deb or the driver from github and compile it. No error occur. Then i adjust rights in /usr/include/am* and /usr/lib/aml_libs so it is readable and then i compile your mymfc in c1_aml branch. But it keeps saying that it cannot load the codec.

How did you install the codec? Did you do any additional steps? And are you using the c1 as well? I use the default ubuntu image from hardkernel.

Owersun commented 8 years ago

Yes, that's mostly everything you need to do. I did test it on C1 as well. Can you paste couple of lines that are printed before the final message, as well as 10 last lines from dmesg after you try to run the program.

SamuelBrucksch commented 8 years ago

I use this video: http://download.openbricks.org/sample/H264/big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4

./mymfc big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4 Main::main - Video stream in the file is stream number 0 Main::main - AVCodec: h264, id 28 Main::main - Header of size 138848 CBitstreamConverter::Open avcC data too small or missing CLinuxC1Codec::OpenDecoder CDVDVideoCodecC1: Failed to open C1 Amlogic Codec CLinuxC1Codec::CloseDecoder CLinuxC1Codec::SetViewport Setting viewport to 0 0 0 0

dmesg does not seem to change when running your program: [ 41.072115@3] ----aml_hw_iec958_init,runtime->rate=44100-- [ 41.072123@3] ----aml_hw_iec958_init,runtime->rate=44100,sample_rate=5-- [ 41.072130@3] iec958 mode PCM16 [ 41.072138@3] IEC958 16bit [ 41.072145@3] hdmitx: audio: aout notify rate 44100 [ 41.072150@3] hdmitx: audio: aout notify size 16 [ 41.072156@3] hdmitx: audio: audio channel num is 1 [ 41.072164@3] hdmitx: audio: SPDIF [ 41.072176@3] hdmitx: audio: current VIC: 16 [ 41.072180@3] hdmitx: audio: audio sample rate: 2 [ 41.072185@3] hdmitx: audio: reset audio N para [ 41.072196@3] hdmitx: audio: PCM out to HDMI [ 41.083951@3] hdmitx: audio: Time out: AIU_HDMI_CLK_DATA_CTRL [ 41.083967@3] hdmitx: audio: i2s_to_spdif_flag:1 [ 41.083988@3] hdmitx: audio: Enable audio spdif to HDMI [ 41.083998@3] hdmitx: audio: Audio Type: PCM [ 41.084041@3] hdmitx: audio: set audio param [ 41.135944@3] runtime dma_bytes 65536,stream type 1 [ 42.220061@2] alsa capture long time no data, quit xrun! [ 43.240051@2] alsa capture long time no data, quit xrun! [ 44.260069@2] alsa capture long time no data, quit xrun! [ 45.280047@2] alsa capture long time no data, quit xrun! [ 54.843808@3] usb 1-1.1: USB disconnect, device number 3 [ 138.807880@2] init: failsafe main process (615) killed by TERM signal [ 138.924745@2] config uart_b_ttyS2:: Character length 8bits/char [ 138.927796@2] config uart_b_ttyS2:: Character length 8bits/char [ 149.066395@0] init: plymouth-stop pre-start process (2062) terminated with status 1

BTW that CBitstreamConverter::Open avcC data too small or missing does not come with a mpeg1 or 2 testfile, but the result is the same. It says cannot find codec...

Owersun commented 8 years ago

I'll give it a look this evening, but right now it looks like there is no codec initialized in the kernel for you, since dmesg doesn't change. There should be at least some messages about something happening to the codec. Can you install a Kodi for C1 and try to play any video, look at what logs would say, are they player using the codec or ffmpeg?

SamuelBrucksch commented 8 years ago

Feb 17 10:05:58 odroid kernel: [ 416.776476@3] amvdec_h264 mem-addr=9a00000,buff_offset=8a00000,buf_start=9b3e000 Feb 17 10:05:58 odroid kernel: [ 416.776500@3] H264 sysinfo: 1920x1080 duration=3840, pts_outside=1, sync_outside=0, use_idr_framerate=0 Feb 17 10:05:58 odroid kernel: [ 416.779763@3] 264 ucode swap area: physical address 0x3ec18000, cpu virtual addr f288b000 Feb 17 10:05:58 odroid kernel: [ 416.779779@3] start load original firmware ... Feb 17 10:05:58 odroid kernel: [ 416.780132@3] vout [tv_set_vframe_rate_hint] duration = 3840, policy = 1! Feb 17 10:05:58 odroid kernel: [ 416.780143@3] vout [framerate_automation_process] duration = 3840 Feb 17 10:05:58 odroid kernel: [ 416.780150@3] vout [get_target_vmode] frame_rate_target = 2500 Feb 17 10:05:58 odroid kernel: [ 416.780167@3] vout [framerate_automation_set_mode] mode_target = 25 Feb 17 10:05:58 odroid kernel: [ 416.780172@3] +++++++++++++++++framerate_automation_set_mode[1036]auto_mode=0++++++++++++++++ Feb 17 10:05:58 odroid kernel: [ 416.780780@3] video first pts = 0 Feb 17 10:05:58 odroid kernel: [ 416.782320@0] frame_mbs_only_flag 1, crop_bottom 4, frame_height 1080, mb_height 68,crop_right 0, frame_width 1920, mb_width 68 Feb 17 10:05:58 odroid kernel: [ 416.820060@0] video first pts = 1

And in KODI see attached screenshot. img_20160217_100850

Owersun commented 8 years ago

Yeah, this one is right, meaning the codec is present in the system. I'll take a look into what could be wrong with the console program this evening, in 8-9 hours.

SamuelBrucksch commented 8 years ago

Cool. Thanks for your help.

SamuelBrucksch commented 8 years ago

BTW i just found out, that false is returned at this point: https://github.com/Owersun/mymfc/blob/c1_aml/LinuxC1Codec.cpp#L534

width or height is zero... Maybe that helps identifying the issue.

I just added additional output in main.c: Main::main - Header of size 138848, width: 0, height: 1920

Even when i use different video sizes width is always zero but height works...

Owersun commented 8 years ago

Yeah, this is the issue, for some reason the size of the video is reported to have 0 as one dimensions. It will not work to just comment out the check, since the screen size is set base on that after as well. Can you maybe update your ffmpeg libraries? Becuase to parse the video the ffmpeg is used and the program totally relays on what the ffmpeg gives as video properties to it.

SamuelBrucksch commented 8 years ago

ffmpeg -version ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers built on Nov 7 2014 10:36:29 with gcc 4.8 (Ubuntu/Linaro 4.8.2-19ubuntu1) configuration: --enable-gpl libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100

This is what i get. Its the systems default ffmpeg. Which version do you use?

Owersun commented 8 years ago

I compile my own from their git master branch most of the time, since I deal with that features a lot. Can you do ffprobe on the file you are trying to play and see what is going to be the output?

SamuelBrucksch commented 8 years ago

ffprobe big_buck_bunny_480p_H264_AAC_25fps_1800K.MP4 ffprobe version 2.4.3 Copyright (c) 2007-2014 the FFmpeg developers built on Nov 7 2014 10:36:29 with gcc 4.8 (Ubuntu/Linaro 4.8.2-19ubuntu1) configuration: --enable-gpl WARNING: library configuration mismatch postproc configuration: --enable-thumb --enable-neon --enable-postproc libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_480p_H264_AAC_25fps_1800K.MP4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: isommp423gp5 creation_time : 2011-08-04 02:50:53 title : big_buck_bunny_480p_surround-fix.avi_002.AVI.MP4 artist : created with SUPER(C).v2011.bld.49 encoder : eRightSoft comment : 10:51:04 Duration: 00:01:15.00, start: 0.000000, bitrate: 1915 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 1814 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default) Metadata: creation_time : 2011-08-05 02:50:25 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default) Metadata: creation_time : 2011-08-04 02:50:53 handler_name : GPAC ISO Audio Handler Stream #0:2(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2011-08-04 02:50:57 handler_name : GPAC MPEG-4 OD Handler Stream #0:3(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2011-08-04 02:50:57 handler_name : GPAC MPEG-4 BIFS Handler Unsupported codec with id 0 for input stream 2 Unsupported codec with id 0 for input stream 3

And on the 1080p ffprobe big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4 ffprobe version 2.4.3 Copyright (c) 2007-2014 the FFmpeg developers built on Nov 7 2014 10:36:29 with gcc 4.8 (Ubuntu/Linaro 4.8.2-19ubuntu1) configuration: --enable-gpl WARNING: library configuration mismatch postproc configuration: --enable-thumb --enable-neon --enable-postproc libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: isommp423gp5 creation_time : 2011-08-04 01:51:12 title : big_buck_bunny_1080p_surround.avi_006.AVI.MP4 artist : created with SUPER(C).v2011.bld.49 encoder : eRightSoft comment : 09:51:32 Duration: 00:00:45.00, start: 0.000000, bitrate: 7356 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 7254 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default) Metadata: creation_time : 2011-08-05 01:50:11 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default) Metadata: creation_time : 2011-08-04 01:51:16 handler_name : GPAC ISO Audio Handler Stream #0:2(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2011-08-04 01:51:21 handler_name : GPAC MPEG-4 OD Handler Stream #0:3(und): Data: none (mp4s / 0x7334706D), 0 kb/s (default) Metadata: creation_time : 2011-08-04 01:51:21 handler_name : GPAC MPEG-4 BIFS Handler Unsupported codec with id 0 for input stream 2 Unsupported codec with id 0 for input stream 3

Owersun commented 8 years ago

Well this looks fine, still hints are coming from here: https://github.com/Owersun/mymfc/blob/c1_aml/main.cpp#L90 and codecCtx is AVCodecContext type, which is purely ffmpeg internal stuff... So I cannot tell much where width and height becoming 0 and why. Maybe you can add a debug right after these assignment too see what you are getting from ffmpeg?

SamuelBrucksch commented 8 years ago

Will update ffmpeg first and see what happens then.

SamuelBrucksch commented 8 years ago

Ok new FFMPEG version detects width & height correctly: CDVDVideoCodecC1::Open Opened C1 Amlogic Codec. DisplayWidth: 1920, DisplayHeight: 1080

But now i get errors like this: CLinuxC1Codec::Decode CLinuxC1Codec::get_pts_video get_pts_video: 0 CLinuxC1Codec::Decode rtn(2), m_cur_pictcnt(0), m_cur_pts(0.000000), lastpts(0.000000) Main::main - Extracted frame number 285 of size 1 CBitstreamConverter::Convert: error converting.

dmesg now looks like this: Feb 17 13:23:25 odroid kernel: [ 8352.867507@1] amvdec_h264 mem-addr=9a00000,buff_offset=8a00000,buf_start=9b3e000 Feb 17 13:23:25 odroid kernel: [ 8352.867522@1] H264 sysinfo: 1920x1080 duration=0, pts_outside=1, sync_outside=0, use_idr_framerate=0 Feb 17 13:23:25 odroid kernel: [ 8352.869823@1] 264 ucode swap area: physical address 0x3ec10000, cpu virtual addr f3c11000 Feb 17 13:23:25 odroid kernel: [ 8352.869834@1] start load original firmware ... Feb 17 13:23:25 odroid kernel: [ 8352.870105@1] vout [tv_set_vframe_rate_hint] duration = 0, policy = 1! Feb 17 13:23:25 odroid kernel: [ 8352.870119@1] vout [framerate_automation_process] duration = 0 Feb 17 13:23:25 odroid kernel: [ 8352.870131@1] vout [get_target_vmode] frame_rate_target = 0 Feb 17 13:23:25 odroid kernel: [ 8352.870149@1] vout [framerate_automation_set_mode] mode_target = 25 Feb 17 13:23:25 odroid kernel: [ 8352.870155@1] +++++++++++++++++framerate_automation_set_mode[1036]auto_mode=0++++++++++++++++ Feb 17 13:23:25 odroid kernel: [ 8352.870632@1] video first pts = 0 Feb 17 13:23:30 odroid kernel: [ 8358.085407@0] vout [tv_set_vframe_rate_end_hint] return mode = 25, policy = 1! Feb 17 13:23:30 odroid kernel: [ 8358.085419@0] vout [framerate_automation_set_mode] mode_target = 25 Feb 17 13:23:30 odroid kernel: [ 8358.085425@0] +++++++++++++++++framerate_automation_set_mode[1036]auto_mode=0++++++++++++++++ Feb 17 13:23:30 odroid kernel: [ 8358.085562@3] video first pts = 0

Video is not displayed at all...

Owersun commented 8 years ago

Bitstream converter is something mapping the data in each frame h264 bitstream to annexb bitstream. The frame size of 1 byte look very suspicious, and very probably error on conversion could happen. And again, the CBitstreamConverter that does that I took as the whole block from Kodi codebase, didn't modify a bit in it. So it's even the ffmpeg is again preparing corrupt data for the input, or bitstream converter from Kodi cannot deal with the data coming from ffmpeg... Did you prepare in any way the video you are trying to play, or is it the normal .avi/.mkv file?

SamuelBrucksch commented 8 years ago

It is a normal mp4 h264 test video. Worked on all other systems where i tested with hardware acceleration and in kodi it worked as well... guess i have to look for changes in kodi and update your classes... Will report back if i get it to work.