I'm capturing 720P video 20 FPS in a MPEG-4-ES stream, so I have 50ms to capture and process a frame. I think my problem has to do with the time stamps. I can write the raw ES streams to disk and then I can play it back without any problems. But when I read the raw frames and try to mux it, then get the data back our and write it I get corrupted frames. <br>
<br>Here is the code I am using to push buffers into the pipeline:<br> GstBuffer * vidbuf = gst_buffer_try_new_and_alloc(vidLength);<br> if (vidbuf == NULL)<br> {<br> Log::logError("[VideoMuxer::mux] Failed to allocate a video buffer");<br>
}<br> GST_BUFFER_DURATION(vidbuf) = GST_CLOCK_TIME_NONE;<br> GST_BUFFER_TIMESTAMP(vidbuf) = GST_CLOCK_TIME_NONE;<br> GST_BUFFER_OFFSET(vidbuf) = GST_BUFFER_OFFSET_NONE;<br> GST_BUFFER_OFFSET_END(vidbuf) = GST_BUFFER_OFFSET_NONE;<br>
// GST_BUFFER_DURATION(vidbuf) = nsDuration;<br>// GST_BUFFER_TIMESTAMP(vidbuf) = nsTime;<br> gst_buffer_set_data(vidbuf, vid, vidLength);<br> error = gst_app_src_push_buffer(GST_APP_SRC(_videoSrc), vidbuf);<br>
if (error != GST_FLOW_OK)<br> {<br> Log::logError("[VideoMuxer::mux] Failed to push data into _videoSrc");<br> }<br><br>I've commented out the code that had the duration and current time. It would generate garbage data if I kept the time stamps. The way the code is written above it will not produce any data into a file. I can get this to work on the PC by reading the MPEG4-ES data and parsing frames from this file and then pushing it into the same pipeline. But when I do this on the embedded system it doesn't work. <br>
<br>Another odd thing is the MPEG-4 hardware compressor produces weird frame times. Here is what ffprobe says about my MPEG4-ES streams. Note that this example uses 24 FPS instead of the 20 FPS of the production system:<br>
Input #0, m4v, from '2010_12_17_Good.m4v':<br> Duration: N/A, bitrate: N/A<br> Stream #0.0: Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 24k tbr, 1200k tbn, 24k tbc<br>[STREAM]<br>codec_name=mpeg4<br>codec_long_name=MPEG-4 part 2<br>
decoder_time_base=1/24000<br>codec_type=video<br>r_frame_rate=24000.000000<br>r_frame_rate_num=24000<br>r_frame_rate_den=1<br>width=1280<br>height=720<br>gop_size=12<br>has_b_frames=1<br>sample_aspect_ratio=1/1<br>display_aspect_ratio=16/9<br>
pix_fmt=yuv420p<br>index=0<br>time_base=1/1200000<br>start_time=N/A<br>duration=N/A<br>nb_frames=0<br>[/STREAM]<br><br>Now when I mux this into a MOV file (based on an earlier post about the inadequacies of AVI files). I get the following from ffprobe:<br>
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mov':<br> Duration: 00:00:03.69, start: 0.000000, bitrate: 3517 kb/s<br> Stream #0.0(eng): Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 23.83 tbr, 2400 tbn, 24k tbc<br>
Stream #0.1(eng): Audio: pcm_s16le, 32000 Hz, stereo, s16, 1024 kb/s<br>[STREAM]<br>codec_name=mpeg4<br>codec_long_name=MPEG-4 part 2<br>decoder_time_base=1/24000<br>codec_type=video<br>language=p�F ��F <br>r_frame_rate=23.833333<br>
r_frame_rate_num=143<br>r_frame_rate_den=6<br>width=1280<br>height=720<br>gop_size=12<br>has_b_frames=1<br>sample_aspect_ratio=1/1<br>display_aspect_ratio=16/9<br>pix_fmt=yuv420p<br>index=0<br>time_base=1/2400<br>language=eng<br>
start_time=0.000000 <br>duration=3.654167 <br>nb_frames=0<br>[/STREAM]<br>[STREAM]<br>codec_name=pcm_s16le<br>codec_long_name=PCM signed 16-bit little-endian<br>decoder_time_base=0/1<br>codec_type=audio<br>language=��F p�F <br>
sample_rate=32000.000000 <br>channels=2<br>bits_per_sample=16<br>index=1<br>time_base=1/32000<br>language=eng<br>start_time=0.000000 <br>duration=3.696000 <br>nb_frames=0<br>[/STREAM]<br><br><br>I suspect I am doing something wrong with the time stamps of the data. Can anyone help with an example of how to correctly mux an already compressed video and audio streams together?<br>
<br>Thanks in advance!!!<br><br><br><br><div class="gmail_quote">On Thu, Aug 25, 2011 at 6:39 PM, Stefan Kost <span dir="ltr"><<a href="mailto:ensonic@hora-obscura.de">ensonic@hora-obscura.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 08/25/11 23:28, Nicholas Butts wrote:<br>
> I'm trying to mux an MPEG4-ES stream with an uncompressed audio stream<br>
> into an avimux filter and then to an appsink. I have this working on<br>
> Ubuntu 10.04. Now I am moving to an ARM based embedded system and this<br>
> is REALLY slow. It takes on-average 12.7 ms to performing the muxing.<br>
> This seems extremely slow to me. Has anyone else attempted this? Is<br>
> there a way to disable all of the threading and make a single threaded<br>
> application?<br>
><br>
</div>Even if you could disable the threading, I doubt that this would be the<br>
source of the slowness. Check that you don't copy data where it can be<br>
avoided. Also using appsrc and appsink would make me think that your<br>
design isn't that good.<br>
<font color="#888888"><br>
Stefan<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div><br><br>