Skip to content

Commit 926afe3

Browse files
committed
fixed packet size
1 parent 12fa4f0 commit 926afe3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn process_bsf(
256256
}
257257

258258
loop {
259-
let mut new_packet = Packet::empty();
259+
let mut new_packet = Packet::new(packet.size() + 2048);
260260
let ret = av_bsf_receive_packet(filter.ptr, packet.as_mut_ptr());
261261
if ret < 0 {
262262
break;
@@ -265,6 +265,11 @@ fn process_bsf(
265265
break;
266266
}
267267
new_packet.set_stream(packet.stream());
268+
new_packet.set_flags(packet.flags());
269+
new_packet.set_dts(packet.dts());
270+
new_packet.set_pts(packet.pts());
271+
new_packet.set_duration(packet.duration());
272+
// new_packet.set_position(packet.position());
268273
new_packets.push(new_packet.clone());
269274
}
270275
}
@@ -437,6 +442,7 @@ fn handle(params: HandleParams) -> anyhow::Result<()> {
437442
}
438443

439444
if skip_until_first_key_frame {
445+
debug!("Skipping until the first key frame");
440446
continue;
441447
}
442448

test.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def bytes_to_bits_binary(byte_data):
1616
# set env LOGLEVEL=info
1717
# file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_ab.mp4"
1818
# file = "/home/ivan/Downloads/1_underground_supercut.mp4"
19-
file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug.mp4"
19+
file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_x265.mp4"
2020
# file = "/home/ivan/Downloads/1_underground_supercut_reencode_bug_aud.mp4"
2121
s = FFMpegSource(file, params=[],
2222
queue_len=10, decode=False,
2323
block_if_queue_full=True,
24-
ffmpeg_log_level=FFmpegLogLevel.Trace)
25-
s.log_level = FFmpegLogLevel.Trace
24+
ffmpeg_log_level=FFmpegLogLevel.Info)
25+
s.log_level = FFmpegLogLevel.Info
2626
# counter = 0
2727
while True:
2828
try:
@@ -40,8 +40,8 @@ def bytes_to_bits_binary(byte_data):
4040
first_hex_res = " ".join(format(x, '02x') for x in payload[:16])
4141
last_hex_res = " ".join(format(x, '02x') for x in payload[-4:])
4242
code = decode_exp_golomb(payload[:16])
43-
int_val = int(code, 2)
44-
print("Payload bin start:", int_val, code)
43+
# int_val = int(code, 2)
44+
print("Payload bin start:", code)
4545
print("Payload hex start:", first_hex_res)
4646
# if len(payload) - 4 > int_val:
4747
# first_hex_res = " ".join(format(x, '02x') for x in payload[4 + int_val:20 + int_val])

0 commit comments

Comments
 (0)