peterderivaz / pyopenmax

Raspberry Pi Python wrappers for OpenMAX multimedia library
23 stars 4 forks source link

State not reached. #1

Open dapa79 opened 12 years ago

dapa79 commented 12 years ago

I can't play the test.mp4 file inlcuded in raspberry pi hello_video example:

pyopenmax.play('/home/pi/test.mp4') Traceback (most recent call last): File "", line 1, in File "pyopenmax.py", line 982, in play vp = VideoPlayer(videofile) File "pyopenmax.py", line 862, in init read_media.change_state(OMX_StateIdle) File "pyopenmax.py", line 591, in change_state raise ValueError("State not reached") ValueError: State not reached

I get the same error when trying other movie clips. I've tried running both the example and the vcfiled executable as root. On the raspberry pi forum there seems to be others having the same issue. The same error occurs on the official raspberry pi image as well as a recent raspbian build with the latest binary firmware.

peterderivaz commented 12 years ago

1) On my image (which is fairly old) I don't need to run as root (although it should not matter either way)

2) I get the error above if I type the wrong filename.

3) In my image I need to do pyopenmax.play("/opt/vc/src/hello_pi/hello_video/test.h264") I wonder if they have changed the hello_video to use a different file now? (your file has the extension mp4 and is in a different directory) Perhaps the new file doesn't work for some reason? (Do you have a link to it?)

4) I would begin debugging by using: cd /home/pi ls -al to check that the file is really there and that it has the correct permissions to be readable.

5) Next I would run /opt/vc/bin/vcgencmd set_logging level=-1 python import pyopenmax pyopenmax.play('/home/pi/test.mp4') exit() sudo /opt/vc/bin/vcdbg -m128 log msg

This should print out a whole lot of debug information that might contain something instructive. (I think the -m128 corresponds to which memory split you are using. You may need -m64 or -m192 if you are using a different split)

6) I'll try to get a more up to date image on an sdcard and figure out what has happened. (Unfortunately this might take a while as my sdcard has developed a fault and won't even mount the filesystem at the moment...)

7) One thing I had to type at some stage (but I didn't think it was needed on more recent builds) was sudo sh /opt/vc/sbin/install_vmcs --force

8) It also relies on there being the right vlls in /boot/vlls - but with the latest image I would have thought this would be okay.

dapa79 commented 12 years ago

Thanks for the rapid response!

I've been using "/opt/vc/src/hello_pi/hello_video/test.h264" in my tests. I was just lazy and copy-pasted another users error description from the raspberry pi forum. We both got the same error.

Using the "offical" debian image i get, running the commands in 5)

4206468599: debug_sym: OpenVideoCoreMemoryFile: newHandle->vcSymbolTableOffset (1936287828) > 4Mb 4206469294: Unable to open videocore memory access: -5

Have verified the file location, chmoded it 777 and also with a copy in /home/pi/. The file works as it should with hello_video so it is not corrupt.

Running 7) I get: (I ran it once before. That time I forgot to pipe stderr to a file but as far as I can remember the errors were the same)

install_vmcs: previous installation's uninstallation script saved in install_vmcs: /opt/vc/sbin/uninstall_last_vmcs install_vmcs: expected file missing in /opt/vc/share/install/vmcs.conf install_vmcs: expected file missing in /opt/vc/share/install/vcfiled install_vmcs: expected file missing in /opt/vc/share/install/vchiq install_vmcs: no vchiq module found for this kernel (3.1.9+) install_vmcs: Warning - no VLLs in /sd/vlls install_vmcs: installation would normally link this location to /boot/vlls install_vmcs: ensure VLLs are present in /boot/vlls (probably the install_vmcs: DOS partition of your SD card), and rerun this install_vmcs: installation install_vmcs: warning - /sd/mediafiles does not exist, some applications require this Creating vchiq device node

Perhaps something is missing.

dapa79 commented 12 years ago

I've tried to google the error messages but found nothing. I guess they are broadcom/chip specific and that only a few people have access to documentation. Are you in a position to get further information on this error?

Is there anything else I can try?

Thanks!

peterderivaz commented 12 years ago

I've been talking to Dom about this and he is investigating at the moment.

I think the OpenVideoCoreMemoryFile error is because you were using a different memory split to me so you might need to use "sudo /opt/vc/bin/vcdbg -m64 log msg" instead.

