<div dir="ltr"><div>Thanks for your response.</div><div><br></div><div>Following is diff between my modified file (main.c) and original one (muxing.c).</div><div><br></div><div>--- main.c<span class="" style="white-space:pre">  </span>2015-09-25 12:15:20.000000000 +0800</div><div>+++ muxing.c<span class="" style="white-space:pre">    </span>2015-09-16 14:57:53.000000000 +0800</div><div>@@ -34,7 +34,6 @@</div><div> #include <string.h></div><div> #include <math.h></div><div> </div><div>-#include <libavcodec/avcodec.h></div><div> #include <libavutil/avassert.h></div><div> #include <libavutil/channel_layout.h></div><div> #include <libavutil/opt.h></div><div>@@ -50,62 +49,6 @@</div><div> </div><div> #define SCALE_FLAGS SWS_BICUBIC</div><div> </div><div>-// JJ Start</div><div>-</div><div>-#include <fcntl.h></div><div>-#include <sys/stat.h></div><div>-#define CLEAR(x) memset(&(x), 0, sizeof(x))</div><div>-</div><div>-</div><div>-#include "ait_capture.h"</div><div>-</div><div>-</div><div>-int video_handle;</div><div>-StreamFormat gVFmt;</div><div>-</div><div>-int open_video_device(const char* dev_name)</div><div>-{</div><div>-    struct stat st;</div><div>-    int handle;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div>-</div><div>-    CLEAR(st);</div><div>-</div><div>-    if (!dev_name)</div><div>-    {</div><div>-<span class="" style="white-space:pre">  </span>printf("%s(%s) Missing Device Name\n",__FUNCTION__,__FILE__);</div><div>-    }</div><div>-    else</div><div>-    {</div><div>-<span class="" style="white-space:pre">   </span>if (stat(dev_name,&st)==-1)</div><div>-<span class="" style="white-space:pre">   </span>{</div><div>-<span class="" style="white-space:pre"> </span>    printf( "%s(%s) Can't Identify device %s\n",__FUNCTION__,__FILE__, dev_name);</div><div>-<span class="" style="white-space:pre"> </span>}</div><div>-<span class="" style="white-space:pre"> </span>else</div><div>-<span class="" style="white-space:pre">      </span>{</div><div>-<span class="" style="white-space:pre"> </span>    if (!S_ISCHR(st.st_mode))</div><div>-<span class="" style="white-space:pre">   </span>    {</div><div>-<span class="" style="white-space:pre">           </span>printf("%s(%s) %s is not a device\n",__FUNCTION__,__FILE__, dev_name);</div><div>-<span class="" style="white-space:pre">  </span>    }</div><div>-<span class="" style="white-space:pre">   </span>    else</div><div>-<span class="" style="white-space:pre">        </span>    {</div><div>-<span class="" style="white-space:pre">           </span>handle=open(dev_name, O_RDWR|O_NONBLOCK,0);</div><div>-<span class="" style="white-space:pre">               </span>if (handle<0)</div><div>-<span class="" style="white-space:pre">          </span>{</div><div>-<span class="" style="white-space:pre">         </span>    printf( "%s(%s) Cannot open device %s\n",__FUNCTION__,__FILE__,dev_name);</div><div>-<span class="" style="white-space:pre">         </span>}</div><div>-<span class="" style="white-space:pre">         </span>else</div><div>-<span class="" style="white-space:pre">              </span>    return handle;</div><div>-<span class="" style="white-space:pre">      </span>    }</div><div>-<span class="" style="white-space:pre">   </span>}</div><div>-    }</div><div>-    exit(0);</div><div>-    return -1;</div><div>-}</div><div>-</div><div>-// JJ End</div><div>-</div><div>-</div><div> // a wrapper around a single output AVStream</div><div> typedef struct OutputStream {</div><div>     AVStream *st;</div><div>@@ -126,7 +69,6 @@</div><div> static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)</div><div> {</div><div>     AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     printf("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",</div><div>            av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),</div><div>@@ -137,7 +79,6 @@</div><div> </div><div> static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)</div><div> {</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div>     /* rescale output packet timestamp values from codec to stream timebase */</div><div>     av_packet_rescale_ts(pkt, *time_base, st->time_base);</div><div>     pkt->stream_index = st->index;</div><div>@@ -154,20 +95,13 @@</div><div> {</div><div>     AVCodecContext *c;</div><div>     int i;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     /* find the encoder */</div><div>-    printf("Try to find encoder for '%s'\n",</div><div>-    avcodec_get_name(codec_id));</div><div>-</div><div>     *codec = avcodec_find_encoder(codec_id);</div><div>-    if (codec_id!=AV_CODEC_ID_H264)</div><div>-    {</div><div>-<span class="" style="white-space:pre">    </span>if (!(*codec)) {</div><div>-    <span class="" style="white-space:pre">    </span>    fprintf(stderr, "Could not find encoder for '%s'\n",</div><div>-    <span class="" style="white-space:pre">        </span>    avcodec_get_name(codec_id));</div><div>-    <span class="" style="white-space:pre">  </span>    exit(1);</div><div>-<span class="" style="white-space:pre">    </span>}</div><div>+    if (!(*codec)) {</div><div>+        fprintf(stderr, "Could not find encoder for '%s'\n",</div><div>+                avcodec_get_name(codec_id));</div><div>+        exit(1);</div><div>     }</div><div> </div><div>     ost->st = avformat_new_stream(oc, *codec);</div><div>@@ -178,16 +112,7 @@</div><div>     ost->st->id = oc->nb_streams-1;</div><div>     c = ost->st->codec;</div><div> </div><div>-    if (codec_id==AV_CODEC_ID_H264)</div><div>-    {</div><div>-<span class="" style="white-space:pre">     </span>c->codec_type=AVMEDIA_TYPE_VIDEO;</div><div>-<span class="" style="white-space:pre">      </span>c->bit_rate=gVFmt.bitrate;</div><div>-<span class="" style="white-space:pre">     </span>c->extradata_size=0;</div><div>-<span class="" style="white-space:pre">   </span>c->extradata = NULL;</div><div>-    }</div><div>-</div><div>-//    switch ((*codec)->type) {</div><div>-    switch (c->codec_type) {</div><div>+    switch ((*codec)->type) {</div><div>     case AVMEDIA_TYPE_AUDIO:</div><div>         c->sample_fmt  = (*codec)->sample_fmts ?</div><div>             (*codec)->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;</div><div>@@ -218,16 +143,8 @@</div><div> </div><div>         c->bit_rate = 400000;</div><div>         /* Resolution must be a multiple of two. */</div><div>-//        c->width    = 352;</div><div>-//        c->height   = 288;</div><div>-        c->width     = gVFmt.width;</div><div>-        c->height    = gVFmt.height;</div><div>-<span class="" style="white-space:pre">   </span>c->me_range  = 16;</div><div>-<span class="" style="white-space:pre">    </span>c->max_qdiff = 4;</div><div>-<span class="" style="white-space:pre">      </span>c->qmin      = 10;</div><div>-<span class="" style="white-space:pre">  </span>c->qmax      = 36;</div><div>-<span class="" style="white-space:pre">  </span>c->qcompress = 0.6f;</div><div>-</div><div>+        c->width    = 352;</div><div>+        c->height   = 288;</div><div>         /* timebase: This is the fundamental unit of time (in seconds) in terms</div><div>          * of which frame timestamps are represented. For fixed-fps content,</div><div>          * timebase should be 1/framerate and timestamp increments should be</div><div>@@ -235,8 +152,7 @@</div><div>         ost->st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };</div><div>         c->time_base       = ost->st->time_base;</div><div> </div><div>-//        c->gop_size      = 12; /* emit one intra frame every twelve frames at most */</div><div>-        c->gop_size      = gVFmt.gop; /* emit one intra frame every twelve frames at most */</div><div>+        c->gop_size      = 12; /* emit one intra frame every twelve frames at most */</div><div>         c->pix_fmt       = STREAM_PIX_FMT;</div><div>         if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {</div><div>             /* just for testing, we also add B frames */</div><div>@@ -268,7 +184,6 @@</div><div> {</div><div>     AVFrame *frame = av_frame_alloc();</div><div>     int ret;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     if (!frame) {</div><div>         fprintf(stderr, "Error allocating an audio frame\n");</div><div>@@ -283,10 +198,6 @@</div><div>     if (nb_samples) {</div><div>         ret = av_frame_get_buffer(frame, 0);</div><div>         if (ret < 0) {</div><div>-<span class="" style="white-space:pre">   </span>    fprintf(stderr, "frame->format=%d\n",frame->format);</div><div>-<span class="" style="white-space:pre">        </span>    fprintf(stderr, "frame->nb_sample=%d\n",frame->nb_samples);</div><div>-<span class="" style="white-space:pre"> </span>    fprintf(stderr, "frame->channel_layout=%llu\n",frame->channel_layout);</div><div>-<span class="" style="white-space:pre">      </span>    fprintf(stderr, "ret=%d\n",ret);</div><div>             fprintf(stderr, "Error allocating an audio buffer\n");</div><div>             exit(1);</div><div>         }</div><div>@@ -301,7 +212,6 @@</div><div>     int nb_samples;</div><div>     int ret;</div><div>     AVDictionary *opt = NULL;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     c = ost->st->codec;</div><div> </div><div>@@ -359,7 +269,6 @@</div><div>     AVFrame *frame = ost->tmp_frame;</div><div>     int j, i, v;</div><div>     int16_t *q = (int16_t*)frame->data[0];</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     /* check if we want to generate more frames */</div><div>     if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,</div><div>@@ -367,8 +276,7 @@</div><div>         return NULL;</div><div> </div><div>     for (j = 0; j <frame->nb_samples; j++) {</div><div>-        //v = (int)(sin(ost->t) * 10000);</div><div>-<span class="" style="white-space:pre">   </span>v=j<frame->nb_samples/2?10000:0;</div><div>+        v = (int)(sin(ost->t) * 10000);</div><div>         for (i = 0; i < ost->st->codec->channels; i++)</div><div>             *q++ = v;</div><div>         ost->t     += ost->tincr;</div><div>@@ -393,7 +301,6 @@</div><div>     int ret;</div><div>     int got_packet;</div><div>     int dst_nb_samples;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     av_init_packet(&pkt);</div><div>     c = ost->st->codec;</div><div>@@ -454,7 +361,6 @@</div><div> {</div><div>     AVFrame *picture;</div><div>     int ret;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     picture = av_frame_alloc();</div><div>     if (!picture)</div><div>@@ -479,7 +385,6 @@</div><div>     int ret;</div><div>     AVCodecContext *c = ost->st->codec;</div><div>     AVDictionary *opt = NULL;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     av_dict_copy(&opt, opt_arg, 0);</div><div> </div><div>@@ -488,13 +393,14 @@</div><div>     av_dict_free(&opt);</div><div>     if (ret < 0) {</div><div>         fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));</div><div>-        //exit(1);</div><div>+        exit(1);</div><div>     }</div><div> </div><div>+    /* allocate and init a re-usable frame */</div><div>     ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);</div><div>     if (!ost->frame) {</div><div>         fprintf(stderr, "Could not allocate video frame\n");</div><div>-        //exit(1);</div><div>+        exit(1);</div><div>     }</div><div> </div><div>     /* If the output format is not YUV420P, then a temporary YUV420P</div><div>@@ -504,31 +410,10 @@</div><div>     if (c->pix_fmt != AV_PIX_FMT_YUV420P) {</div><div>         ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);</div><div>         if (!ost->tmp_frame) {</div><div>-            printf("Could not allocate temporary picture\n");</div><div>+            fprintf(stderr, "Could not allocate temporary picture\n");</div><div>             exit(1);</div><div>         }</div><div>     }</div><div>-</div><div>-//    video_handle=open_video_device("/dev/video0");</div><div>-//    printf("Video Device Handle %d\n",video_handle);</div><div>-    if (ConfigureDev(&gVFmt)<0)</div><div>-    {</div><div>-<span class="" style="white-space:pre"> </span>printf("%s(%s) - Fail to open device\n",__FUNCTION__,__FILE__);</div><div>-<span class="" style="white-space:pre"> </span>exit(0);</div><div>-    }</div><div>-    if (gVFmt.bitrate)</div><div>-<span class="" style="white-space:pre">   </span>SetBitrate(gVFmt.stream_id, gVFmt.bitrate/1000);</div><div>-    if(gVFmt.gop)</div><div>-<span class="" style="white-space:pre">       </span>SetGOP(gVFmt.stream_id, gVFmt.gop);</div><div>-<span class="" style="white-space:pre">       </span>/* Mirror flip */</div><div>-    if (gVFmt.ortn)</div><div>-<span class="" style="white-space:pre">    </span>SetMirrFlip(gVFmt.stream_id, gVFmt.ortn);</div><div>-</div><div>-    if (StartCapturing(gVFmt.stream_id)<0)</div><div>-    {</div><div>-<span class="" style="white-space:pre">   </span>printf("%s(%s) - Fail to start capturing\n",__FUNCTION__,__FILE__);</div><div>-<span class="" style="white-space:pre">     </span>exit(0);</div><div>-    }</div><div> }</div><div> </div><div> /* Prepare a dummy image. */</div><div>@@ -536,7 +421,6 @@</div><div>                            int width, int height)</div><div> {</div><div>     int x, y, i, ret;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     /* when we pass a frame to the encoder, it may keep a reference to it</div><div>      * internally;</div><div>@@ -565,7 +449,6 @@</div><div> static AVFrame *get_video_frame(OutputStream *ost)</div><div> {</div><div>     AVCodecContext *c = ost->st->codec;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div> </div><div>     /* check if we want to generate more frames */</div><div>     if (av_compare_ts(ost->next_pts, ost->st->codec->time_base,</div><div>@@ -575,7 +458,6 @@</div><div>     if (c->pix_fmt != AV_PIX_FMT_YUV420P) {</div><div>         /* as we only generate a YUV420P picture, we must convert it</div><div>          * to the codec pixel format if needed */</div><div>-#if 0</div><div>         if (!ost->sws_ctx) {</div><div>             ost->sws_ctx = sws_getContext(c->width, c->height,</div><div>                                           AV_PIX_FMT_YUV420P,</div><div>@@ -592,7 +474,6 @@</div><div>         sws_scale(ost->sws_ctx,</div><div>                   (const uint8_t * const *)ost->tmp_frame->data, ost->tmp_frame->linesize,</div><div>                   0, c->height, ost->frame->data, ost->frame->linesize);</div><div>-#endif</div><div>     } else {</div><div>         fill_yuv_image(ost->frame, ost->next_pts, c->width, c->height);</div><div>     }</div><div>@@ -610,33 +491,12 @@</div><div> {</div><div>     int ret;</div><div>     AVCodecContext *c;</div><div>-    AVFrame *frame=NULL;</div><div>+    AVFrame *frame;</div><div>     int got_packet = 0;</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div>-    </div><div>-    FrameBuf *fra_buf = NULL;</div><div> </div><div>     c = ost->st->codec;</div><div>-    </div><div>-    if (c->codec_id==AV_CODEC_ID_H264)</div><div>-    {</div><div>-<span class="" style="white-space:pre">      </span>fra_buf = AllocBuffer(0);</div><div>-<span class="" style="white-space:pre"> </span>if (!fra_buf)</div><div>-<span class="" style="white-space:pre">     </span>{</div><div>-<span class="" style="white-space:pre"> </span>    printf( "%s(%s) Cannot allocate buffer at Line %d\n",__FUNCTION__,__FILE__,__LINE__);</div><div>-<span class="" style="white-space:pre">     </span>    return 1;</div><div>-<span class="" style="white-space:pre">   </span>}</div><div>-<span class="" style="white-space:pre"> </span>if (CaptureFrame(gVFmt.stream_id, fra_buf)==0)</div><div>-<span class="" style="white-space:pre">    </span>{</div><div> </div><div>-<span class="" style="white-space:pre">        </span>}</div><div>-<span class="" style="white-space:pre"> </span>ost->frame->pts = ost->next_pts++;</div><div>-    }</div><div>-    else</div><div>-    {</div><div>-    printf( "%s(%s) Line: %d\n",__FUNCTION__,__FILE__,__LINE__);</div><div>-<span class="" style="white-space:pre">   </span>frame = get_video_frame(ost);</div><div>-    }</div><div>+    frame = get_video_frame(ost);</div><div> </div><div>     if (oc->oformat->flags & AVFMT_RAWPICTURE) {</div><div>         /* a hack to avoid data copy with some raw video muxers */</div><div>@@ -648,17 +508,9 @@</div><div> </div><div>         pkt.flags        |= AV_PKT_FLAG_KEY;</div><div>         pkt.stream_index  = ost->st->index;</div><div>+        pkt.data          = (uint8_t *)frame;</div><div>+        pkt.size          = sizeof(AVPicture);</div><div> </div><div>-<span class="" style="white-space:pre">        </span>if (c->codec_id==AV_CODEC_ID_H264)</div><div>-        {</div><div>-<span class="" style="white-space:pre">        </span>    pkt.data          = (uint8_t *)fra_buf->buf;</div><div>-    <span class="" style="white-space:pre">  </span>    pkt.size          = fra_buf->buf_used;</div><div>-<span class="" style="white-space:pre">      </span>}</div><div>-<span class="" style="white-space:pre"> </span>else</div><div>-<span class="" style="white-space:pre">      </span>{</div><div>-<span class="" style="white-space:pre"> </span>    pkt.data          = (uint8_t *)frame;</div><div>-    <span class="" style="white-space:pre">    </span>    pkt.size          = sizeof(AVPicture);</div><div>-<span class="" style="white-space:pre"> </span>}</div><div>         pkt.pts = pkt.dts = frame->pts;</div><div>         av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base);</div><div> </div><div>@@ -666,36 +518,19 @@</div><div>     } else {</div><div>         AVPacket pkt = { 0 };</div><div>         av_init_packet(&pkt);</div><div>-<span class="" style="white-space:pre">       </span>if (c->codec_id==AV_CODEC_ID_H264)</div><div>-<span class="" style="white-space:pre">     </span>{</div><div>-<span class="" style="white-space:pre"> </span>    if (IsKeyFrame(fra_buf->buf,fra_buf->buf_used)==1)</div><div>-    <span class="" style="white-space:pre">              </span>pkt.flags        |= AV_PKT_FLAG_KEY;</div><div>-    <span class="" style="white-space:pre">    </span>    pkt.stream_index  = ost->st->index;</div><div>-<span class="" style="white-space:pre">  </span>    pkt.data          = (uint8_t *)fra_buf->buf;</div><div>-    <span class="" style="white-space:pre">  </span>    pkt.size          = fra_buf->buf_used;</div><div>-    <span class="" style="white-space:pre">        </span>    //pkt.pts = pkt.dts = ost->frame->pts;</div><div>-    <span class="" style="white-space:pre">  </span>    pkt.pts = pkt.dts = AV_NOPTS_VALUE;</div><div>-    <span class="" style="white-space:pre">   </span>    av_packet_rescale_ts(&pkt, c->time_base, ost->st->time_base);</div><div>-<span class="" style="white-space:pre">  </span>    ret = av_interleaved_write_frame(oc, &pkt);</div><div>-<span class="" style="white-space:pre">     </span>    //ret = write_frame(oc, &c->time_base, ost->st, &pkt);</div><div>-<span class="" style="white-space:pre">        </span>    FreeBuffer(fra_buf);</div><div>-<span class="" style="white-space:pre">        </span>    got_packet=1;</div><div>-<span class="" style="white-space:pre">       </span>}</div><div>-<span class="" style="white-space:pre"> </span>else</div><div>-<span class="" style="white-space:pre">      </span>{</div><div>-<span class="" style="white-space:pre"> </span>printf( "%s(%s) Line: %d\n",__FUNCTION__,__FILE__,__LINE__);</div><div>-    <span class="" style="white-space:pre">      </span>    /* encode the image */</div><div>-    <span class="" style="white-space:pre">        </span>    ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);</div><div>-    <span class="" style="white-space:pre">     </span>    if (ret < 0) {</div><div>-        <span class="" style="white-space:pre">       </span>fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));</div><div>-        <span class="" style="white-space:pre">       </span>exit(1);</div><div>-    <span class="" style="white-space:pre">    </span>    }</div><div>-    <span class="" style="white-space:pre">     </span>    if (got_packet) {</div><div>-        <span class="" style="white-space:pre">       </span>ret = write_frame(oc, &c->time_base, ost->st, &pkt);</div><div>-    <span class="" style="white-space:pre">  </span>    } else {</div><div>-        <span class="" style="white-space:pre">        </span>ret = 0;</div><div>-    <span class="" style="white-space:pre">    </span>    }</div><div>-<span class="" style="white-space:pre">   </span>}</div><div>+</div><div>+        /* encode the image */</div><div>+        ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);</div><div>+        if (ret < 0) {</div><div>+            fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));</div><div>+            exit(1);</div><div>+        }</div><div>+</div><div>+        if (got_packet) {</div><div>+            ret = write_frame(oc, &c->time_base, ost->st, &pkt);</div><div>+        } else {</div><div>+            ret = 0;</div><div>+        }</div><div>     }</div><div> </div><div>     if (ret < 0) {</div><div>@@ -708,11 +543,10 @@</div><div> </div><div> static void close_stream(AVFormatContext *oc, OutputStream *ost)</div><div> {</div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div>     avcodec_close(ost->st->codec);</div><div>     av_frame_free(&ost->frame);</div><div>     av_frame_free(&ost->tmp_frame);</div><div>-//    sws_freeContext(ost->sws_ctx);</div><div>+    sws_freeContext(ost->sws_ctx);</div><div>     swr_free(&ost->swr_ctx);</div><div> }</div><div> </div><div>@@ -731,9 +565,6 @@</div><div>     int encode_video = 0, encode_audio = 0;</div><div>     AVDictionary *opt = NULL;</div><div> </div><div>-    printf("%s(%s) Enter\n",__FUNCTION__,__FILE__);</div><div>-</div><div>-</div><div>     int i=0;</div><div>     /* Initialize libavcodec, and register all codecs and formats. */</div><div>     av_register_all();</div><div>@@ -750,10 +581,9 @@</div><div>     }</div><div> </div><div>     filename = argv[1];</div><div>-// JJ 20150922 No need to do it</div><div>-//    if (argc > 3 && !strcmp(argv[2], "-flags")) {</div><div>-//        av_dict_set(&opt, argv[2]+1, argv[3], 0);</div><div>-//    }</div><div>+    if (argc > 3 && !strcmp(argv[2], "-flags")) {</div><div>+        av_dict_set(&opt, argv[2]+1, argv[3], 0);</div><div>+    }</div><div> </div><div>     /* allocate the output media context */</div><div>     avformat_alloc_output_context2(&oc, NULL, NULL, filename);</div><div>@@ -766,18 +596,6 @@</div><div> </div><div>     fmt = oc->oformat;</div><div>     fmt->audio_codec=AV_CODEC_ID_MP2;</div><div>-    fmt->video_codec=AV_CODEC_ID_H264;</div><div>-    </div><div>-    strcpy(gVFmt.dev_name,"/dev/video0");</div><div>-    gVFmt.stream_id=SID_RECORD;</div><div>-    gVFmt.pixFmt=V4L2_PIX_FMT_H264;</div><div>-    gVFmt.width=1920;</div><div>-    gVFmt.height=1080;</div><div>-    gVFmt.framerate=30;</div><div>-    gVFmt.gop=30;</div><div>-    gVFmt.bitrate=7168*1000;</div><div>-    gVFmt.ortn=3;</div><div>-</div><div>     /* Add the audio and video streams using the default format codecs</div><div>      * and initialize the codecs. */</div><div>     if (fmt->video_codec != AV_CODEC_ID_NONE) {</div><div>@@ -829,9 +647,8 @@</div><div>         } else {</div><div>             encode_audio = !write_audio_frame(oc, &audio_st);</div><div>         }</div><div>-<span class="" style="white-space:pre">   </span>if (!encode_audio)</div><div>+<span class="" style="white-space:pre">        </span>if (i>30*20)</div><div> <span class="" style="white-space:pre">  </span>    break;</div><div>-</div><div>     }</div><div> </div><div>     /* Write the trailer, if any. The trailer must be written before you</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 6, 2015 at 4:08 PM, Carl Eugen Hoyos <span dir="ltr"><<a href="mailto:cehoyos@ag.or.at" target="_blank">cehoyos@ag.or.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">JJ Liu <jjliu.hk@...> writes:<br>
<br>
> Following is my modified muxing.c<br>
<br>
If you send an unified diff instead, there is<br>
at least a chance that somebody can help...<br>
<br>
Carl Eugen<br>
<br>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div><br></div>