Skip to content

Commit d0cd6e4

Browse files
author
bwsw
committed
implemented correct codec and pixel_format for decoded streams
1 parent 51e5eef commit d0cd6e4

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repository = "https://github.com/insight-platform/FFmpeg-Input"
77
readme = "README.md"
88
keywords = ["FFmpeg", "Video"]
99
categories = ["computer-vision"]
10-
version = "0.1.5"
10+
version = "0.1.6"
1111
edition = "2021"
1212
license="Apache-2.0"
1313
rust-version = "1.62"

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ pip install ffmpeg-input
1515
### Build In Docker (Manylinux_2_28)
1616

1717
```bash
18+
# certain python version (decreases build time)
19+
#
20+
docker build -t ffmpeg_input -f docker/Dockerfile.manylinux_2_28_X64 --build-arg PYTHON_INTERPRETER=/opt/python/cp38-cp38/bin/python .
21+
# all manylinux versions
22+
#
1823
docker build -t ffmpeg_input -f docker/Dockerfile.manylinux_2_28_X64 .
24+
25+
# copy wheels from docker
26+
#
1927
docker run --rm -it -v $(pwd)/distfiles:/tmp ffmpeg_input cp -R /opt/dist /tmp
2028
```
2129

src/lib.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::time::SystemTime;
1818
const DECODING_FORMAT: Pixel = Pixel::BGR24;
1919
const DECODED_PIX_BYTES: u32 = 3;
2020

21-
fn is_stream_key_framed(id: ffmpeg::codec::Id) -> Result<bool, String> {
21+
fn is_stream_key_framed(id: Id) -> Result<bool, String> {
2222
let key_frames = match id {
2323
Id::H264
2424
| Id::H265
@@ -291,8 +291,17 @@ fn handle(
291291
};
292292

293293
for (raw_frame, width, height) in raw_frames {
294-
let codec = String::from(video_decoder.codec().unwrap().name());
295-
let pixel_format = format!("{:?}", video_decoder.format());
294+
let codec = if !decode {
295+
String::from(video_decoder.codec().unwrap().name())
296+
} else {
297+
String::from(Id::RAWVIDEO.name())
298+
};
299+
300+
let pixel_format = if !decode {
301+
format!("{:?}", video_decoder.format())
302+
} else {
303+
format!("{:?}", DECODING_FORMAT)
304+
};
296305

297306
let key_frame = p.is_key();
298307
let pts = p.pts();

test_decode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
res = np.frombuffer(res, dtype=np.uint8)
2020
res = np.reshape(res, (p.frame_height, p.frame_width, 3))
2121
end = time.time()
22-
print(p.queue_len, "all_time={}".format(int(end * 1000 - p.frame_received_ts)),
22+
print(p.codec, p.pixel_format, p.queue_len, "all_time={}".format(int(end * 1000 - p.frame_received_ts)),
2323
"python_time={}".format(int(end * 1000 - p.frame_processed_ts)))
2424
cv2.imshow('Image', res)
2525
if cv2.waitKey(1) & 0xFF == ord('q'):

0 commit comments

Comments
 (0)