How to make a custom video player W/ embed options! Rare [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
First question: What would be the best language to create a video player in? / Anyone point me in the direction of a tut that can help me write said script?
Second Question: How can I code such player to echo a embed code for each video: Ala youtube/break/viemo.
^ whats amazing to me, is the fact I searched google for a day and a half and haven't even come close to someone explaining how to build a video player, let alone have a option for it to spit out a embed code or any other sharing options.
Usage info: Once the player is finished it will be imported into wordpress, so I can have total control of each video and manage them accordingly. Not asking for help for importing to WP but any tips would be great.
{Please don't point me to VideoJS or any other video service, as I will make my own and not pay for a license.}

In general, a video player is a picture gallery, where twenty four (or more) pictures are displayed in order every second during the entire duration of the film. Twenty four is the lowest limit for a person to visually confuse static pictures with motion, for better effects I would recommend thirty or more.
The second component of a video player is typically a music player, which displays many "frames" of music per second, which blend through the digital to analog playback system into something resembling continuous sound.
Getting these two subsystems to operate without letting one get ahead of the other is generally required for a "video playback" system. There are many "already done" systems, but it sounds like you envision building your own (to add in unique "features").
Keep in mind that there are very large volumes of data moving around in "video playback". This means that if it is possible, compressing the data is vital for reasonable performance. Compression routines are not as simple as they seem, and the major video codecs are those that do a good job of balancing CPU cycles to decompress, file size, and resulting image quality.
Assuming you really don't want to write a video player, but just want to use someone else's video player "with enhancements", you will be at the mercy of how well built the existing video player is, whether or not it supports any kind of customization, and if it does, how well it supports the customization you have in mind.
Since speed is such a consideration, even though more advanced languages exist, traditionally these things are done in C, assembly, or even hardware acceleration chips.

These are my thought, although you should try to search a little better... Tutorials are very easy to find ...
You could use Flash / ActionScript to create a custom video player. It's still common on the net, although more and more non-flash players are rising (HTML5). I still prefer Flash because of the performance, but keep in mind that iPhone / iPad doesn't support Flash...
If you are going to script your own videoplayer in Flash, this tutorial will set you off to create your own implementation...
For your second question:
Just create a database with a unique ID for every video URL your player will have. When you create the embed code you can include this unique ID as a URL var to the main video player.
From there on you can call your player page with URL vars (example: http://www.yourlink.com?videoid=ID).
When you embed your SWF object you can then pass the videoid along with a FlashVar, or prefetch the matching video URL and send that URL with a FlashVar to your SWF. It's not so complicated, more info can be found here.

try osmf.org. You can either use the strobe media playback with it or build your own player around it. OSMF is pretty robust

Related

using java and fft for sound file manipulation

I am a musician/singer/songwriter,
I was hoping someone might know of information already out that does some if not all of what I'm trying to achieve.
I record song ideas into raw digital wav files using only my voice to emulate instruments ( vocal melody, bass, guitar, drums, etc.) into a song structure (verse, chorus, bridge).
I was hoping that java/fft could be used to slice each mili-second into an array that could be broken down into notes and riffs that I am singing.
Here is a list of some of the steps I see that need to be done with my wav files.
Find out the note that I'm singing. The software would take each note and nudge it into the nearest "true note" (a4=440hz).
It would take the notes and find out which key or possible keys the song may be in.
From a very large database of real songs, the software would make chord suggestions and placement suggestions depending on the genre the song is in.
It would take the riffs ( any sequence of more than 3 notes done more than 3 times in a song) and create loops with a drop down box of alternative voiceings and randomizing.
There is much more, but this should show you the basics of what I’m trying to do.
If there aren’t programs already written that already do all or part of this, would it be possible for me to write a program that uses java and fft to slice every millisecond into an array to determine notes?
I have read some java/fft material and it is way over my head mostly (I have studied a little java) but I was hoping someone might be able to lead me in the right direction.

Calculating the Beat/Minute in a Audio File in Android [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to calculate the beat per minute in a Audio File in android , I have just a small clue , There is a Visualizer Library which creates a DIGITAL BAR effect with the Audio files wave , I can check for the beat with this , Is this the correct solution or is there any proper way to do this ? I want to categorize Audio files in a proper way. According to the Beat/minute in a File.
Any help would be greatfull
Beats per minute can be calculated with multiple levels, a simple energy calculator which you are referring to by the should level meter or VAD (voice/ audio activity detector) can be somewhat simple to make, where as a proper pitch detector, this is a complex process and isolating the beat of music segment can be complex since perception of a beat is complex.
If you are simply interested in energy calculator/ beat like feature what you can do is have a two running averages and see how large is your signal relative to the other.
X= [x1……xn] input audio samples, separate the buffers into smaller segment say 100 samples. n=100,
Take the absolute value for this array abs(X),
Simple one pole smoothing function can be made with
X_filtered_long= X_filtered_long . (1-alpha) + abs(X). alpha // alpha is .02, value depends on the sample rate, signals and what beat of interest
Create the second filtered signals
X_filtered_short= X_filtered_short . (1-beta) + abs(X). beta // beta is .2
If (X_filtered_short > X_filtered_long)
Detected_beat= 1;
InsideBeat=+1;
else
Detected_beat= 0;
InsideBeat=0;
If you want to, "I want to categorize Audio files in a proper way. According to the Beat/minute in a File." This can only be done with finger printing the audio with parameters such as MFCC.
Good reference would be
Automatic genre classification of music content: a survey
Scaringella, N. ; Zoia, G. ; Mlynek, D.
Signal Processing Magazine, IEEE
Volume: 23 , Issue: 2
What you're asking here is tremendously difficult.
Audio analysis to get the beats is usually done with complex mathematical manipulation of the audio data, by transforming the audio signal from the time-domain to the frequency-domain using signal-processing techniques. There are whole books dedicated to this subject.
Visualizers like the one you mention internally use many of these DSP techniques and it would probably be an even worse nightmare to analyze the visualizer data than the audio data.
Even if you manage to find a library that does this for you, the results would be very unreliable. Maybe for electronic music where the beats are more obvious you would get better results than for classical music or jazz.

Audio manipulation with Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
The smallest unit of a digital image is a pixel.
What is the smallest unit of digital sound?
what can be considered to be a pixel for sound?
How can we use java to manipulate it?
The smallest unit of sound is known as a frame. For 8 bit mono it will be a single byte. For stereo 16 bit it will be 4 bytes.
How can we use Java to manipulate it?
That depends on what you want to do with it. You will need to be a lot more specific to get reasonable answers.
Some possible operations are:
Volume change
Pan
Speed or slow the play rate, with or without..
Pitch shift
Spectrum analysis..
.. how many hertz or samples can the speaker produce?
That depends largely on the speaker. Speakers have all different types of dynamic ranges, usually in a kind of 'bell curve' with no absolute upper or lower limits.
Does that mean it takes 44KB to store 1 second of music that is CD Quality?
Each frame of CD quality sound contains 4 bytes, given it is stereo, 16 bit. Multiply 4 bytes by 44100 to calculate the number of bytes per second.
What's the difference between mono and stereo?
Mono has one channel, stereo has two.
What I want to do is manipulate individual units of sound and also - to create a custom musical instrument/synth.
It is not so hard to generate a simple sinusoidal sound in code. See Beeper for an example.
A lot of other effects can be created by playing around with the ADSR (Attack, Decay, Sustain, Release) envelope of a sound. For example, applying the ADSR envelope of a guitar note to a piano tone, will make it sound uncannily like a guitar, and vice versa.
What is channel? Is it like speaker - Left speaker is one channel and right speaker is another?
Pretty much. Mono sounds like rubbish (IMO), while stereo can make the different instruments sound like they are coming from different positions, just like if the band were sitting right in front of you.
5.1 channel sound is a little more complicated, and usually1 it 'cheats' by simply.
Putting the left channel through the left speaker(s).
Putting the right channel through the right speaker(s).
Mixing them both equally and putting that through the center speaker.
Filtering for just the low frequency sound and putting that through the single woofer or bass speaker. The human ear cannot easily tell where low frequency sounds are coming from, so that is acceptable. The woofer can be placed anywhere in the room, and still sound just the same.
To be honest, I do not know of any sound format that actually stores 5 or 6 channels for the sound, I think it is all separated out (for the woofer) or mixed together (for the center speaker) in hardware at run-time. Java Sound will only deal with one or 2 channels directly, in any case.
The smallest unit of digital sound is a sample -- the signal level at a particular point in time. [But see addendum below.]
To use Java to manipulate it: If you have to ask this question, you probably want to go looking for libraries someone else has written.
But if you want to know in general what's involved: Read in the sound file. If it was in a compressed format (such as MP3), unpack it. That will give you a very long array/vector of samples. You can cut-and-paste sections of that to edit the recording, or scale it to make it softer or louder (beware of "clipping", which results when you try to exceed the maximum volume). More complicated manipulations are possible, but that's a full course in digital signal processing which I'm not going to try to do here -- websearch that phrase, especially in conjunction with sound or audio or music should find more information.
You can also generate your own audio by producing the samples programmatically. A signal which varies sinusoidally from sample to sample produces a pure tone. Other repeating shapes add overtones of various kinds. Varying the frequency of the repetition changes the pitch. Adding several signals together (while watching out for clipping) mixes them into a single signal. And so on.
Note that MIDI is not "digital sound" -- it's a digital score. It describes what notes should be played when, but it's up to the synth to turn that into sound.
ADDENDUM: I haven't heard the term "frame" before (see Andrew's answer), but I'll believe it. I think of samples because I'm thinking at the hardware layer, but distinguishing that from sample meaning an audio clip is a Good Thing so I'd bet frame is indeed more correct/current.
In java you´d typically work with AudioInputStream instances (that you get out of classes defined by the Java sound API). Those are read byte-wise for playback.
I have never doen manipulation myself, but as far as I know, this is mostly done through Java sound´s mixer class.
Below tutorial should have all the info you´re looking for:
http://docs.oracle.com/javase/tutorial/sound/playing.html

Android Game Development - Moving the phone

First of all, sorry for the vague title. I have no other ideas of what could possibly be put there, but you'll see this for yourself as you read on.
I am a very new Java developer for android and a martian to game development, therefore my question is not so related to particulars as it is related to theory and possibilities.
I'm interested in how I can develop my game so if holding the phone horizontally and it is tilted one way or another, an object will move in that direction. I'm sure this is very common and easily done but what about if I wanted the top speed to increase the further it was turned, and the acceleration to increase the quicker it was turned?
I honestly have no idea of the complexity of this question, whether you will laugh and give me one line of code or whether it's something you just can't teach.
Either way, thanks for reading, I look forward to your responses.
Check this out http://mobilestrategist.blogspot.com/2010/01/android-accelerometer-and-orientation.html
This gives you what you need to do what you're asking for, but as the other answer suggests, you may be running before you crawl here. I have been writing Android for 2 years and have yet to take advantage of the accelerometer. Though if you're just looking to noodle around with the device's capabilities, this is as good a place to start as any, I suppose.
You could read about sensors & sensor events.
TYPE_ACCELEROMETER is perhaps what you are looking for...

Java 2D game programming - Newbie questions

We're a team of a programmer and a designer and we want to make a medium-sized java game which will be played as an applet in the web browser. Me (the programmer) has 3 years of general development experience, but I haven't done any game programming before.
We're assuming that:
We'll decide on a plot, storyline of the game, etc.
We'll create a list of assets (images) that we need, i.e player images, monster images, towns, buildings, trees, objects, etc. (We're not adding any music/sound efffects for now)
The designer will get started on creating those images while I finish reading some of the game programming books i've bought. The designer will create the first town/level of the game, then pass on those images to me, I will begin coding that first level and he would start on the next level, and after 4-5 levels we'll release v.1 of the game.
Question 1: Is this the correct methodology to use for this project?
Question 2: What format should the designer create those images in. Should they be .bmp, .jpeg, or .gif files? And, would he put all those images in one file, or put each monster/object/building in its own file? Note; We are sticking to 2D for now and not doing 3D.
Question 3: I've seen some game artware where there would be a file for a monster, and in that file there'd be about 3-4 images of a monster from different directions, all put in one file, i think because they're part of an animation. Here's an illustraton:
[Monster looking to right] ... [Monster looking in the front] ... [Monster looking to right[
And all of them are in one file. Is this how he'll have to supply me with those animations?
What i'm trying to find out is, what is the format he'll have to supply me the designed images in, for me to be able to access/manipulate them easily in the Java code.
All answers appreciated :)
I have some comments for each question.
Question 1: You say that you will begin coding level 1, 2, .. one by one. I recommend you to create a reusable framework instead or see it in the big picture instead. For the information you provide I think you are going to make some kind of RPG game. There are lots of things that can be shared between levels such as the Shop, the dialog system, for example. So focus for extensibility.
Why wait for designers to pass on the image? You can begin your coding by starting with pseudo graphics file you created yourself. You can then work with designer in parallel this way. And you can replace your pseudo graphics file with ones provided by designer later.
Question 2: JPG is not suitable for pixel-art style image, that appears a lot in most 2D game. And the GIF support only 256 color. The best choice to me seems to be PNG.
The designer should always keep the original artworks in editable format as well. It's likely that you want to change the graphics in the future.
Question 3: It depends. The format mentioned, where character's animations are kept in single file, is called Sprite. If you kept your resource in this sprite format than you will have some works reading each of the sub-image by specifying coordinates. However, sprite helps you keep things organized. All the 2D graphics related to "Zombie" character is kept in one place. It is therefore easy to maintain.
About the image format: don't let the designer deliver anything as jpg, because you'll lose quality.
Let him send it as png instead, and convert it to your preferred format as needed.
Also, remember to have him send the source files (photoshop/illustrator/3dsmax/whatever) in case you'll ever need tiny changes that you can make yourself without hiring the graphics dude. Who knows if he'll still be available in the future anyway.
I want to suggest to you that, before you make any decisions about your workflows, you and your colleague go have a look at JavaFX and see if maybe that's the toolkit that best meets your needs.
http://java.sun.com/javafx/
The [Monster looking to right] ... [Monster looking in the front] ... [Monster looking to left] style of animation demarcation has been around for as long as I've been peeking into game data, so I would suggest going with that path.
I was about to make the same remark as Wouter: use PNG, modern format which is highly compressed (as opposed to BMP), lossless (as opposed to Jpeg) and full color and with several level of transparency (as opposed to Gif).
Why people put several sprites in the same image? Actually, for Java, I am not sure, if the images are part of a jar... I know it is interesting in CSS, for example, because it reduces the number of images to download, so the number of hits on the server, which is a well known Web optimization. For games on hard disk, reducing the number of small files can be interesting too.
The designer can appreciate this too. At least in times where sprites used a color palette: you had only one image, using the same palette: easier to edit, and slightly reduce the overall size (in times were memory was costly!).
I can't answer on the methodology, I never did a game in team... If it fits your needs, it is probably the right methodology...
duncan points to JavaFX, I will point to pulpcore which seems to be a promising library. Of course, there are plenty others, like JGame and such.
Bunch of pros here: http://www.javagaming.org/
This is not answering any of the questions. But for game develop/Simulation Engines learning if u need a reference:
http://www.cs.chalmers.se/idc/ituniv/kurser/08/simul/
It's a link for the class lectures of Simulation Engines at Chalmers Univ in Gotembourg. The teacher as a game company and gave quite good lectures. Check the slides we had in the classes, maybe they'll help you a bit.

Categories

Resources