bvibber / OGVKit

Ogg and WebM media playback for iOS
MIT License
216 stars 67 forks source link

OGVDecoderOgg cannot process an .oga file #219

Closed olSolo closed 4 years ago

olSolo commented 6 years ago

I try to play an .oga file. Firstly, when I create and OGVInputStream for this file, it's media type is nil, so I have to create OGVMediaType(string: "audio/ogg"), and get a decoder, but I guess it's another issue.

So I get OGVDecoderOgg, and call process(), it calls oggz_read() and gets 0 as a result, which means to be end of file.

This is the file I play:

OggS�����=�!OpusHead8�>OggS�����������OpusTagslibopus 1.2-alphaOggS�����[��O_mm��v�����sumzwX`'#��_Cxe�����ND�~�����pY�����q�E m1+�+�3�6����h��fu��c�d�)ki���
�2����<��]�IXN8����o=�x�(j%���&#`�#MT9����X�9s��+�X�S���r�R��i��hi��~��>��W���։�"[UA��-P��I1ƥ�J���Aڄ�`Xakt�%m���:�����;J���9��d2˔��MԳ��䍵�Z����KiNX1.?�"���<wں���2�.j!Я�@o��f�j�+<����+!ی![._�\X���b.���o{�5���ӂA���Jw��z%  A;����E�?7j����t2������7���E�-(�9�P6�%3�T�e�j-�@/��f`�F/\�G�E.�ǰ�b��    ?���3އ�x����~q��X�7#`�F�Ah����ƺ�ם,m[����Wܖ�Εe����;c�V��   �����<}�Xu�����S24D Ŀz<����֦���'�B�����w�Z�Z!ۊ{N�]�%�M�7-�s��8���F�[�ހX��"�r����t����o-���
#��!ڸ�  �k̔�a5D�Rj�E8�ήQ���C�S�2��70���7�?�gl���04��Xd�����i�պ�ii�Uy�������ˆ0�X�נ
�u�¶���+
�=;v�}x-�svޓ�t��o���R�J��~|�gje1(YRLC?R�Q��8�-�kr�,��]��K�v�P���mDB"Y��Ǝb\Y��iL#W��S���x����S�INy�B�X�M�����x�S��M��)�Z�#N�q���C���La"'Er�HU���*ꜿ�}`��y��J]hg8��Z�p�-&^#��������t��4dzU���AQ)a���L�П1fӰ~�"��<Ր��-!(*���iV
�R'�X����?5�Ij�HU�M%�{cM����L�(�������O�P�B_I��V�Em'E�F�J:��͌G�x��䈊�藡!�L�i��%d�m��}�ʠ�\��{���� �iv�W�qc�p�)/������X�[yhf ����ͫ4�[c�w�o1����]Æ׹��q_b.J���X��� �*t'd�ΥE���Do��%J���'O4m���Rͪ;#��sJ�]o!]�7O �:z�{��k��2t�;��))�=nV`X�d���]f\���S0`,)S��b��Q���D����[/���'B�Ct�b+���G�'�0t{������ulR�b� �$�U(�:ŋ��~���»,�4��8B�HBhiZ�-���n0���r ~?��=D��c�X�@����b��������7)�!a� F����?z��G]-�b&����_�    ���L�eSo�EIzO��3##���`������n}rz�B��5���;al�`�Cy/�
X���U(X˜կ{�8BlP&�!�|P��8
y�ݙ����Ǔ�lJ���5P �5N&�;�Q��J7J���5��W]����!�A�����D���z�s�WS��Z��7H�,�����@�)�2�Xn,\����J�����ߠ'7�S���L�N�}%e����e]�4J�%���N1Tؗ7�#��|�! ���b�0�ß���|u��92ά�UZ�[���Z������2�-@X��hI��EW&>��#�m:���{�S��,�j���D}��$�{����Z����?XAC\�ڳd,��os޾A^�!`�>b�$�(��C����̱]�N��#�41��;+�_��� �[X��.7Q���Ep:��OB�0�C���N��l�L@������8?
N[��5Zoշ�1�s̰�E�'��oL������e�閙��ܙ����pf�W�ļ��N%��N�/����k�OggSh������I}iv{�nV|}}zso�uX�)�)
$TX���M���o�������M3⻞|Mam�!c�`�{&�5�O|�D������C�d����W�������"cj��ϣ���G,w�"�"���6۽N�ߡ�t� �B":Y��$��k�0x}X��Cڸ�iRa��{�_3s�S�$�qQ�����oڇ!�;&�&㪾-3��<�|�����9�r�nm��-9��nuHeE��P������3^$��>[��9�N;�]����9*3bO��x}�}lʀX���K>~�=Λ�6H���`������O
[����)3��.v�$@ˏ�Tg�N��?��b��4�����}�<J�������
�n�����tN*��1XR�Nc%�
.
�X�kZy��)X)k��5�&��,�V��mjj0�l��Sfj�����X�gn�]�_e��(O'}Uy���4�����@`�Xӳ����0��9��T�u|I]��j@�f�}��+*  0�X��WM�;2�U� 3�b��6����/���  ��p���s�h�LM�r`�lu��~"��>
����4����l����x������~qd*ޙ�حT�("�����Bj��J|��g�g�୷�X��U �dhxJ�@�*Rz~�t-.�o�hDNCYS-����K*�=�h㢡�?ղ��E[9D+b�3����bw�
�߇_�.]���IBpNA_���/v6}�IB�S���e2������9��W����*��d��X�1>�d�d�����AԵ�/H��0�O�!R'e��^9�(�=�ղ���M��,�x�m�=F˸\���~~�(c;�H��:Tub�����6�Y� �O���Jza�Ӿ��X`y�)2�V)3��|����P���;���}G��M捐]v(G`ۑ}'���R���k���
^�jS�0�G��K�Nz{�=Zd���?�X�ڞBէ,���0��m���v��A}n����I&�QȮ������C����5    �(%Fʑ3L�l���e������B��]�+q�?�ی�
���
<v:��9 �,X�,��K;W!�z(�X�L�,���?���;��czK�,����k���_/ԏC��d�|jw�J{��}�w��?�����m"B4�@�{�9�Kk����N�7ԣ �3j�΋���9�J�)����Z*p������2����X�ebs�u��J&�b��ΒЮ��p"hxׅ呸�}eq�\�\x���ؿ�Zh�y2?�\*���B������TlÌs�ǫ}Q
�D�kA���a���7L�����   W�
ߺ�[����

(X�C)�RITxr��45� �~�OB�������z=E�b#M��_$1hNs��r���R�BecҸ��33��l7�D#��o��M��z��r���Ij/!E (�3�?�����|p��d��Y�xX�� $�
�v娠%��^Rⶦ@ɏ���\�<��v3
����_v����-4��M�;d�7�I�������������0�L��r�CnQ·x˭k��y[�ou�x�W��%�X�������&}����x^��8�r�i/\I
���e�ݽ�Q/��ūClf1�d3���6�6���f[�@����e�x�J�p��������k0���+��xfk)�~����u8�`@X�<.��/-q�Sy���N��#7��0�wR���b�_�0���gْ�뀷+�k����J�ʛK8k�Жug�"p�P�E�U�� �'""м]�6����rD���M�(w"����
IXꢢB�WɉFX�7�/�Q�rW����{���u��t  ����ǧ��ϲ����L��vb�m�u�N������z�PK�+���},����������;��en��Kl�y(�8_*�l�j��ގ�POggS����$���hlln~}mryq�xjusoX��M��E�t�#���fspU*�Tp�T뫣7t������k��??s    I���Ю�O����I�n�׃~����A}%(����o�Wn��JM�a�<�F5G|�a�;�UX��R�uLӬ�ʥ[�cM�\E�iU�/�|Q��'ʟ^~]r*�kn��Ӕ P��곥������v)����Mz�4xr����&�[�Y;"��6���p!�&uT����@i��X�*�W��� ����.���H�f��2}O�g,�zc"���w�1��%B��{+Ը����?0tLǬ�.��ҁ��5Q��z[���˛op�G�*�X`��?FI�~��`X��X+؁M�V�Iiՠ~��Xkc�V���G�:�0�8��C����2>������ ��[ΓC;~I������K/6h��s��͇=�����uσ�H�aX�D�x�N��ƒ�R�����ݬ�ZK�[�&��ˁ��ދH�
�T5\��;���j"L�FS�Z���$Cn\�c�
��v���-[�$IfqI)�u�}�
�t��m������gz4l���y��Ny����w��X뙍�c��maɢ����P�����z��܋��um:��H�L5�LyWc'������\� �:;?V|�s��O~EY����#�wޛ?mʃ��f�3�=�=�Q[f�3L ��w������<
��jAFX��p`�0m5߻>LL'�fn)���#�p�������3�LW���OC��d~y��&Z:y��>�JL���-�g�Q�i��oR5f��>E�좴-<Z�"?���y�[mOX�����l�������.9�S4�ltBLbUk�hk���T�x�ܯF��H�9�@p�����jS�E�&4��ht�q��4q��:�`���b�<�ɌտË�fk=E�X�BpY����)�0�;���Z.��;�"����e̎� ��+���9�!����5>���n��ۛ26�ԙns;G!X)�S�0~c���3�;5���!M��7m�l�I�$�@�J\p/AG���PX��rn�]f���%�b�� ;j��+0zF���e�~?�}����R�m�\J����ҡ
j5�X    ��Y�㛤̱�5����In�X[���*_���,�V�*@ 3�H�x��X�\B^vz��'.zH�۱+s�.7c�Y��Sߒ�…"�nFL���bV���g;�2HM���F���c�C�&3��uEqܬ�O��z���@�:v��N⪹��9��Vz3w{    vͬ���.�7�e@X�ǻ~�HKVY�f���������M��I�}x<�k��{0_��9߁�s���
�2��wi�vb?�x�E�
MG
����\$uK�y��ڳ�� ���N���џ�eF�\h�4�L�#�xD��RX��6e���W��Sf��M��x���)�݌#���VT����
��6��d��*���@�XN50��vN�{B7t�ݮ.W(�j�*�v�3�\��V�y���p��u:KB�X��e��B��1����f�Q�  ������As��Fa�5�{Te�ѵ�"�J�'��y1�.��\��ܸSfl
^Эk�Sɼ����yМ=����ѷ=�ӕf��8
!�Zu�S���)0��FX��?H��:�J�W���qj�p'�ܷ�����oG*<.�ش��!��]|��?��,c"B,� J�i�!P  ��[�O�������Ì�ޗ�L��o]�;,R&-]�*�'֠X��+�Tg[��Y!��P3�+u�=4psE��ۂ��8���Ʋ�9@���2gĢ>�N���a�!����(��xIB�z�h��eE�G��&s��W�����º��gH4�OggS��������"liyxgzlxjz�ps�tdX�ZG�H��P�:
�}:�a���Si���ܕ��Y��덕)H<g�d=��~R��][�͐f2����*��oaT�99n��mW]�4�ib�3MW��mu�R�_3݂�@X����}�lH�?���9��TƬ������\�
^l�a�-���3�\޼��).�(+e$�o��BƸ�g)O� چ�΂�m����™�<�c�N5&<횰X�UK<��|V`=-Ƭ��D�T_R�-����X,��&�T��R`������'|�t��۳{
�
���➔)��j��/����Kދ�0�[�/�|�=G�8��N�F�ѽ|.
������j#j�T��X�D���t���Pe�ߎ�a����k����b�V�#�\X���8Y| B� Ca��n������H���֮� �y ��f���f���~��;�_�T�kn�I�W���;�)i�����w�X���m�F�����i7H��ѩF�-)�Hr[���~E%U]��FdM�MS�~�@�m&}sn��X���8�`�F�F
hmkZ��3�J�؄ı�C<��6
X�Q#�A��C9,7L���=�f���!g�ut�Ocb  � @҂�J�{lY��$��on[�5�Ӈ�����Q���d�����6��#����   ��a��J���O_5��@�m��+��O5�/bX仴•qg��˞�8���[�,���ssh``o����1��"�-���P:��������g�:�*
`R�q�z�Z\���2bZ�
�}�'s�#aUA v�^���۵|?�
n�X��1a<����Ϩ�ޕ�s_����o��t���e���&�ݧ?9Wϸ�w���R��t��.cŝѩ���F���
C4�Br�v�L��-��G%�ЕX,bf_�M�pb����7P�i6,�X���Z������{���u�^l��~����m�c�&���cn��@ܬ����^��6P�uN���IթZ�q�x�{�%��0����s�́�G�
r���_�؏�7K�oX���FM�,�I�a�ZWnT2&�����|P��Qe�k��V����a�Za�B,�7u~������a����&���eQzj�a�UJ��u��ɮ�ip
s��I��荊�������47��X��$A���x˦W��c�^~$r�&E3~x�M���U�����X���7Nl�����ࠨ����� �\R�W���/������ǿ=�����p}�{t�ψx2Qh��5/Ϛ�n�,�2L%��]��q��2��+R��X�^J��dNHL����ˆ2l��1Q��L71z�A���w��r�I���Ib���6�8QE��:�p(��;�W��D�-���L���������ZO��8��ۿ�ov��oY\p|�o�X���#g�p��U�
^#�ֶ���ޫ�D�T�����&����)����m�I��}��E�=����?�{Jm;�K�j�|��P ��� F�?D;pt۪�KQ)B�C��u��T�I�lS��nz`X������������𾡚��f��:h�:,�y�X��]�$���J�u��\�8�q>2��Gw�s�Nγps���Gb)�g���~��T�X�u�q"TX�x�P;    \�DS��F�ϚW$����3�3va�����hX����{�<n|9���P���7
���'[�%���34޸K��Rj1�Ó.�e���}�mf9d<D�V�|Zjﳛ�@ı*�}���Eá��\�- �#Ra�����|��X.�G�ڎ���m�=�n;:�9��K�H-}K���.��UN�ty��k)^��|;\�S!�C�7f�{󢄭���}����Au� �>��C֘|S��lI�OggS��������qlj�vly�X�F���a5����*d��.����>LJ��9X�h���b��i�E+�m@�Ii���"�>d�:X��Ϩ�|Dq���j��kş�5�:ꭼ5{R����$6
2S X��<�tm0{I(H�^U9r��K��_b�䔳��t԰%�}���6Z{��cH���MjJ%�1&��1(�y[,K�߾T�sj� �;�\�5�N��
L���G�X�ꐱ�:��o}S��ra
@쇂I28��N��?�W��&$mZ6AC"�ȄU�Pu��)bj�p�<^�����T{"��������{��z�@J�!�k�2���l�.J������ P�|�F��&��Z��X�Y~��L�3}6v�����.�����lYv���VWA�Χ�sU�u������^u-�:�)��t7���ߥ�G��6uQ�\}`V���W�V�mv���Wu�   �hz����Ws/��q�@X���Xv%�y��"�’x��^�D��[%�^�Xf8�x/-Sˆ��?kZۛ]��d�~���
sy4�9�U5!K����7�q�z�X�z��uF�+��c̞�ިX���8
L5%����LO{�
������U�)�OAڮM:�HŽe�*"�oǬ��]��N�`@.y����6�O��`}����> �ݞrЇ:��ЇL�������,�E��SK}���}.1r�3A�X���dfЙ�l�
�N�$�-����}[�s�<�É������y{�����;�Ʀk�n &Oa4@�T��OR��,q'�)��-�٠�� ��y���o35����배y�����l����L�m�b�yJo

So is it a bug, or I do something wrong?

bvibber commented 6 years ago

Be warned that the demuxer and decoder APIs are not very good yet, so there may be oddities using them directly. :)

I believe that first run through [OGVDecoderOgg process] will process all the raw input stream into packets if it's short enough -- if it's longer you may need to run multiple process calls in your loop.

Assuming nothing went wrong, it should flip the dataReady and hasAudio properties on at that point. If something is going wrong, you might see more output if you call OGVKit.singleton.logger.level = OGVLogLevelDebug in your setup, it should dump some more detailed debug into via NSLog()

Unfortunately your sample file seems to have pasted as text :) so I can't test it to make sure there's not a decoder bug...

olSolo commented 6 years ago

After first try to [OGVDecoderOgg process] it gets into this state:

else if (ret == 0) {
            // end of file
            [OGVKit.singleton.logger debugWithFormat:@"END OF FILE from oggz_read?"];
            return 0;

and returns 0, in the example I found that it means it's not ok and smth went wrong, the data is not ready. Actually, I try playing Telegram voice notes, I attached an example. 5238154067095585246.oga.zip

bvibber commented 6 years ago

A 0 return from process should indicate that it's read all the packets in available so far through the demuxer.

You should now be able to see the metadata and return decoded packets. What do the dataReady, hasAudio, audioFormat properties return? Does decodeAudioWithBlock: work?

It's possible there are bugs with short files; I'll test with the sample file in a bit.

olSolo commented 6 years ago

Strange, but I don't have decodeAudioWithBlock method in OGVDecoder.h, although I can find it here in master. I installed 0.5.13 version via CocoaPods, and the only methods I have are:

- (BOOL)process;
- (BOOL)decodeFrame;
- (BOOL)decodeAudio;
- (BOOL)seek:(float)seconds;

+ (BOOL)canPlayType:(OGVMediaType *)mediaType;

screen shot 2018-09-12 at 13 48 48

bvibber commented 6 years ago

Ah, git master must be ahead of the version in the specs. :)

Yeah, looks like something's going wrong based on those props & ivars; I'll test it when I get a chance with the sample file and see if I can figure it out!