The most likely reason for the file not playing is that the current shipping VLLs do not include the raw h264 container parser. If this is true then there are 3 possibilities to try: 1) Try an mp4 container instead of a raw h264 container. (mp4 files can still contain h264 visual bitstreams) e.g. try a different file 2) See if we can get updated VLLs with raw h264 container support 3) Use the ffmpeg/avcodec libraries to parse the container format on the ARM and then just pass the extracted NAL units to OpenMAX

I will post agan when I get some more concrete information (probably Thursday 28 June).

dapa79 commented 12 years ago

Using -m192 I get more debug output that might help in the diagnostics:

611109762: 248832.184: dmalloc: size 21176 pool 0x8c5bcd98 ptr 0x8c63d0f0 611111413: 248832.356: dmalloc: size 280 pool 0x8c5bcd98 ptr 0x8c6b4430 611112301: 248832.399: dmalloc: size 472 pool 0x8c5bcd98 ptr 0x8c6423b0 611113112: 248832.434: dmalloc: size 88 pool 0x8c5bcd98 ptr 0x8c642590 611114123: 248832.480: dmalloc: size 4120 pool 0x8c5bcd98 ptr 0x8c6425f0 611115085: 248832.572: dmalloc: size 312 pool 0x8c5bcd98 ptr 0x8c6bae30 611115929: 248832.603: TV Service: received command 0x0 (get_state) 611116947: 295737.025: OMX.broadcom.read_media:init 611117838: 295737.184: top:create_component read_media 611118833: 295737.216: dmalloc: size 7192 pool 0x8c5bcd98 ptr 0x8c6baf70 611119673: 295737.313: dmalloc: size 312 pool 0x8c5bcd98 ptr 0x8c6bcb90 611120457: 295737.336: read_media:RIL:GetParameter(1000002) 611121476: 295737.352: read_media:RIL:GetParameter(1000004) 611122253: 295737.367: read_media:RIL:GetParameter(1000003) 611123174: 295737.383: read_media:RIL:GetParameter(1000005) 611123960: 295737.410: dmalloc: size 1112 pool 0x8c5bcd98 ptr 0x8c6bccd0 611124971: 295737.434: read_media:RIL:GetParameter(7f000008) 611125985: 295737.451: read_media:RIL:GetParameter(2000001) 611126860: 295737.467: read_media:RIL:GetParameter(7f000007) 611127807: 295737.481: read_media:RIL:GetParameter(7f000006) 611128628: 295737.498: read_media:RIL:GetParameter(2000001) 611129572: 295737.514: read_media:RIL:GetParameter(7f000007) 611130396: 295737.530: read_media:RIL:GetParameter(7f000006) 611131600: 295737.547: read_media:RIL:GetParameter(2000001) 611132481: 295737.562: read_media:RIL:GetParameter(7f000007) 611133484: 295737.576: read_media:RIL:GetParameter(7f000006) 611134345: 295737.592: read_media:RIL:GetParameter(2000001) 611135313: 295737.608: read_media:RIL:GetParameter(7f000007) 611136139: 295737.624: read_media:RIL:GetParameter(7f000006) 611137084: 295737.650: read_media:RIL:SetParameter(7f0000a9) 611137850: 295737.664: read_media:4:SetCallbacks 611138611: 295737.683: read_media:4:SetParameter(7f000001) 611139547: 295737.700: read_media:4:GetParameter(7f000002) 611139794: 295737.720: read_media:4:SetParameter(7f000004) 611140598: 295737.746: dmalloc: size 216 pool 0x8c5bcd98 ptr 0x8c643610 611141704: 295738.218: read_media:4:SetCallbacks 611141968: 295739.907: read_media:4:GetParameter(1000002) 611142204: 295739.924: read_media:4:RIL:GetParameter(1000002) 611143044: 295740.641: read_media:4:SendCommand(2,110,c6b4954) Disable 110 611144046: 295740.659: read_media:4:sending cmd 2 to 110 611144303: 295740.687: read_media:4:starting command 2 611145085: 295740.703: read_media:4:RIL:GetParameter(2000001) 611145536: 295740.731: read_media:4:processingCommand=0 611146350: 295741.777: read_media:4:GetParameter(1000004) 611147163: 295741.795: read_media:4:RIL:GetParameter(1000004) 611147599: 295742.474: read_media:4:SendCommand(2,111,c6b4954) Disable 111 611148443: 295742.493: read_media:4:sending cmd 2 to 111 611148709: 295742.518: read_media:4:starting command 2 611149684: 295742.536: read_media:4:RIL:GetParameter(2000001) 611150561: 295742.559: read_media:4:processingCommand=0 611150825: 295745.952: read_media:4:GetParameter(1000003) 611151052: 295745.970: read_media:4:RIL:GetParameter(1000003) 611152105: 295746.964: read_media:4:GetParameter(1000005) 611152397: 295746.981: read_media:4:RIL:GetParameter(1000005) 611153208: 295747.717: read_media:4:SendCommand(2,112,c6b4954) Disable 112 611153468: 295747.735: read_media:4:sending cmd 2 to 112 611154220: 295747.764: read_media:4:starting command 2 611154642: 295747.781: read_media:4:RIL:GetParameter(2000001) 611155417: 295747.807: read_media:4:processingCommand=0 611155666: 295748.680: read_media:4:SendCommand(2,113,c6b4954) Disable 113 611156581: 295748.698: read_media:4:sending cmd 2 to 113 611157453: 295748.725: read_media:4:starting command 2 611157709: 295748.742: read_media:4:RIL:GetParameter(2000001) 611158532: 295748.767: read_media:4:processingCommand=0 611159525: 295750.565: read_media:4:GetParameter(2000001) 611159784: 295750.580: read_media:4:RIL:GetParameter(2000001) 611160725: 295751.416: read_media:4:SetParameter(2000001) 611161626: 295751.432: read_media:4:RIL:SetParameter(2000001) 611161885: 295752.054: read_media:4:SendCommand(3,111,c6b4954) Enable 111 611162102: 295752.071: read_media:4:sending cmd 3 to 111 611162930: 295752.098: read_media:4:starting command 3 611163930: 295752.124: read_media:4:processingCommand=0 611164202: 295752.892: read_media:4:SendCommand(2,113,c6b4954) Disable 113 611165026: 295752.910: read_media:4:sending cmd 2 to 113 611166044: 295752.943: read_media:4:starting command 2 611166324: 295752.959: read_media:4:processingCommand=0 611167135: 295754.653: read_media:4:SetParameter(100000d) 611168107: 295754.671: read_media:4:RIL:SetParameter(100000d) 611168374: 295755.330: read_media:4:GetState(1) 611169325: 295755.942: read_media:4:SendCommand(0,2,c6b4954) State to idle 611170162: 295755.971: read_media:4:starting command 0 611170411: 295755.989: read_media:4:RIL:GetParameter(2000001) 611170624: 295756.010: read_media:4:RIL:GetParameter(2000001) 611171593: 295756.029: read_media:4:RIL:GetParameter(2000001) 611172426: 295756.065: dmalloc: size 1176 pool 0x8c5bcd98 ptr 0x8c6bd130 611172672: 295756.108: dmalloc: size 56 pool 0x8c5bcd98 ptr 0x8c6436f0 611173477: 295756.155: dmalloc: size 88 pool 0x8c5bcd98 ptr 0x8c6bd5d0 611174513: 295756.176: dfree: pool 0x8c5bcd98, ptr 0x8c6bd5d0 611175472: 295756.195: dfree: pool 0x8c5bcd98, ptr 0x8c6436f0 611176315: 295756.212: open ( /opt/vc/src/hello_pi/hello_video/test.h264 ) 611176581: 295756.250: convert_pathname( /opt/vc/src/hello_pi/hello_video/test.h264, /opt/vc/src/hello_pi/hello_video/test.h264 ) returned 1 611177399: 295756.280: dfree: pool 0x8c5bcd98, ptr 0x8c6bd130 611177841: 295756.307: read_media:4:RIL:container_open error 6, (/opt/vc/src/hello_pi/hello_video/test.h264, error opening file) 611178694: 295756.326: read_media:4: reverting transition, going to Loaded 611178953: 295756.345: read_media:4:RIL:GetParameter(2000001) 611179731: 295756.362: read_media:4:RIL:GetParameter(2000001) 611180191: 295756.378: read_media:4:RIL:GetParameter(2000001) 611181032: 295756.395: read_media:4:RIL:GetParameter(2000001) 611182849: 295756.412: read_media:4:completed state transition to OMX_StateLoaded 611183308: 295756.433: read_media:4:processingCommand=0 611183534: 295757.222: read_media:4:GetState(1) 611183751: 295977.772: read_media:4:GetState(1) 611183957: 296178.905: read_media:4:GetState(1) 611184175: 296379.923: read_media:4:GetState(1) 611185063: 296580.911: read_media:4:GetState(1) 611185326: 296781.886: read_media:4:GetState(1) 611185548: 296982.888: read_media:4:GetState(1) 611186330: 297183.864: read_media:4:GetState(1) 611186786: 297384.858: read_media:4:GetState(1) 611187565: 297585.837: read_media:4:GetState(1) 611187810: 302991.945: read_media:4:SendCommand(2,-1,0) Disable -1 611188575: 302991.976: read_media:4:starting command 2 611189015: 302991.995: read_media:4:RIL:GetParameter(2000001) 611189821: 302992.016: read_media:4:processingCommand=0 611190805: 302992.041: read_media:4:GetState(1) 611191080: 302992.057: read_media:4:GetState(1) 611191971: 302992.073: read_media:4:GetParameter(7f000003) 611192232: 302992.095: read_media:4:ComponentTunnelRequest(110,clear) 611193034: 302992.113: read_media:4:RIL:GetParameter(7f000006) 611194015: 302992.134: read_media:4:GetParameter(7f000003) 611194273: 302992.155: read_media:4:ComponentTunnelRequest(111,clear) 611195227: 302992.173: read_media:4:RIL:GetParameter(7f000006) 611196061: 302992.193: read_media:4:GetParameter(7f000003) 611196352: 302992.213: read_media:4:ComponentTunnelRequest(112,clear) 611197167: 302992.229: read_media:4:RIL:GetParameter(7f000006) 611197636: 302992.248: read_media:4:GetParameter(7f000003) 611198481: 302992.269: read_media:4:ComponentTunnelRequest(113,clear) 611199455: 302992.284: read_media:4:RIL:GetParameter(7f000006) 611199733: 302992.305: read_media:4:GetParameter(7f000003) 611200554: 302992.321: read_media:4:GetParameter(7f000003) 611200813: 302992.339: read_media:4:GetParameter(7f000003) 611201837: 302992.356: read_media:4:GetParameter(7f000003) 611202684: 302992.373: read_media:4:GetParameter(7f000003) 611202947: 302992.390: dfree: pool 0x8c5bcd98, ptr 0x8c643610 611203173: 302992.421: read_media:4:ComponentDeInit 611203958: 302992.447: dfree: pool 0x8c5bcd98, ptr 0x8c6bcb90 611204402: 302992.477: dfree: pool 0x8c5bcd98, ptr 0x8c6baf70 611205188: 302992.511: read_media:4: total=0 not_loaded=0 611205464: 302992.529: dfree: pool 0x8c5bcd98, ptr 0x8c6bccd0 611206211: 302992.556: dfree: pool 0x8c5bcd98, ptr 0x8c6b9c70 611207222: 302992.578: dfree: pool 0x8c5bcd98, ptr 0x8c6bacf0 611207484: 302992.614: dfree: pool 0x8c5bcd98, ptr 0x8c6b9a90 611208278: 302992.637: dfree: pool 0x8c5bcd98, ptr 0x8c6b9970 611209271: 302992.673: dfree: pool 0x8c5bcd98, ptr 0x8c6b9cd0 611210222: 302992.697: dfree: pool 0x8c5bcd98, ptr 0x8c6b46b0

