0
votes

I'm looking for new solution to play h.264 steaming video ,which is based on 1722 protocol and entered in Ethernet from other device, in Windows 7 or 10 by using socket similarly with the way from linux environment.

I can bind network-interface directly using option of SO_BINDTODEVICE in linux and if I use that, video streaming is so smooth in vlc player and vlc statistics show bitrate is over 20,000 kb/s

so I tried two manners in Windows like below:

  1. using scapy module in python

    • sniffing all raw packet Ethernet
    • attach data on payload and send packet to vlc player
    • result is poor, because the bitrate in vlc statistics is almost under 1500kb/s
  2. using winpcap lib in C(VS)

    • sniffing all raw packet through pcap_next_ex or pcap_loop
    • attach data on payload and send packet to vlc player
    • result is bad, the bitrate in vlc statistics is 3000kb/s

1.

global dgramSock
dgramSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def prn(pkt):
    global dgramSock
    ...
    #filter to pick specific packet
    ...
    #attach data on payload and naming myPacket
    ...
    send_len = dgramSock.sendto(myPacket, ('127.0.0.1', 44514))

sniff(prn = prn, filter='ether)

2.

sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
addr.sin_family = AF_INET;             
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_port   = htons(44514);

...

while( (pcap_next_ex(_handle, &header, &pkt_data)) >=0){
      ...
      #filter to pick specific packet
      ...
      #attach data on payload and naming myPacket
      ...   
      sendto(sock, (char *)myPacket, myPacketSize, 0, (struct sockaddr *)&(addr), sizeof(addr));

}

I think that two manner what I tried looks not essential way.

In Windows, what is the best solution to send raw packet to other program fastly without loss?

1

1 Answers

0
votes

I don't know exactly my solution is correct approach or not but I left my solution for one who seek some solution same problem like me

My wrong approach what I have been was using VLC in Windows. I guess VLC listener buffer seem to small not enough to get all streaming data from socket, so streaming data looks corrupted or broken, even though little part of top in video played normal streaming.

So I tried new player, FFmpeg. FFmpeg provide ffplay.exe. It seems to decoder same with VLC.

I just send streaming data through UDP stack and valid port from Visual studio or Python. There is no issue using UDP socket, but you need to check listener buffer is enough to get all packets coming via network card.(like API: pcap_set_buffer_size)

If you can success to send your streaming data toward specific port what you want to send, next step is run ffplay with some command.

simple example command to run ffplay ffplay.exe -codec:v h264 -i udp://127.0.0.1:44514 -framerate 30

Tip) For beginner in ffmpeg like me, you should keep order of command, ffplay and ffmpeg have strong rule of arguments, but simple rule is explained as input and output rule. You have to give input option first and output option come behind -i(input) option

There is many branch to using ffplay or to your environment so my explanation would not match correctly in many situations.

If I can answer your question, I will keep track on that.

Thank you