In order to use a mp4 file with app_rtsp and a streaming server from a videophone it has to be encoded in the supported phone formats.
Most streaming servers supports mp4/3gp file formats, so h263-1998 is a good choice for video enconding and there are severall tools for editing it.
The problem is that audio codecs used in videotelephony (gsm/speech/g723/g729) are not usually used in streaming (AAC/MP3).
The mp4 file format allows storing in it any kind of streamable data, but not many tools support creating a media file like that.
The tool pcm2mp4 allows to create an mp4 with a PCMU audio track so it can be used for testing rtsp streaming integration (other codecs could be also easilly integrated).
We would use a sample file converted to h263 for this mini tutorial
gondolin:~/video# mp4info sample_300kbit.3gp
mp4info version 1.5.0.1
sample_300kbit.3gp:
Track Type Info
201 video H.263, 69.973 secs, 94 kbps, 176x144 @ 10.003859 fps
65335 hint Payload H263-2000 for track 201
101 audio MPEG-4 AAC LC, 70.000 secs, 8 kbps, 12000 Hz
65435 hint Payload MP4A-LATM for track 101
1 od Object Descriptors
2 scene BIFS
First we will extract both media tracks
gondolin:~/video# mp4creator -extract=201 sample_300kbit.3gp
gondolin:~/video# mv sample_300kbit.3gp.t201 sample_300kbit.263
gondolin:~/video# mp4creator -extract=101 sample_300kbit.3gp
gondolin:~/video# mv sample_300kbit.3gp.t101 sample_300kbit.aac
We will convert the AAC audio file into PCMU
gondolin:~/video# ffmpeg -i sample_300kbit.aac -acodec pcm_mulaw -ar 8000 -ac 1 -f mulaw sample_300kbit.mulaw
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration: --prefix=/usr --libdir=${prefix}/lib --shlibdir=${prefix}/lib --incdir=${prefix}/include/ffmpeg --enable-shared --enable-mp3lame --enable-gpl --enable-faad --mandir=${prefix}/share/man --enable-vorbis --enable-pthreads --enable-faac --enable-xvid --enable-dts --enable-amr_nb --enable-amr_wb --enable-pp --enable-libogg --enable-libgsm --enable-x264 --enable-a52 --extra-cflags=-Wall -g -fPIC -DPIC --cc=ccache cc
libavutil version: 49.1.0
libavcodec version: 51.28.0
libavformat version: 51.7.0
built on Jan 19 2007 17:05:58, gcc: 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Input #0, aac, from 'sample_300kbit.aac':
Duration: 00:01:09.4, start: 0.000000, bitrate: 8 kb/s
Stream #0.0: Audio: aac, 12000 Hz, mono, 8 kb/s
Output #0, mulaw, to 'sample_300kbit.mulaw':
Stream #0.0: Audio: pcm_mulaw, 8000 Hz, mono, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
size= 2184kB time=70.0 bitrate= 64.0kbits/s
video:0kB audio:2184kB global headers:0kB muxing overhead 0.000000%
And use the tool to create a new mp4 file from the PCMU file
gondolin:~/video# /usr/tools/pcm2mp4 sample_300kbit.mulaw sample_300kbit_ulaw.3gp
gondolin:~/video# mp4info sample_300kbit_ulaw.3gp
mp4info version 1.5.0.1
sample_300kbit_ulaw.3gp:
Track Type Info
1 audio G.711 uLaw, 70.000 secs, 64 kbps, 8000 Hz
2 hint Payload PCMU for track 1
Then just add the h263 track and hint it
gondolin:~/video# mp4creator -create=sample_300kbit.263 sample_300kbit_ulaw.3gp
gondolin:~/video# mp4info sample_300kbit_ulaw.3gp
mp4info version 1.5.0.1
sample_300kbit_ulaw.3gp:
Track Type Info
1 audio G.711 uLaw, 70.000 secs, 64 kbps, 8000 Hz
2 hint Payload PCMU for track 1
3 video H.263, 69.903 secs, 94 kbps, 176x144 @ 10.013876 fps
gondolin:~/video# mp4creator -hint=3 sample_300kbit_ulaw.3gp
gondolin:~/video# mp4info sample_300kbit_ulaw.3gp
mp4info version 1.5.0.1
sample_300kbit_ulaw.3gp:
Track Type Info
1 audio G.711 uLaw, 70.000 secs, 64 kbps, 8000 Hz
2 hint Payload PCMU for track 1
3 video H.263, 70 secs, 94 kbps, 176x144 @ 10.013876 fps
4 hint Payload H263-2000 for track 3
Metadata Tool: mp4creator 1.5.0.1
The resulting file can be found here. Please take note that it won't be playable from a video player as it won't recognize the PCMU as a valid audio codec for that format.
|