-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
setTimestamp improvement for MPEG TS files #2144
Conversation
@Aismy Please give this a try! |
@anotherche Please revert unnecessary changes in formatting |
I never quite understand why you change so many lines every time you touch this code, but please leave the "old quick seeking code used in JavaCV versions prior to 1.4.1" like it was |
I mean, do a copy/paste of this code and just leave it as is, without touching the formatting either, unless there's a good reason to change it: |
All because users want accuracy in seeking. In fact, I only change the code to accommodate these wishes. Now it was necessary to provide a cyclic call of the By the way, during my checks on a large number of files, the new algorithm always works the same or faster than the old one... but it works accurately (if of course the file itself is fine, but if the file is corrupted, then the old algorithm works wrong too)
I'm not sure I understand what is meant. I thought you meant that I used tabs in the code. But I had already replaced them with spaces. |
Oh, I apologize, I noticed that I actually forgot after a few tries to change |
Again, I apologize. The confusion occurred after I was trying to understand why |
Just in case, this part is now fully compliant with this. The faint differences you see appeared back in 1.4.2. (and then in 1.5.6), so we cannot just simply copy/paste the code from 1.4. |
One last little change. I put the old comment ( |
Let me explain again in detail why the proposed changes are justified. However, not all problems were actually solved. There was still a problem originally related to the incorrect operation of ffmpeg's In addition, there have been complaints about slower code, which is why the legacy code has returned in version 1.4.2. Since then, all versions of The problem with incorrect work of However, even then I realized that this approach would occasionally fail in some rare cases, and that it was necessary to redesign And here, in the last issue, it was shown that for MPEG TS files this happens excessively often. So this change had to be introduced. This change required the old and the new algorithm each use their own logic to call |
I understand what you're trying to do, but refactoring the whole method every time there's a little something to fix doesn't seem like the right way to go. Anyway, if you're comfortable frequently rewriting experimental code like that, that's fine, as long as the old code remains usable just in case, I'm OK with merging this. So, are you done with this pull request? Good to merge? |
Yeah, it's done. Merry Christmas, and may the world go back to normal! |
Awesome! Thanks for the fixes, and Merry Christmas to you too! From what I understand of your research topic, you're working on stuff that could be useful to renewable energy systems? In any case, you're doing your part to "fix" the world, and the rest is out of our control... |
Yes, that's right, some of my research has to do with renewable energy technologies and smart materials. More precisely, they are related to the mechanisms of the processes that are used in such technologies. Programming has always been necessary for me as a tool to implement numerical solutions to research problems. So at one time I needed a java interface to opencv and ffmpeg, which I found in javacv. I am glad that I myself have been useful in some way for the development of these tools and for their application (for example, there are researchers who are happy to be able to import video into ImageJ, a program for scientific analysis of image stacks, which was implemented using javacv). |
So I'm curious, what kind of software are you using for those projects? Do you still use Java a lot? |
mostly Java, C#, C |
That's interesting, I don't have the impression that a lot of science is happening in Java these days. Frameworks like Smile and Spark that have been developed at great length seem pretty much abandoned. Where's the action happening? |
Personally, I don't use framewoks like that, just plain Java. I started using it when I needed to analyze images (time lapse shots or video of transofmations taking place in crystals) and recognize various elements in these images (geometry of transofmations, shape of crystals). The most convenient tool for me turned out to be ImageJ, written in Java and allowing me to use my own plugins. Accordingly, to create the necessary plugins, I needed a Java interface for opencv and ffmpeg, so - javacv. |
By the way, about the image series. In order to uniformly combine the shooting process itself with the subsequent image analysis, I also wrote the code to control the camera in Java, using the Gphoto2 library over jna. In this regard, I had some thoughts about trying to develop an interface for Ghoto2 using javacpp. If I had the time... |
Changes to
setTimestamp
function to resolve issue #2127.Also improved accuracy of
frameNumber
calculation ingrabFrame
function.MPEG TS files have a couple of peculiarities: they often start with rather large timestamp values (perhaps as a result of cutting?), and key frames are very frequent. Because of this, jumps to arbitrary frames often occurred with large errors in the previous code. In the new code,
avformat_seek_file
is called repeatedly until a key frame earlier than the desired frame is reached.