Skip to content

Commit

Permalink
fixed packet size
Browse files Browse the repository at this point in the history
  • Loading branch information
bwsw committed Sep 17, 2024
1 parent 12fa4f0 commit 926afe3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fn process_bsf(
}

loop {
let mut new_packet = Packet::empty();
let mut new_packet = Packet::new(packet.size() + 2048);
let ret = av_bsf_receive_packet(filter.ptr, packet.as_mut_ptr());
if ret < 0 {
break;
Expand All @@ -265,6 +265,11 @@ fn process_bsf(
break;
}
new_packet.set_stream(packet.stream());
new_packet.set_flags(packet.flags());
new_packet.set_dts(packet.dts());
new_packet.set_pts(packet.pts());
new_packet.set_duration(packet.duration());
// new_packet.set_position(packet.position());
new_packets.push(new_packet.clone());
}
}
Expand Down Expand Up @@ -437,6 +442,7 @@ fn handle(params: HandleParams) -> anyhow::Result<()> {
}

if skip_until_first_key_frame {
debug!("Skipping until the first key frame");
continue;
}

Expand Down
10 changes: 5 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def bytes_to_bits_binary(byte_data):
# set env LOGLEVEL=info
# file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_ab.mp4"
# file = "/home/ivan/Downloads/1_underground_supercut.mp4"
file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug.mp4"
file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_x265.mp4"
# file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_aud.mp4"
s = FFMpegSource(file, params=[],
queue_len=10, decode=False,
block_if_queue_full=True,
ffmpeg_log_level=FFmpegLogLevel.Trace)
s.log_level = FFmpegLogLevel.Trace
ffmpeg_log_level=FFmpegLogLevel.Info)
s.log_level = FFmpegLogLevel.Info
# counter = 0
while True:
try:
Expand All @@ -40,8 +40,8 @@ def bytes_to_bits_binary(byte_data):
first_hex_res = " ".join(format(x, '02x') for x in payload[:16])
last_hex_res = " ".join(format(x, '02x') for x in payload[-4:])
code = decode_exp_golomb(payload[:16])
int_val = int(code, 2)
print("Payload bin start:", int_val, code)
# int_val = int(code, 2)
print("Payload bin start:", code)
print("Payload hex start:", first_hex_res)
# if len(payload) - 4 > int_val:
# first_hex_res = " ".join(format(x, '02x') for x in payload[4 + int_val:20 + int_val])
Expand Down

0 comments on commit 926afe3

Please sign in to comment.