RetroArch is able to record your playing session to a video file.
The same mechanism also enables you to live stream your games to platforms like Twitch.tv or Youtube.
To test recording, go to Settings->Recording and enable the functionnality.
You also need to provide a file path with a file extension. In this example, we are recording to test.mkv in the current folder using the Save Output Recording as... entry.
You then need to launch a game, and your session will be recorded.
Options like Use GPU Recording can be used to record with shaders.
The first thing you will need is a twitch account.
Once logged in, open the user menu in the top bar and go to the Dashboard.
In the Settings tab you will find your Stream Key. This key is required to stream to your twitch page and must be kept secret.
In Settings->Recording, enable the feature and set the Save Output Recording as... option to rtmp://live.twitch.tv/app/$YOUR_STREAM_KEY
You will also need to download and load this config file. It will improve the performance of the video encoding.
Once done, you can start playing a game and it should appear on your Twitch channel.