Search code examples
luawireshark

Lua script doesn't create file using tshark


I have a lua script which I found on github.(https://github.com/volvet/h264extractor) When I use it from wireshark, it creates a dump file from pcap. But if I use from Ubuntu terminal like this: tshark -X lua_script:rtp_h264_extractor.lua -r a.pcap It doesn't create any dump file. Is there any solution to this problem or this is how it should be? Here is the code from lua script.

    local function extract_h264_from_rtp()
    local h264_tap = Listener.new("ip", "h264")
    local text_window = TextWindow.new("h264 extractor")
    local fp = io.open("dump.264", "w+")
    local seq_payload_table = { }
    local pass = 0
    local packet_count = 0
    local max_packet_count = 0
    local fu_info = nil
    
    local function log(info)
        text_window:append(info)
        text_window:append("\n")
    end
    
    if fp == nil then 
        log("open dump file fail")
    end
    
    local function seq_compare(left, right)  
        if math.abs(right.key - left.key) < 1000 then  
            return left.key < right.key  
        else 
            return left.key > right.key  
        end  
    end  
    
    local function dump_single_nal(h264_payload)
        fp:write("\00\00\00\01")
        fp:write(h264_payload:tvb()():raw())
        fp:flush()
    end

Thank you.


Solution

  • I deleted lines which belong to Wireshark GUI and it worked.