Thanks for your sharing about your experience.

 But for my situation, I have configure the flag before open h264 encoder like 
this: oVcc->flags |= CODEC_FLAG_GLOBAL_HEADER.

That is very strange.  It works well when I put the video and audio into mp4 
and mkv container.

Waiting for someone can give out the final explanation.

Best regards,

Li
________________________________________
From: [email protected] [[email protected]] On Behalf 
Of Michael Chisholm [[email protected]]
Sent: Tuesday, March 13, 2012 6:53 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice    
and libavfilter.
Subject: Re: [Libav-user] Please help me about transcoding to   TS      stream: 
H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb 
bitstream filter (-bsf h264_mp4toannexb)

Sounds similar to an issue I used to have.  The solution was changing
the setting of CODEC_FLAG_GLOBAL_HEADER to *before* the h264 encoder
(x264) was opened.  Extradata is set up during the opening.  Hope that
helps.

Andy

On 3/13/2012 10:31 AM, Li Zhang wrote:
> Hi,
>
>
> Now the video can be played by adding the sps and pps information stored in 
> the avctx->extradata to the beginning of video frame. Why the TS container do 
> not do that for me? Is there anyone know what the problem is?
>
>
> Best regards,
>
> Li
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf 
> Of Li Zhang [[email protected]]
> Sent: Tuesday, March 13, 2012 10:27 AM
> To: This list is about using libavcodec, libavformat, libavutil, libavdevice  
>   and libavfilter.
> Subject: Re: [Libav-user] Please help me about transcoding to   TS      
> stream: H.264 bitstream malformed, no startcode found,  use the 
> h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
>
> Hi,
>
> I have check the final .ts file I got, there is no PPS and SPS for IDR frame. 
> I have configure that the CODEC__FLAG_GLOBAL_HEADER. The gop_size is 250. The 
> first video frame is I frame. But there is no PPS and SPS information. 
> However, when I put the video and audio into mp4 container, the video and 
> audio all can be played.  Is there anyone can tell me what happened?
>
> Best regards,
>
> Li Zhang
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf 
> Of Li Zhang [[email protected]]
> Sent: Saturday, March 10, 2012 9:37 AM
> To: This list is about using libavcodec, libavformat, libavutil, libavdevice  
>   and libavfilter.
> Subject: Re: [Libav-user] Please help me about transcoding to TS        
> stream: H.264 bitstream malformed, no startcode found,  use the 
> h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
>
> Hi Kalileo,
>
> Thank you very much for your quick reply.
>
> Sorry for my unclear description last email. What I have done is start from 
> mpeg2 TS stream, and then decoding, encoding them to H.264+AAC without 
> container. Next I have put H.264+AAC data frame into AVI, MKV, MP4 container 
> successfully. However, my final target is putting H.264+AAC data frame into 
> TS container. And it failed. So what I passed to IMHO h264_mp4toannexb is not 
> mpegts stream but H.264+AAC frame.
>
> So I want to make sure you understand my situation correctly.
>
> So according to my understanding, after the H.264 encoding, I should add the 
> h264 Annex B header to every H264 video frame manually. Am I right?
>
> Hope there is some experts can give us confirmation about that. Or there is 
> any other suggestion please tell me, thanks.
>
>
>
> Best regards,
>
> Li Zhang
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf 
> Of Kalileo [[email protected]]
> Sent: Friday, March 09, 2012 5:27 PM
> To: This list is about using libavcodec, libavformat, libavutil,        
> libavdevice and libavfilter.
> Subject: Re: [Libav-user] Please help me about transcoding to TS stream:      
>   H.264 bitstream malformed, no startcode found,  use the h264_mp4toannexb 
> bitstream filter (-bsf h264_mp4toannexb)
>
> On Mar 9, 2012, at 22:20 , Li Zhang wrote:
>
>>
>> Hi everyone,
>>
>>
>> I am a new user to ffmpeg API. I want to transcode mpeg2 video stream to 
>> H.264+AAC and then put them into TS container again.
>>
>> I have implemented transcoding from mpeg2 TS to AVI, MKV, MP4 local files. 
>> Now the problem is when I used the same code put those H.264+AAC data packet 
>> into TS container, the video can not be played and only the audio can be 
>> played. Actually, there was video packet data in the .ts file which was 
>> derived from trandcoding.
>>
>> And I got the information from ffmpeg that "H.264 bitstream malformed, no 
>> startcode found, use the h264_mp4toannexb bitstream filter (-bsf 
>> h264_mp4toannexb)". So I initiated the h264_mp4toannexb bitstreamfilter and 
>> use av_bitstream_filter_filter to process the packet before write them to 
>> output file. However, av_bitstream_filter_filter returns 0 and the final 
>> output file still the same situation and the warning information still 
>> happen.
>>
>> There is another warning information about DTS, it only happen every 29 
>> frames. That is so strange.  Please help me.  I used the latest version of 
>> ffmpeg.
>> When I used the Elecard Stream Analyzer to check my transcoded file, I found 
>> the file missed SPS and SEI information for the video stream. There is only 
>> SPS and SEI information for audio stream.  I do not know why the TS 
>> container can not produce these information for me.
>
> Hi Li,
>
> IMHO h264_mp4toannexb does not work if you convert from mpegts stream to 
> mpegts stream, because as far as I have understood it h264_mp4toannexb 
> expects mp4 as source and not mpegts. you need to do manually what 
> h264_mp4toannexb would do, that is adding the h264 Annex B header in front of 
> every h264 frame.
>
> I'm sure the experts here can confirm or correct me, and explain better what 
> to do.
>
>
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
>

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to