Lua脚本使用tshark不创建文件

我有一个从GitHub上找到的lua脚本。(https://github.com/volvet/h264extractor)当我从wireshark中使用它时,它会从pcap创建转储文件。 但是,如果我像这样从Ubuntu终端使用它:tshark -X lua_script:rtp_h264_extractor.lua -r a.pcap 它不会创建任何转储文件。是否有解决这个问题的方案或者这就是它的问题所在? 以下是lua脚本的代码。

local function extract_h264_from_rtp()
local h264_tap = Listener.new("ip", "h264")
local text_window = TextWindow.new("h264提取器")
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("打开转储文件失败")
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

谢谢。

点赞
用户2755698
用户2755698

你没有提供完整的 Lua 脚本,所以我下载了它。很明显,这个脚本只是为 Wireshark GUI 编写的,因为它在“工具”下注册了一个菜单项。换句话说:

register_menu("Extract h264 stream from RTP", extract_h264_from_rtp, MENU_TOOLS_UNSORTED)

这个脚本在tshark中根本不起作用。实际上,这个脚本确实应该以以下内容为开头,以便更清晰地表明它不适用于tshark

if not gui_enabled() then
    return
end
2020-07-15 21:18:47
用户5260190
用户5260190

我删除了属于 Wireshark GUI 的部分,并且它可以运行。

2020-08-16 20:15:35