To create an mp3 file of the first 30s of an existent mp3 file, just use the following command.
ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3
In case the original format is not mp3 you can use instead
ffmpeg -t 30 -i inputfile.webm -acodec libmp3lame -aq 4 outputfile.mp3