The videos you see on YouTube are taken from Emulators playing Pokemon ROMs. Here's one video I found that tells you what software you can use if you wanna do it too: http://www.youtube.com/watch?v=33Qd-klIxlY
Otherwise you'd need to do what Speed freak said and set up a camera to record off the DS. You need to do that for 3DS at the moment since there is no emulator for it yet.
You would have to set up your Camera in a certain position in which it can see the DS system's Screen precisely. That is really the only way, but make sure you have good lighting in order to prevent blurriness. Something to know is that from Gen IV onwards there is a Vs. Recorder that can record a Battle Frontier/Subway or Wi-fi battle and keep it there, but you can only have one at a time. Then you film that battle without having to press button which might interfere with the Camera, it also speeds up reaction time.