Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP4 conversion speed improvement opportunity #329

Open
obilodeau opened this issue Jul 30, 2021 · 3 comments
Open

MP4 conversion speed improvement opportunity #329

obilodeau opened this issue Jul 30, 2021 · 3 comments
Labels
investigate Needs more thought / experience

Comments

@obilodeau
Copy link
Member

While working on #311 I realized that if the file I/O was going nowhere (output file set to an invalid path that didn't exist for example), then conversion would happen dramatically faster but still be long enough to be credible that it would happen (2x capture duration for example). Maybe there's something wrong in our use of file i/o that I would like to investigate later.

To reproduce, use the PDU-based pcap I used to test the pcap-fix branch and convert it to mp4.

@obilodeau
Copy link
Member Author

I canceled the job on master (before #311) because I wanted to work on something else.

$ time pyrdp-convert.py -f mp4 wrong-output-names.pcap
 19% (413 of 2149) |#############################                                                                                                                             | Elapsed Time: 1:12:52 ETA:   1:08:17^
[... traceback removed ...]
real	73m22.705s
user	74m33.152s
sys	5m2.900s

Pretty crazy for a 160 seconds pcap...

@obilodeau
Copy link
Member Author

obilodeau commented Aug 27, 2021

Did some profiling with snakeviz today. It was clear where the bulk of our time was spent:

2021-08-27_12-50

Reading about ImageQt.fromqimage() I found out that it would compress to png the whole frame. That operation is completely unnecessary here since PyAV will perform compression to video as well. I found a way to pass an array of bytes instead using numpy. Here are the benchmarks.

with from_image via QTImage:

$ time pyrdp-convert.py pyrdp_output/replays/rdp_replay_20210826_12-15-33_512_Stephen215343.pyrdp -f mp4
[*] Converting 'pyrdp_output/replays/rdp_replay_20210826_12-15-33_512_Stephen215343.pyrdp' to MP4
100% (1465 of 1465) |##################################################################################| Elapsed Time: 0:07:08 Time:  0:07:08

[+] Succesfully wrote 'rdp_replay_20210826_12-15-33_512_Stephen215343.mp4'

real	7m23.110s
user	7m33.381s
sys	0m8.217s

with from_ndarray and qimage2ndarray:

$ time pyrdp-convert.py pyrdp_output/replays/rdp_replay_20210826_12-15-33_512_Stephen215343.pyrdp -f mp4
[*] Converting 'pyrdp_output/replays/rdp_replay_20210826_12-15-33_512_Stephen215343.pyrdp' to MP4
100% (1465 of 1465) |##################################################################################| Elapsed Time: 0:00:55 Time:  0:00:55

[+] Succesfully wrote 'rdp_replay_20210826_12-15-33_512_Stephen215343.mp4'

real	0m59.565s
user	1m20.037s
sys	0m1.196s

@obilodeau
Copy link
Member Author

The previous comment had nothing to do with the investigation needed for this issue. I opened a PR with the same content #349 and I will leave this issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Needs more thought / experience
Projects
None yet
Development

No branches or pull requests

1 participant