I've also tried h264 / AAC in mp4 container (Serenity from http://www.h264info.com/clips.html) but I get the same error:

817588734: 499375.305: open ( /home/pi/ser.mp4 ) 817589496: 499375.335: convert_pathname( /home/pi/ser.mp4, /home/pi/ser.mp4 ) returned 1 817590477: 499375.362: dfree: pool 0x8c5bcd98, ptr 0x8c6bd130 817590752: 499375.391: read_media:5:RIL:container_open error 6, (/home/pi/ser.mp4, error opening file) 817591842: 499375.411: read_media:5: reverting transition, going to Loaded

popcornmix commented 12 years ago

Apologies for not looking at this before now. I've just got it working with the lastest firmware. Here are instructions:

Get latest firmware (https://github.com/Hexxeh/rpi-update) or use Wheezy image (http://www.raspberrypi.org/phpBB3/viewtopic.php?f=50&t=8071)

GPU needs additional vlls for demuxing video files cd ~ sudo mkdir -p /sd/vlls wget https://dl.dropbox.com/u/3669512/vlls.tgz cd /sd/vlls sudo tar xf ~/vlls.tgz

allow GPU to access filesystem: sudo /opt/vc/sbin/vcfiled cd ~/pyopenmax sudo python -i import pyopenmax pyopenmax.play("/opt/vc/src/hello_pi/hello_video/test.h264")

and I get video playing.

The GPU reading files and parsing containers is something we don't encourage, hence the lack of vlls in the standard distributions. Ideally the container parsing would be done by the ARM using ffmpeg/libav, like in omxplayer.

dapa79 commented 12 years ago

It's working!!! Many thanks! :) Now I can start coding on my little python project.

I've tried the above with test.m264 as well as the mp4 trailer and both were silky smooth. No audio though, but I suspect test.h264 is a video stream only, and my mp4 contains AAC that's not licensed. Can this method of running movies handle audio?

I'm an python/C beginner and find the openmax code difficult to understand, so Im afraid I don't know how to modify pyopenmax to use for instance pyffmpeg. I guess that would be needed in order to get audio working as well.

Peter, perhaps you could add a pyffmpeg connection to pyopenmax? Im sure it would be most appreciated by beginners such as myself.

And again, Thanks!!

ghost commented 12 years ago

I followed @popcornmix's directions using the Wheezy image. Now I'm stuck in the while loop just after read_media.open_uri waiting for the port to change state. Any ideas?

Looking at the output with verbose enabled:

Command complete read_media
Command complete read_media
Command complete read_media
Command complete read_media
Command complete read_media
Error: 0x80001012L read_media
Getting state 1
Moving to state 2
Getting state 1
Waiting...

The error is from read_media.disable_port(PORT_MEDIA_READER_CLOCK_INPUT) which I presume means the clock input is already disabled.

peterderivaz commented 12 years ago

Oh dear, I've tried it myself and get the same problem.

I guess something must have changed in the Wheezy image that means this no longer works. Perhaps the VLLs popcornmix provided are no longer compatible with the latest VMCS?

I guess the best fix is to try and use the ffmpeg libraries to load the data instead of the GPU. It is on my Todo list...

Apologies for the disappointment!

ghost commented 12 years ago

Thanks for looking into it. At least I know I'm not doing something wrong. I'll keep a look out for updates.

peterderivaz commented 12 years ago

Oh dear, I've tried it myself and get the same problem.

I guess something must have changed in the Wheezy image that means this no
longer works. Perhaps the VLLs popcornmix provided are no longer compatible with the
latest VMCS?

I guess the best fix is to try and use the ffmpeg libraries to load the
data instead of the GPU. It is on my Todo list...

Apologies for the disappointment!

popcornmix commented 12 years ago

Yes, it is a problem with VLL compatability. We used to build all VLLs then delete them (so we could test things like MPEG2, VC1, and H264 encode). Now we have pulled more libraries into the main start.elf code I don't build the VLLs (and so the linkage isn't there).

The best fix is what Peter suggested.

justinasjaronis commented 9 years ago

OK I get that demuxing is depreciated. I'm pretty OK with that, i can prepare demuxed files both for audio/video. but.. peterderivaz, maybe it is possible to remove read_media component from the pipeline? So it would work with uncontainered .h264 file, as does hello_video? What steps and direction has to be taken, to accomplish this?

I looked at hello_video/video.c code and I see that it uses big chunk of code from ilclient component. Do we really need to implement/wrap that library on python?

TuomLarsen commented 9 years ago

I too am getting the "State not reached" error, on Raspbian Jessie and RPi 2, trying to play "/opt/vc/src/hello_pi/hello_video/test.h264". Please, are there any workarounds or perhaps are you having any plans for fixing this? I understand this is a bit old issue so I just wanted to check in about its status. Thanks!

badmetacoder commented 9 years ago

Same issue here.

nulijiabei commented 5 years ago

Invalid https://dl.dropbox.com/u/3669512/vlls.tgz