futzu / SCTE-35_SuperKabuki

SCTE-35 Inserter for MPEGTS. SuperKabuki is SCTE-35 Packet Injection for Ad Insertion, powered by threefive.
https://github.com/futzu/SuperKabuki
BSD 2-Clause "Simplified" License
12 stars 2 forks source link

IndexError: index out of range #6

Closed Avencheng closed 5 months ago

Avencheng commented 5 months ago

Hi! It's me again :)

I kept getting the same error after running my program for a while, and it never happened before. I used the following packages for superkabuki 0.0.59 :

Name                    Version                  Build  Channel
superkabuki              0.0.59                   pypi_0    pypi
threefive                2.4.35                   pypi_0    pypi
new-reader               0.1.9                    pypi_0    pypi
iframes                  0.0.7                    pypi_0    pypi

The error i got when i using 0.0.59.

PMT Section Length: 555
frame=67773 fps= 30 q=29.0 size=  821881kB time=00:37:39.15 bitrate=2980.2kbits/
frame=67788 fps= 30 q=29.0 size=  822227kB time=00:37:39.68 bitrate=2980.8kbits/
PMT Section Length: 555
frame=67804 fps= 30 q=29.0 size=  822537kB time=00:37:40.18 bitrate=2981.3kbits/
PMT Section Length: 555
Program Number: 54196
PCR PID: 7644
Program Info Length: 2114

Added Registration Descriptor:
    b'\x05\x04CUEI'
