请选择 进入手机版 | 继续访问电脑版

ChinaFFmpeg

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 19333|回复: 10

[Linux] ffmpeg封装h264裸流为mp4文件

[复制链接]
发表于 2016-11-3 15:19:27 | 显示全部楼层 |阅读模式
错误

    Stream #0:1: Unknown: none
[mpegts @ 0x23a77a0] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mpegts @ 0x23a77a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mpegts @ 0x23a77a0] Using AVStream.codec.time_baMMB LEAK(pid=1095): 0x8FB84000, 413696 bytes, ''
se as a timebase hint to the muxer is deprecatedmmz_userdev_release: mmb<0x8FB84000> mapped to userspace 0xb13a8000 will be force unmaped!
MB LEAK(pid=1095): 0x8FBE9000, 32768 bytes, ''
[1;35m[mpegts @ 0x23a77a0] Usmmz_userdev_release: mmb<0x8FBE9000> mapped to userspace 0xb13a0000 will be force unmaped!
ing AVStream.codec to pass codec parametMMB LEAK(pid=1095): 0x8FBF1000, 413696 bytes, ''
ers to muxers is deprecated, use AVStreammz_userdev_release: mmb<0x8FBF1000> mapped to userspace 0xb0b3b000 will be force unmaped!
m.codecpar instead.
[mpegts MMB LEAK(pid=1095): 0x8FC56000, 32768 bytes, ''
@ 0x23a77a0] muxrate VBR, mz_userdev_release: mmb<0x8FC56000> mapped to userspace 0xb0b33000 will be force unmaped!
mpcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mp4, to 'output002.mp4':
    Stream #0:0: Unknown: none
    Stream #0:1: Unknown: none
[mp4 @ 0x23f7950] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mp4 @ 0x23f7950] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x23f7950] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mp4 @ 0x23f7950] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[mp4 @ 0x23f7950] muxer does not support non seekable output
route add default gw 192.168.0.1 dev eth0

回复

使用道具 举报

 楼主| 发表于 2016-11-3 15:23:33 | 显示全部楼层
用的最新的ffmpeg封装的
回复 支持 反对

使用道具 举报

发表于 2016-11-4 14:20:51 | 显示全部楼层
可以参考一下ffmpeg的doc/examples/muxing.c
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-11-4 15:03:40 | 显示全部楼层
嗯,但是我现在这边是直接给数据就发生[mp4 @ 0x23f7950] muxer does not support non seekable output这个错误
回复 支持 反对

使用道具 举报

发表于 2016-11-4 15:21:20 | 显示全部楼层
代码是否方便贴出来看一下
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-11-4 16:48:03 | 显示全部楼层
int add_video_stream(AVCodecID codec_id)
        {
                m_VideoStream = avformat_new_stream(m_FormatContext, 0);
                if(0 == m_VideoStream)return -1;

                AVCodecContext * c = m_VideoStream->codec;
                c->codec_type = AVMEDIA_TYPE_VIDEO;
                c->bit_rate = m_mp.video_bitrate;
                c->codec_id = codec_id;
#if D_SUPPORT_FFMPEG_2_2_16
                c->time_base.num = 1;
                c->time_base.den = m_mp.video_fps;

#else
/////for new ffmpeg version 2.8.6
                m_VideoStream->time_base.num=1;
                m_VideoStream->time_base.den=m_mp.video_fps;
                c->ticks_per_frame = 1;
#endif               

               
                c->width = m_mp.video_width;
                c->height = m_mp.video_height;
                c->has_b_frames = 0;
                c->pix_fmt = AV_PIX_FMT_YUV420P;
               
                //printf("get : %d\n",m_VideoStream->codec->codec_id);
               
                if(m_mp.spspps.size() != 0)
                {
                        c->extradata_size = m_mp.spspps.size();
                        c->extradata = (uint8_t *)av_malloc(c->extradata_size);
                        memcpy(c->extradata, &m_mp.spspps[0], c->extradata_size);
                }

                if(m_mp.muxer_type == MUXER_FLV || m_mp.muxer_type == MUXER_RTMP || m_mp.muxer_type == MUXER_MP4)c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                return 0;
        }
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-11-4 16:48:30 | 显示全部楼层
这是write的代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-11-4 16:48:55 | 显示全部楼层
int write_video(unsigned char* pBuffer, size_t iBufSize, int frametype, unsigned long long ts)
        {
                //cout << "iBufSize :" << iBufSize << "frametype:" << frametype << "pBuffer" << pBuffer[0]<< endl;
                if(0 == m_FormatContext)return -1;

                AVRational av_time_base_q;
                av_time_base_q.num = 1;
                av_time_base_q.den = 1000000;

                int64_t pts = av_rescale_q(ts, av_time_base_q, m_VideoStream->time_base);
                if(m_video_pts >= pts){
                        printf("!!!!!!v!!!!!!!imposible, pts(%lld) > pts(%lld)\n", m_video_pts, pts);
                        return 0;
                }
                if(m_audio_pts > pts){
//                        printf("!!!!!maybe!!!!!imposible, apts(%lld) > pts(%lld)\n", m_audio_pts, pts);
                }
                m_video_pts = pts;

                AVPacket pkt;
                av_init_packet(&pkt);
                pkt.pts = pts;
                pkt.dts = pts;
                if(frametype){
                        pkt.flags |= AV_PKT_FLAG_KEY;
                }
                pkt.stream_index = m_VideoStream->index;
                pkt.data = (uint8_t *)pBuffer;
                pkt.size = iBufSize;

               
                //printf("get[%d] : %d\n",pkt.stream_index,m_FormatContext->streams[pkt.stream_index]->codec->codec_id);

                return av_interleaved_write_frame(m_FormatContext, &pkt);
               
        }
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-11-4 16:49:14 | 显示全部楼层
av_interleaved_write_frame这里面报的错误
回复 支持 反对

使用道具 举报

发表于 2017-1-10 19:02:25 | 显示全部楼层
你好,你的在linux 怎嘛变异的,我的总是编译不通过。支持h264 在·arm 交叉编译
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|Archiver|ChinaFFmpeg

GMT+8, 2024-4-19 04:48 , Processed in 0.047254 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表