[FFmpeg-devel] [PATCH] avformat/avienc: add check bitstream method
Steven Liu
lq at chinaffmpeg.org
Fri Jan 5 10:13:49 EET 2018
rename mpegts_check_bitstream to ff_check_bitstream
fix problem: remux from mp4(AVC Codec) to avi(AVC Codec)
error message:
[avi @ 0x7fac97003c00] H.264 bitstream malformed, no startcode found,
use the video bitstream filter 'h264_mp4toannexb' to fix
it ('-bsf:v h264_mp4toannexb' option with ffmpeg)
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
libavformat/avienc.c | 1 +
libavformat/mpegts.h | 5 +++++
libavformat/mpegtsenc.c | 4 ++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ac0f04c354..a8782ef292 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -1002,6 +1002,7 @@ AVOutputFormat ff_avi_muxer = {
.write_header = avi_write_header,
.write_packet = avi_write_packet,
.write_trailer = avi_write_trailer,
+ .check_bitstream = ff_check_bitstream,
.codec_tag = (const AVCodecTag * const []) {
ff_codec_bmp_tags, ff_codec_wav_tags, 0
},
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 272e2be4f7..96610ee0a6 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -114,4 +114,9 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
*/
int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt);
+/**
+ * Check bitstream of stream
+ * @return <0 to stop processing
+ */
+int ff_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt);
#endif /* AVFORMAT_MPEGTS_H */
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fdfa544ee2..866615f620 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1846,7 +1846,7 @@ static void mpegts_deinit(AVFormatContext *s)
av_freep(&ts->services);
}
-static int mpegts_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+int ff_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
{
int ret = 1;
AVStream *st = s->streams[pkt->stream_index];
@@ -1982,7 +1982,7 @@ AVOutputFormat ff_mpegts_muxer = {
.write_packet = mpegts_write_packet,
.write_trailer = mpegts_write_end,
.deinit = mpegts_deinit,
- .check_bitstream = mpegts_check_bitstream,
+ .check_bitstream = ff_check_bitstream,
.flags = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS,
.priv_class = &mpegts_muxer_class,
};
--
2.14.3 (Apple Git-98)
More information about the ffmpeg-devel
mailing list