# Tag Info

13

takeScreenshot() Based on the .NET Naming Guidelines methods should be named using PascalCase casing takeScreenshot() => TakeScreenshot() You are enclosing the usage of the Bitmap inside a using statement which is the way to go but calling Dispose() on that Bitmap is superfluous because that is what a using statement is doing. If you have two using ...

8

You could write the screenshots directly to the video stream. This could save you a lot of disk space depending on your capture time. To make the video file smaller you need to use a codec that compresses the output like MPEG-4. Finally you could encapsulate the recording in its own class: public sealed class ScreenRecorder : IDisposable { private ...

7

According to your comment, if it's only the MultipartFileWrapper.class.getField("multipartFile") statement that might throw a NoSuchFieldException, then when that happens, the lines that set imageFormats and videoFormats will not be reached, so these values will remain null, and the if conditions in the catch block are pointless. Furthermore, it's good to ...

6

Disclaimer: I haven't actually got to trying to run your code yet, this was all done by inspection. However, I think there's enough here to be getting on with... Style Style is important; it makes your code easier to read and understand. Python has a style guide, and (unless you're following a different one*) you should follow it, for example: your imports ...

6

Partial result ffmpeg -v warning -i video1.mkv -i video2.mkv -filter_complex '[0:v]scale=400:400,pad=800:400 [0:q]; [1:v]scale=400:400[1:q]; [0:q][1:q]overlay=400:0' -f nut -c:v rawvideo -c:a copy - | mplayer -noconsolecontrols -cache-min 1 -cache 1024000 - Dummy video input removed Filenames now separate command line aguments, not parts of a longer string ...

6

What you call "underscore functions" are actually the result of a few principles including separation of concerns, single responsibility and sure, there is some encapsulation involved as well but that's not really prevalent. So in that regard: it's definitely a good thing that you are splitting this in multiple methods because it really makes it easier to ...

6

Its pretty good: Don't do this: using namespace cv; using namespace std; Its a bad habit that one day will get you into a lot of trouble. The reason the namespace names are so short is so that adding std:: or cv:: before identifiers is not overburdensome. Read more about the issues: Why is “using namespace std” considered bad practice? I suppose this is ...

5

The worst part is actually public static final String[] ACCEPTED_IMAGE_FORMATS; public static final String[] ACCEPTED_VIDEO_FORMATS; publishing both arrays for everyone to modify them at will. Ideally, use Guava's ImmutableList. Otherwise, use Collections.unmodifiableList(new ArrayList(....)). If you don't mind letting the initialization do some trivial ...

5

The fastest way I've found is simple and very compact code-wise, especially if you're able to compress using canonical or semi-canonical Huffman codes. Start by reading about how to decode all the codeword bits simultaneously using Dan Hirschberg and Debra Lelewer's "Efficient Decoding of Prefix Codes" in Communications of the ACM, April 1990, Volume 33 ...

5

After back and forth with ChrisW and yourself, it seems I found a glaring bug var frameFix = function() { hContext.drawImage(sourceVid, 0, 0, sourceVid.videoWidth, sourceVid.videoHeight); var frame = hContext.getImageData(0, 0, sourceVid.videoWidth, sourceVid.videoHeight); var length = frame.data.length; for (var i = 0;...

5

Architectural Ideas Let's start at the Architecture of your Application and the data transfer. There's basically two places where we can optimize the performance of your application. I'm ignoring latency for now, since that is mostly determined by the network and the performance of the image processing. This means if we can improve the speed of image ...

4

Most of your code is API calls. I'm surprised that Javascript is fast enough to run at all (it isn't, on my old laptop, using Chrome browser). I'll assume that using completely different APIs, and for example writing a plug-in in a different, compiled language (if that's even possible) is out-of-scope for this question. Therefore I guess that the only ...

4

Well I got this code working, so kudos for writing code that works. I don't have a lot of experience with Media Foundation or EmguCV, but I did want to share a few observations on your implementation. It appears to be a feature of this implementation that Start and Stop can be called more than once, possible to produce several output files over the ...

4

import os, codecs, datetime, glob E401 multiple imports on one line Recommend you run $flake8 and heed its advice, as PEP-8 asks for just one import per line. Use isort to organize them. Each of your functions has lovely comments; thank you. Recommend you turn the one-sentence comments into docstrings. The add_subtitles() function is maybe slightly long,... 4 Using string concatenation for creating file paths opens you up to a whole lot of headache. Should you use /, //, \ or \\? The answer depends on the environment you are running in. Luckily, the Path class can do all this logic for us: Instead of path + "//screenshot-" + fileCount + ".jpeg"; you could do Path.Combine(path,$"screenshot-{fileCount}.jpeg"); ...

3

I would use a single bind: $("#videoplayer").bind("timeupdate", function() { var currentTime = this.currentTime; if (currentTime > 0.75 * (this.duration)) { a = a + 1; console.log("watched 75%"); ga('send', 'event', 'Videos', 'Watched 25%', 'Video 1'); } else if (currentTime > 0.50 * (this.duration)) { b = b ... 3 Your fundamental strategic error is trying to accomplish this task mostly in Bash. It's not impossible, but, as you have noticed, it's not a good tool for the job. Adversities include: Parsing input from xrandr --verbose. You have ended up running xrandr --verbose many times, extracting one bit of information each time, which is obviously suboptimal. As ... 3 Readability To ease the readability (and testability) of your code, I would recommend you to split it in multiple functions communicating via multiple channels. For instance, for the client: func getOutput(command string) (io.ReadCloser, error) // to launch the v4l2 func readFrames(in io.ReadCloser, out <-chan Frame) func splitFrames(in chan<-... 3 The most inefficient thing in your code is usage of byte[] to hold video or image data. There is a concept of Large Object Heap in .NET which is not compacted unless explicitly otherwise made-to starting .Net 4.5.1. Red Gate's Explanation of Large Object Heap Latest behavior of Large Object Heap All your objects with a size of more that 85000 bytes are ... 3 1) Are you sure that it is safe to write to cameraImagePtr from background thread the way you do it? Because documentation clearly states that it is not: Update the back buffer only between calls to the Lock and Unlock methods. If you do not follow the Lock/Unlock workflow described in the WriteableBitmap class remarks, undefined behaviors, such as ... 3 That is a natural restriction on video encoding. On modern machines 1 minute of 720p video is encoded approximately in 1 minute. You can save a lot of time if you do not need re-encoding (i.e. changing codec or video size) by using -codec copy ffmpeg option. Also you said you have 64 cores, but your code use only 1 thread for encoding. Use -threads 0 to ... 3 First let's go over some code-style issues :) 1. Usings You have a lot of using that you don't need. Only include the namespaces you need. If you feel fancy you can even sort them alphabetically or by "system/lib/custom" or length using System.IO; using System.Drawing; using System.Diagnostics; using System.Drawing.Imaging; using System.Collections.... 3 Bloated You have 104 lines of code, that can easily by made more readable with some simple redunctions. Remove comments, same line open blocks {, and remove empty lines. That reduces the code to 54 lines. Review I can see you are somewhat new to JS Some JS items Use const for variables that do not change. In JS we put the open block delimiter { on the ... 3 Code Structuring All Android tutorial code packs event listeners into anonymous inner classes, because the examples are usually short and it is convenient, from distribution point of view, to pack all code into the same file. It is however not the correct way to implement production code, as it creates large and messy compilation units that contain many many ... 2 Two random thoughts: In the Category Dropdown part the$(this).html() could be extracted out to a named local variable. The following code is duplicated, it could be extracted out a separate function: $('.transport_popup').hide();$('.rec_select').hide(); $('.mic_select').hide();$('.cam_select').hide();

2

It seems your code needs Windows to run, so I cannot execute it myself. jonrsharpe has done a pretty thorough analysis. Some complements: Creating strings In here: def setImageRegex(self,imageCountVar): """ @setImageRegex: padding image count. """ if (len(imageCountVar) == 5): irx = "%05d" elif (len(imageCountVar) == 4): ...

2

Interesting code, you are skirting the rules of 'code you wrote', but I still think review of this code is valuable. In essence this code is fine, there are some style changes you might want to consider. I am guessing part of your goal is to have a "one page has it all" HTML page, but you should really have that JavaScript in separate script file You ...

2

You can use a private static Method to initialize the fields. public class ContentUtils { public static final String[] ACCEPTED_IMAGE_FORMATS = getAcceptedImageFormats(); public static final String[] ACCEPTED_VIDEO_FORMATS = getAcceptedVideoFormats(); private static String[] getAcceptedImageFormats() { try { Field ...

2

VideoBuffer.h / VideoBuffer.cpp I believe the only symbol you need from the libav includes is for AVFrame, which appears to be pulled in with #include "libavcodec/avcodec.h" (which includes "libavutil/frame.h"). I haven't tested it, but you should be able to remove the other two includes. The VideoBuffer::initialize method seems like it could be eliminated ...

Only top voted, non community-wiki answers of a minimum length are eligible