Traceback (most recent call last):
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki59/bin/superkabuki", line 7, in <module>
    sk.encode()
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki59/lib/python3.11/site-packages/superkabuki.py", line 214, in encode
    pid = self._parse_info(pkt)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki59/lib/python3.11/site-packages/threefive/stream.py", line 481, in _parse_info
    self._parse_tables(pkt, pid)
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki59/lib/python3.11/site-packages/threefive/stream.py", line 467, in _parse_tables
    return self._parse_pmt(pay, pid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki59/lib/python3.11/site-packages/superkabuki.py", line 379, in _parse_pmt
    d_len = pay[idx]
            ~~~^^^^^
IndexError: index out of range

I also tried the older version (superkabuki 0.0.49), which I think was perfect as well, but now I got similar error as above, i used the following for superkabuki 0.0.49 :

Name                    Version                  Build  Channel
superkabuki              0.0.49                   pypi_0    pypi
threefive                2.4.1                    pypi_0    pypi
new-reader               0.1.7                    pypi_0    pypi
iframes                  0.0.7                    pypi_0    pypi

Interestingly, It suddenly insert all the cues which has already been inserted at the corresponding time. The error i got when i using 0.0.49.

frame=62097 fps= 30 q=29.0 size=  758738kB time=00:34:32.14 bitrate=2999.6kbits/
frame=62113 fps= 30 q=29.0 size=  758917kB time=00:34:32.67 bitrate=2999.5kbits/
frame=62127 fps= 30 q=29.0 size=  759065kB time=00:34:33.15 bitrate=2999.4kbits/
(1021.5, '/DAlAAAAAAAAAP/wFAUAAAAGf+/+BXrRGP4AUxWIAAABAAAAZiKZuA==')
(1081.47, '/DAgAAAAAAAAAP/wDwUAAAAGf0/+Bc0rIAAAAQAAADyDFPY=')
(1201.5, '/DAlAAAAAAAAAP/wFAUAAAAHf+/+BnICWP4AUxWIAAABAAAAOH3Kzg==')
(1261.47, '/DAgAAAAAAAAAP/wDwUAAAAHf0/+BsRcYAAAAQAAANwiLfo=')
(1381.5, '/DAlAAAAAAAAAP/wFAUAAAAIf+/+B2kzmP4AUxWIAAABAAAAKcImoA==')
(1441.47, '/DAgAAAAAAAAAP/wDwUAAAAIf0/+B7uNoAAAAQAAACFRBI0=')
(1561.5, '/DAlAAAAAAAAAP/wFAUAAAAJf+/+CGBk2P4AUxWIAAABAAAAtaZJUg==')
(1621.47, '/DAgAAAAAAAAAP/wDwUAAAAJf0/+CLK+4AAAAQAAAAkXOEo=')
(1741.5, '/DAlAAAAAAAAAP/wFAUAAAAKf+/+CVeWGP4AUxWIAAABAAAAZ2Ms2A==')
(1801.47, '/DAgAAAAAAAAAP/wDwUAAAAKf0/+CanwIAAAAQAAAMtpiWA=')
(1921.5, '/DAlAAAAAAAAAP/wFAUAAAALf+/+Ck7HWP4AUxWIAAABAAAAZqHzpQ==')
(1981.47, '/DAgAAAAAAAAAP/wDwUAAAALf0/+CqEhYAAAAQAAACK9yhM=')
frame=62143 fps= 30 q=29.0 size=  759240kB time=00:34:33.68 bitrate=2999.3kbits/
(181.467, '/DAgAAAAAAAAAP/wDwUAAAABf0/+APk04AAAAQAAAM/zvg0=')
(301.467, '/DAlAAAAAAAAAP/wFAUAAAACf+/+AZ4AYP4AUxWIAAABAAAARV7fnQ==')
(361.467, '/DAgAAAAAAAAAP/wDwUAAAACf0/+AfBmIAAAAQAAAOYaSes=')
(481.5, '/DAlAAAAAAAAAP/wFAUAAAADf+/+ApU9WP4AUxWIAAABAAAArzuq7A==')
(541.467, '/DAgAAAAAAAAAP/wDwUAAAADf0/+AueXYAAAAQAAABE4LA0=')
(661.5, '/DAlAAAAAAAAAP/wFAUAAAAEf+/+A4xumP4AUxWIAAABAAAAD8WPcA==')
(721.467, '/DAgAAAAAAAAAP/wDwUAAAAEf0/+A97IoAAAAQAAAO5rvlQ=')
(841.5, '/DAlAAAAAAAAAP/wFAUAAAAFf+/+BIOf2P4AUxWIAAABAAAARz8mWQ==')
(901.467, '/DAgAAAAAAAAAP/wDwUAAAAFf0/+BNX54AAAAQAAAIYvB5g=')
frame=62157 fps= 30 q=29.0 size=  759399kB time=00:34:34.16 bitrate=2999.3kbits/
frame=62173 fps= 30 q=29.0 size=  759572kB time=00:34:34.69 bitrate=2999.2kbits/
(121.433, '/DAlAAAAAAAAAP/wFAUAAAABf+/+AKbDaP4AUxWIAAABAAAAdWToAw==')
frame=62188 fps= 30 q=29.0 size=  759766kB time=00:34:35.17 bitrate=2999.3kbits/
frame=62204 fps= 30 q=29.0 size=  759928kB time=00:34:35.70 bitrate=2999.1kbits/
frame=62218 fps= 30 q=29.0 size=  760083kB time=00:34:36.18 bitrate=2999.1kbits/
frame=62234 fps= 30 q=29.0 size=  760261kB time=00:34:36.70 bitrate=2999.0kbits/
frame=62248 fps= 30 q=29.0 size=  760417kB time=00:34:37.18 bitrate=2998.9kbits/
frame=62264 fps= 30 q=29.0 size=  760610kB time=00:34:37.71 bitrate=2998.9kbits/
Program Number 18137
PCR PID 7857
Registration Descriptor added b'\x05\x04CUEI'
type: 73 len: 121 bytes: b'Iy\x10\xb6~\xccj\xd5\xc3v\x17\x93\x0cn\xe977\xe7\xe6\x89$@\x8d\x9b%\xbc\xb4d\xec2\xe7-\xf1\x07\x88\x8b\x1cG\x01\x00\x184\xa1^\xdc\x08))\xe6\xc19\x92|\xcb\xc8_dQ)s1\xd41\xf6g\xe0h\xd5~\x9c\xd3\xf1\x89M!\xda\x10\xd2\xb8O\xe6\x9a\xd1\xf2\xdd\xe7\xe3k\xff\xc7V\xf0Xm\x97\xe3ZI\xeb8\xa5'
Traceback (most recent call last):
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki49/bin/superkabuki", line 7, in <module>
    sk.encode()
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki49/lib/python3.11/site-packages/superkabuki.py", line 192, in encode
    pid = self._parse_info(pkt)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki49/lib/python3.11/site-packages/threefive/stream.py", line 459, in _parse_info
    self._parse_tables(pkt, pid)
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki49/lib/python3.11/site-packages/threefive/stream.py", line 445, in _parse_tables
    return self._parse_pmt(pay, pid)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/imagecuetone/anaconda3/envs/ffmpeg611_kabuki49/lib/python3.11/site-packages/superkabuki.py", line 358, in _parse_pmt
    d_type = pay[idx]
             ~~~^^^^^
IndexError: index out of range

Do you have any idea about what's going on? And let me know if you need more information. Thanks!

futzu commented 5 months ago

See where it says PMT Section Length 555?

It should much less

Output File:    2.ts
PMT Section Length: 90   <---- Section Length
Program Number: 1
PCR PID: 49
Program Info Length: 26

Added Registration Descriptor:
        b'\x05\x04CUEI'

Found Streams:
        Stream Type: 27  PID: 49  EI Len:  9
        Stream Type: 4  PID: 50  EI Len:  3
        Stream Type: 4  PID: 51  EI Len:  3
        Stream Type: 4  PID: 52  EI Len:  3
        Stream Type: 4  PID: 53  EI Len:  3
        Stream Type: 134  PID: 54  EI Len:  0

Added Stream:
        Stream Type: 134 PID: 134 EI Len:  0

How many streams dd you have in that video?

run

threefive show your_video.ts

and show me the output.

Also send me your whole command ffmpeg and superkabuki, you may just be starving superkabuki, it may be getting too far ahead. We can fix that easy in ffmpeg if needed.

futzu commented 5 months ago

PMTs are program specific, so even if you have multiple programs, that is still a big ass PMT.

Look at this, this is your problem

Program Number 18137 <------- This is odd

PCR PID 7857    
Registration Descriptor added b'\x05\x04CUEI'

type: 73 len: 121 bytes: b'Iy\x10\xb6~\xccj\xd5\xc3v\x17\x93\x0cn\xe977\xe7\xe6\x89$@\x8d\x9b%\xbc\xb4d\xec2\xe7-\xf1\x07\x88\x8b\x1cG\x01\x00\x184\xa1^\xdc\x08))\xe6\xc19\x92|\xcb\xc8_dQ)s1\xd41\xf6g\xe0h\xd5~\x9c\xd3\xf1\x89M!\xda\x10\xd2\xb8O\xe6\x9a\xd1\xf2\xdd\xe7\xe3k\xff\xc7V\xf0Xm\x97\xe3ZI\xeb8\xa5'   <---- this is super weird. I don't think I know a type 73, 

It's blowing up parsing streams in the PMT.

Do a threefive show on the video and show me your whole command.

futzu commented 5 months ago

Apply some logic here, it has been working, and something changed, what changed?

Avencheng commented 5 months ago

I think the message of 'PMT Section Length 555' is from the udp://224.0.0.1:3536 which used for SCTE-35 insertion.

I use below ffmpeg command to stream the ts file as my program input: ffmpeg -re -i image_cuetone_test.mp4 -vcodec libx264 -f mpegts udp://224.0.0.1:3535

there are two ffmpeg command in my program, one of them will output frames and PTS from udp://224.0.0.1:3535 for my program to detect and make the sidecar file.

Another ffmpeg command will make a delay stream : ffmpeg -re -i "udp://@224.0.0.1:3535?overrun_nonfatal=1&fifo_size=50000000" -filter_complex "[0:v]tpad=start_duration=2[v];[0:a]adelay=2s:all=true[a]" -map "[v]" -map "[a]" -vcodec libx264 -f mpegts udp://224.0.0.1:3536

At last, the superkabuki command will insert the cues in the delay stream and output it to 230.0.0.14:3539 : superkabuki -i udp://@224.0.0.1:3536 -s sidecar.txt -p 0x86 | gums -a 230.0.0.14:3539

The threefive show output of input mp4 file:

(ffmpeg611_kabuki59) imagecuetone@imagecuetone-Virtual-Machine:~/Desktop$ threefive show image_cuetone_test.mp4

Program: 0
    Service:    
    Provider:   
    Pid:        5120
    Pcr Pid:    1
    Streams:
                    Pid: 0[0x0] Type: 0x1 H.264 Video
                    Pid: 1[0x1] Type: 0x0 MPEG-2 Video
                    Pid: 20[0x14]   Type: 0x0 MPEG-2 Video
                    Pid: 526[0x20e] Type: 0x0 MPEG-2 Video
                    Pid: 568[0x238] Type: 0x0 MPEG-2 Video
                    Pid: 631[0x277] Type: 0x0 MPEG-2 Video
                    Pid: 694[0x2b6] Type: 0x0 MPEG-2 Video
                    Pid: 964[0x3c4] Type: 0x0 MPEG-2 Video
                    Pid: 1024[0x400]    Type: 5 Unknown
                    Pid: 1286[0x506]    Type: 0x0 MPEG-2 Video
                    Pid: 3072[0xc00]    Type: 0x2 MP2 Video
                    Pid: 3840[0xf00]    Type: 0x0 MPEG-2 Video
                    Pid: 4096[0x1000]   Type: 0x0 MPEG-2 Video
                    Pid: 5086[0x13de]   Type: 0x0 MPEG-2 Video
                    Pid: 5120[0x1400]   Type: 0x2 MP2 Video
                    Pid: 5632[0x1600]   Type: 0x2 MP2 Video
                    Pid: 5888[0x1700]   Type: 0x2 MP2 Video
                    Pid: 7168[0x1c00]   Type: 19 Unknown
                    Pid: 8149[0x1fd5]   Type: 0x0 MPEG-2 Video

Program: 2
    Service:    
    Provider:   
    Pid:        3584
    Pcr Pid:    847
    Streams:
                    Pid: 0[0x0] Type: 0x3 MP2 Audio
                    Pid: 256[0x100] Type: 0x3 MP2 Audio
                    Pid: 512[0x200] Type: 0x3 MP2 Audio
                    Pid: 768[0x300] Type: 0x3 MP2 Audio
                    Pid: 815[0x32f] Type: 0x0 MPEG-2 Video
                    Pid: 845[0x34d] Type: 0x0 MPEG-2 Video
                    Pid: 847[0x34f] Type: 0x0 MPEG-2 Video
                    Pid: 1280[0x500]    Type: 0x3 MP2 Audio
                    Pid: 1536[0x600]    Type: 0x3 MP2 Audio
                    Pid: 1792[0x700]    Type: 0x3 MP2 Audio
                    Pid: 2048[0x800]    Type: 0x3 MP2 Audio
                    Pid: 2304[0x900]    Type: 0x3 MP2 Audio
                    Pid: 2560[0xa00]    Type: 0x3 MP2 Audio
                    Pid: 2816[0xb00]    Type: 0x3 MP2 Audio
                    Pid: 3328[0xd00]    Type: 0x3 MP2 Audio
                    Pid: 3584[0xe00]    Type: 0x3 MP2 Audio
                    Pid: 3840[0xf00]    Type: 0x3 MP2 Audio
                    Pid: 4096[0x1000]   Type: 0x3 MP2 Audio
                    Pid: 4352[0x1100]   Type: 0x3 MP2 Audio
                    Pid: 5120[0x1400]   Type: 0x3 MP2 Audio
                    Pid: 5376[0x1500]   Type: 0x3 MP2 Audio
                    Pid: 5632[0x1600]   Type: 0x3 MP2 Audio
                    Pid: 5888[0x1700]   Type: 0x3 MP2 Audio
                    Pid: 6144[0x1800]   Type: 0x3 MP2 Audio
                    Pid: 6400[0x1900]   Type: 0x2 MP2 Video
                    Pid: 6912[0x1b00]   Type: 0x3 MP2 Audio
                    Pid: 7168[0x1c00]   Type: 0x3 MP2 Audio
                    Pid: 7424[0x1d00]   Type: 0x3 MP2 Audio
                    Pid: 7680[0x1e00]   Type: 0x2 MP2 Video
                    Pid: 7936[0x1f00]   Type: 0x3 MP2 Audio

Program: 3
    Service:    
    Provider:   
    Pid:        3584
    Pcr Pid:    846
    Streams:
                    Pid: 0[0x0] Type: 0x3 MP2 Audio
                    Pid: 3[0x3] Type: 0x0 MPEG-2 Video
                    Pid: 256[0x100] Type: 0x3 MP2 Audio
                    Pid: 512[0x200] Type: 0x2 MP2 Video
                    Pid: 705[0x2c1] Type: 0x0 MPEG-2 Video
                    Pid: 714[0x2ca] Type: 0x0 MPEG-2 Video
                    Pid: 736[0x2e0] Type: 0x0 MPEG-2 Video
                    Pid: 740[0x2e4] Type: 0x0 MPEG-2 Video
                    Pid: 752[0x2f0] Type: 0x0 MPEG-2 Video
                    Pid: 755[0x2f3] Type: 0x0 MPEG-2 Video
                    Pid: 768[0x300] Type: 0x3 MP2 Audio
                    Pid: 788[0x314] Type: 0x0 MPEG-2 Video
                    Pid: 793[0x319] Type: 0x0 MPEG-2 Video
                    Pid: 801[0x321] Type: 0x0 MPEG-2 Video
                    Pid: 802[0x322] Type: 0x0 MPEG-2 Video
                    Pid: 804[0x324] Type: 0x0 MPEG-2 Video
                    Pid: 805[0x325] Type: 0x0 MPEG-2 Video
                    Pid: 807[0x327] Type: 0x0 MPEG-2 Video
                    Pid: 811[0x32b] Type: 0x0 MPEG-2 Video
                    Pid: 814[0x32e] Type: 0x0 MPEG-2 Video
                    Pid: 818[0x332] Type: 0x0 MPEG-2 Video
                    Pid: 820[0x334] Type: 0x0 MPEG-2 Video
                    Pid: 821[0x335] Type: 0x0 MPEG-2 Video
                    Pid: 823[0x337] Type: 0x0 MPEG-2 Video
                    Pid: 825[0x339] Type: 0x0 MPEG-2 Video
                    Pid: 830[0x33e] Type: 0x0 MPEG-2 Video
                    Pid: 832[0x340] Type: 0x0 MPEG-2 Video
                    Pid: 833[0x341] Type: 0x0 MPEG-2 Video
                    Pid: 836[0x344] Type: 0x0 MPEG-2 Video
                    Pid: 837[0x345] Type: 0x0 MPEG-2 Video
                    Pid: 840[0x348] Type: 0x0 MPEG-2 Video
                    Pid: 841[0x349] Type: 0x0 MPEG-2 Video
                    Pid: 843[0x34b] Type: 0x0 MPEG-2 Video
                    Pid: 845[0x34d] Type: 0x0 MPEG-2 Video
                    Pid: 846[0x34e] Type: 0x0 MPEG-2 Video
                    Pid: 847[0x34f] Type: 0x0 MPEG-2 Video
                    Pid: 1024[0x400]    Type: 0x3 MP2 Audio
                    Pid: 1280[0x500]    Type: 0x3 MP2 Audio
                    Pid: 1536[0x600]    Type: 0x3 MP2 Audio
                    Pid: 1792[0x700]    Type: 0x3 MP2 Audio
                    Pid: 2048[0x800]    Type: 0x3 MP2 Audio
                    Pid: 2304[0x900]    Type: 0x3 MP2 Audio
                    Pid: 2560[0xa00]    Type: 0x3 MP2 Audio
                    Pid: 2816[0xb00]    Type: 0x3 MP2 Audio
                    Pid: 3072[0xc00]    Type: 0x2 MP2 Video
                    Pid: 3328[0xd00]    Type: 0x3 MP2 Audio
                    Pid: 3584[0xe00]    Type: 0x3 MP2 Audio
                    Pid: 3840[0xf00]    Type: 0x3 MP2 Audio
                    Pid: 4096[0x1000]   Type: 0x2 MP2 Video
                    Pid: 4352[0x1100]   Type: 0x3 MP2 Audio
                    Pid: 4608[0x1200]   Type: 0x3 MP2 Audio
                    Pid: 4864[0x1300]   Type: 0x2 MP2 Video
                    Pid: 5120[0x1400]   Type: 0x3 MP2 Audio
                    Pid: 5376[0x1500]   Type: 0x2 MP2 Video
                    Pid: 5632[0x1600]   Type: 0x2 MP2 Video
                    Pid: 5888[0x1700]   Type: 0x3 MP2 Audio
                    Pid: 6144[0x1800]   Type: 0x3 MP2 Audio
                    Pid: 6400[0x1900]   Type: 0x3 MP2 Audio
                    Pid: 6656[0x1a00]   Type: 0x3 MP2 Audio
                    Pid: 6912[0x1b00]   Type: 0x3 MP2 Audio
                    Pid: 7168[0x1c00]   Type: 0x2 MP2 Video
                    Pid: 7424[0x1d00]   Type: 0x3 MP2 Audio
                    Pid: 7680[0x1e00]   Type: 0x3 MP2 Audio
                    Pid: 7936[0x1f00]   Type: 0x3 MP2 Audio

The threefive show output of input stream:

(ffmpeg611_kabuki59) imagecuetone@imagecuetone-Virtual-Machine:~$ threefive show udp://224.0.0.1:3535

Reading rcvbuf_size of 212992
Setting rcvbuf_size to 3489660928

Program: 1
    Service:    Service01
    Provider:   FFmpeg
    Pid:        4096
    Pcr Pid:    256
    Streams:
                    Pid: 256[0x100] Type: 0x1b AVC Video
                    Pid: 257[0x101] Type: 0x3 MP2 Audio

The threefive show output of delay stream:

(ffmpeg611_kabuki59) imagecuetone@imagecuetone-Virtual-Machine:~$ threefive show udp://224.0.0.1:3536

Reading rcvbuf_size of 212992
Setting rcvbuf_size to 3489660928

Program: 1
    Service:    Service01
    Provider:   FFmpeg
    Pid:        4096
    Pcr Pid:    256
    Streams:
                    Pid: 256[0x100] Type: 0x1b AVC Video
                    Pid: 257[0x101] Type: 0x3 MP2 Audio

There is nothing changed on my code and commands (I hope so), another difference is that I recreated my virtual environment, but i do keeping everything the same as before.

What baffled me was that it ran fine at the beginning, but crashed after several tens of minutes??

futzu commented 5 months ago

Dude, it's an MP4, threefive on works on mpegts. Everything with SCTE-35 has to be mpegts.

futzu commented 5 months ago

I showed you iframes didn't I? https://github.com/futzu/iframes

What is a delay stream? Do this man, try it with just files and no multicast see if everything works. I wouldn't use 224.0.0.1, that's the all hosts group, it just seems like 224.0.0.0/24 might be problematic.

futzu commented 5 months ago

make sure your datagram size is 1316 coming from ffmpeg,

Judging by rcvbuf_size of 212992, you using a UNIX based OS, so that's good.

Grab a program called btop, and run in another terminal, just so we see what's happening with the processes.

Why are you using multicast? for the parts that one sender and one receiver use UDP, if it's on the same server, write files.

WAIT!

SuperKabuki, which runs on threefive, is seeing Program Number 18137 PCR PID 7857

but threefive show is seeing

Program 1 PCR PID 256

Program: 1
    Service:    Service01
    Provider:   FFmpeg
    Pid:        4096
    Pcr Pid:    256
    Streams:
                    Pid: 256[0x100] Type: 0x1b AVC Video
                    Pid: 257[0x101] Type: 0x3 MP2 Audio

I think you have superkabuki working on an the mp4 stream not mpegts.

Avencheng commented 5 months ago

I used to work on that MP4 file before, it worked. the ffmpeg command that I showed you above would convert it into mpegts : ffmpeg -re -i image_cuetone_test.mp4 -vcodec libx264 -f mpegts udp://224.0.0.1:3535

yeah, I agree it is better not to use 224.0.0.1. I tried the 239.0.0.1, but the problem is still there.

now I have used a real TV signal as my input, the problem no longer occurs so far, but I still need more time to test it.

Thank you so much, Adrian!

futzu commented 5 months ago

A few things to keep in mind.

Avencheng commented 5 months ago

Thanks for your helpful suggestions!

After few days of testing, I guess the error of index out of range is caused by ffmpeg. My test method is using TV stream as my superkabuki input, that means the TV stream doesn't need to go through my ffmpeg delay command before it goes in the superkabuki command. in this case, the error of index out of range never occurs.

But there is another issue, the cues in my sidecar never be inserted. I'm sure that PTS of my insert_pts and cues are bigger than stream's PTS. below is the outputs of my superkabuki command :

Reading rcvbuf_size of 212992
Setting rcvbuf_size to 3489660928

Reading rcvbuf_size of 212992
Setting rcvbuf_size to 3489660928

Output File:    output.ts
PMT Section Length: 55
Program Number: 671
PCR PID: 6119
Program Info Length: 12

Added Registration Descriptor:
    b'\x05\x04CUEI'

Found Streams:
    Stream Type: 27  PID: 6116  EI Len:  20
    Stream Type: 3  PID: 6117  EI Len:  0

Added Stream:
    Stream Type: 134 PID: 134 EI Len:  0

The threefive show output of the TV stream:

(ffmpeg7_kabuki59) imagecuetone@imagecuetone-Virtual-Machine:~/detect_stream_insert_35$ threefive show udp://@229.0.0.7:9000

Reading rcvbuf_size of 212992
Setting rcvbuf_size to 3489660928

Program: 671
    Service:    CTINews-HD              
    Provider:   DiviCom Customer
    Pid:        6115
    Pcr Pid:    6119
    Streams:
                    Pid: 6116[0x17e4]   Type: 0x1b AVC Video
                    Pid: 6117[0x17e5]   Type: 0x3 MP2 Audio

Let me know if you need more informations. Thanks

Avencheng commented 5 months ago

More informations!

I saved the TV signal as a ts file and use this ts file as my input streaming source, then the cues can be successfully inserted. The command I used for saving the TV signal as a ts file : ffmpeg -i udp://229.0.0.7:9000 -c copy middlesky_IRD.ts

The threefive show output of the ts file:

imagecuetone@imagecuetone-Virtual-Machine:~/detect_stream_insert_35$ threefive show middlesky_IRD.ts
Read 100 packets

Program: 1

    Service: Service01
    Provider: FFmpeg
    Pid:      4096
    Pcr Pid:  256
    Streams:
          Pid       Type
          256 [0x100]   0x1b    AVC Video
          257 [0x101]   0x3 MP2 Audio
Avencheng commented 5 months ago

I think the problem of index out of range has been resolved.

Just like you said, I should make sure that the datagram size is 1316 coming from ffmpeg . So I added ?pkt_size=1316 for the output destination on my delay stream ffmpeg command. so now it looks like ffmpeg -re -i 'udp://@229.0.0.7:9000?overrun_nonfatal=1&fifo_size=50000000' -filter_complex "[0:v]tpad=start_duration=2[v];[0:a]adelay=2s:all=true[a]" -map "[v]" -map "[a]" -vcodec libx264 -f mpegts 'udp://229.0.0.7:9001?pkt_size=1316'.

I have been running the program on a Ubuntu VM on Windows. I didn't encounter any issues when running program without adding ?pkt_size=1316 before, the problem of index out of range only occurred after I rebuilt the Ubuntu VM.

futzu commented 5 months ago

I am not Ubuntu on Windows support man, and that ffmpeg command seems a bit convoluted to me. You can hire me to do this, it would probably take me two maybe three days tops.