qw | 2 Sep 05:01 2015

dts/pts/duration in packets

Hi,

I'm using avcodec_encode_video2() and avcodec_encode_audio2() to encode video and audio raw data respectively. Can the two encoding function calculate dts/pts/duration of output packets itself? Or I'll calculate those timestamp values by using other method? Does ffmpeg provide examples to calculate those timestamp values?

Thanks!

Andrew


 

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
Arthur Muller | 1 Sep 21:44 2015

avcodec_encode_video2 usage question

Hello,

 

I’m new to FFMPEG. I starting from the muxing.c example and modified it to generate a mp4 video – with no audio – of an animation.

 

I’m encoding 29 frames, all sized 320x200 pixels. I even have a yuv file for all frames.

 

When I play the file I notice that not all frames get displayed, and I suspect the problem is coming about from avcodec_encode_video2; the last argument – got_packet – often comes back as zero. As a result, that particular frame is not written.

 

Is there anything in particular I need to do to make sure that all frames are properly displayed?

 

Thanks.

 

Arthur Muller
Visual Kinematics, Inc.
14395 Saratoga Avenue, Suite 110
Saratoga, CA 95070
(408) 867-6285 (voice)
(408) 867-7218 (fax)
Skype: vki-arthur
mailto:muller-VWcxWUNH1MU@public.gmane.org
http://www.vki.com

 

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
David Ganetti | 31 Aug 10:23 2015
Picon

CBR encoding/muxing

Hello to all.

Do someone know why muxing together two constant bit rate stream into a MPEG
Transport Stream I always I get a file that has "Variable Bit Rate" as
overall bitrate but each stream is marked as CRB?
What could be my error?

Thanks.
David

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
David Ganetti | 31 Aug 10:12 2015
Picon

Unable to obtain Constant Frame Rate encoding

Hello forum.

Checking all my h.264 encoded video I find "Frame rate: Variable" instead
"Frame rate mode: constant" and "Frame rate: 25.000 fps".
What must I set in order to obtain a "Constant Frame Rate" 25.000 fps
encoding?
Can someone help me?

Thanks.
David

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
Polochon Street | 27 Aug 22:21 2015
Picon

Closing codec properly after an audio decoding

Hi!
I use the following code (see below) in order to decode an audio file into an array, and I'm having a memory leak of 24kb:
Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f80c449e386 in __interceptor_posix_memalign /build/gcc-multilib/src/gcc-5.2.0/libsanitizer/asan/asan_malloc_linux.cc:105
    #1 0x7f80c3acc43f in av_malloc (/usr/lib/libavutil.so.54+0x2343f)

So I'm thinking that it's due to some libav-specific things that I didn't close properly, and so here's my question: is avcodec_close(context); sufficient to free a codec context and a codec? This example (http://ffmpeg.org/doxygen/trunk/decoding_encoding_8c-example.html) does an av_free(context), but my program crashes when I try to do it...

Thanks by advance!
Polochon_street

#define INBUF_SIZE 4096

#define AUDIO_INBUF_SIZE 20480

#define AUDIO_REFILL_THRESH 4096


#include "analyze.h"


int audio_decode(const char *filename, struct song *song) { // decode the track

    AVCodec *codec = NULL;

    AVCodecContext *c = NULL;

    AVFormatContext *pFormatCtx;

   

    int i, d, e;

    int len;

    int planar;

    AVPacket avpkt;

    AVFrame *decoded_frame = NULL;

    int8_t *beginning;

    int got_frame;

    int audioStream;

    size_t index;


    av_register_all();

    av_init_packet(&avpkt);


    pFormatCtx = avformat_alloc_context();


    if(avformat_open_input(&pFormatCtx, filename, NULL, NULL) < 0) {

        printf("Couldn't open file: %s, %d\n", filename, errno);

        song->nSamples = 0;

        return 1;

    }


    if(avformat_find_stream_info(pFormatCtx, NULL) < 0) {

        printf("Couldn't find stream information\n");

        song->nSamples = 0;

        return 1;

    }


    audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);

    c = pFormatCtx->streams[audioStream]->codec;

   

    if (!codec) {

        printf("Codec not found!\n");

        song->nSamples = 0;

        return 1;

    }


    if(avcodec_open2(c, codec, NULL) < 0) {

        printf("Could not open codec\n");

        song->nSamples = 0;

        return 1;

    }

   

    song->sample_rate = c->sample_rate;

    song->duration = pFormatCtx->duration/AV_TIME_BASE;

    size = (((uint64_t)(pFormatCtx->duration)*(uint64_t)song->sample_rate)/(uint64_t)AV_TIME_BASE)*c->channels*av_get_bytes_per_sample(c->sample_fmt);

    song->nSamples = (((uint64_t)(pFormatCtx->duration)*(uint64_t)song->sample_rate)/(uint64_t)AV_TIME_BASE)*c->channels;

    song->sample_array = malloc(size);


    for(i = 0; i < size; ++i)

        song->sample_array[i] = 0;


    beginning = song->sample_array;

    index = 0;


    planar = av_sample_fmt_is_planar(c->sample_fmt);

    song->nb_bytes_per_sample = av_get_bytes_per_sample(c->sample_fmt);


    song->channels = c->channels;

   

/* End of codec init */

    while(av_read_frame(pFormatCtx, &avpkt) >= 0) {

        if(avpkt.stream_index == audioStream) {

            got_frame = 0;

       

            if(!decoded_frame) {

                if(!(decoded_frame = av_frame_alloc())) {

                    printf("Could not allocate audio frame\n");

                    exit(1);

                }

            }

            else

                av_frame_unref(decoded_frame);


            len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);

   

            if(len < 0)

                avpkt.size = 0;


            av_free_packet(&avpkt);


            /* interesting part: copying decoded data into a huge array */

            /* flac has a different behaviour from mp3, hence the planar condition */

            if(got_frame) {

                size_t data_size = av_samples_get_buffer_size(NULL, c->channels, decoded_frame->nb_samples, c->sample_fmt, 1);


                if(index*song->nb_bytes_per_sample + data_size > size) {

                    beginning = realloc(beginning, (size += data_size));

                    song->nSamples += data_size/song->nb_bytes_per_sample;

                }

                int8_t *p = beginning+index*song->nb_bytes_per_sample;

                if(planar == 1) {

                    for(i = 0; i < decoded_frame->nb_samples*song->nb_bytes_per_sample; i += song->nb_bytes_per_sample) {

                        for(e = 0; e < c->channels; ++e)

                            for(d = 0; d < song->nb_bytes_per_sample; ++d)

                                *(p++) = ((int8_t*)(decoded_frame->extended_data[e]))[i+d];

                    }

                    index += data_size/song->nb_bytes_per_sample;

                }

                else if(planar == 0) {

                    memcpy(index*song->nb_bytes_per_sample + beginning, decoded_frame->extended_data[0], data_size);

                    index += data_size/song->nb_bytes_per_sample;

                }

            }

        }

    }

    song->sample_array = beginning;


    /* cleaning memory */

   

    avcodec_close(c);

    av_frame_unref(decoded_frame);

    av_frame_free(&decoded_frame);

    av_free_packet(&avpkt);

    avformat_close_input(&pFormatCtx);


    return 0;

}

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
Zhang Rui | 28 Aug 11:39 2015
Picon

About custom URLProtocol

1. Is it OK to expose URLProtocol as public API for user to implement
custom protocol more than custom IO?

2. Is it OK to add (void *opaque) field to URLContext to represent
AVFormatContext.opaque?
_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
Gonzalo | 27 Aug 23:44 2015
Picon

VDPAU Nvidia acceleration

I just upgraded my Linux drivers and nvidia-settings says I have VDPAU 
support.  I was wondering how do I activate it in ffmpeg and whether it
will have a benefitial impact on my player.

Any help is much appreciated as I am new to decoding on the hw.

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
David Ganetti | 27 Aug 16:11 2015
Picon

Wrong information in my MPEG transport stream

Hello to the forum!

I’m recording a 1080i25 video signal with one stereo audio tracks. 

 

I need to create a CBR MPEG transport stream with one h.264 25fps video track and one MPEG-Audio stereo audio track.

 

I’m was able to create required audio e video track with constant bit rate and mux them into a transport stream, but checking the file with MediaInfo (see the attached file)…

1 – the reported overall bitrate of the file results Variable Bit Rate even if the two muxed streams are CBR as required

2 – in the video stream properties I read “Frame rate mode: Variabile” instead 25 frames per second as set in the codec contest

 

Can someone help me?

 

Thanks in advance

 

Generale
ID                                       : 1 (0x1)
Complete name                            : C:\H.264\h.264_1920x1080i25_8Mbit_MPEG2AUDIO2CH_faster.m2ts
Format                                   : BDAV
Format/Info                              : Blu-ray Video
File size                                : 31,4MiB
Duration                                 : 28s 640ms
Overall bit rate mode                    : Variabile
Overall bit rate                         : 9.181 Kbps

Video
ID                                       : 256 (0x100)
Menu ID                                  : 1 (0x1)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High <at> L4
Format settings, CABAC                   : Si
Format settings, ReFrames                : 4 frame
Codec ID                                 : 27
Duration                                 : 28s 720ms
Bit rate mode                            : Costante
Bit rate                                 : 8.552 Kbps
Nominal bit rate                         : 8.000 Kbps / 8.000 Kbps
Width                                    : 1.920 pixel
Height                                   : 1.080 pixel
Display aspect ratio                     : 16:9
Frame rate mode                          : Variabile
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bit
Scan type                                : MBAFF
Scan order                               : Top field first
Stream size                              : 29,3MiB (93%)
Writing library                          : x264 core 144 r2525 40bb568
Encoding settings                        : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=4 / psy=1 /
psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / 

trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=36 /
lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=tff / 

bluray_compat=0 / constrained_intra=0 / bframes=10 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 /
weightb=1 / open_gop=0 / weightp=0 / keyint=25 / keyint_min=2 / scenecut=40 / 

intra_refresh=0 / rc_lookahead=12 / rc=cbr / mbtree=1 / bitrate=8000 / ratetol=1.0 / qcomp=0.60 /
qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=8000 / vbv_bufsize=8000 / nal_hrd=cbr / 

filler=1 / ip_ratio=1.40 / aq=1:1.00

Audio
ID                                       : 257 (0x101)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 2
Codec ID                                 : 3
Duration                                 : 28s 608ms
Bit rate mode                            : Costante
Bit rate                                 : 256 Kbps
Channel(s)                               : 2 canali
Sampling rate                            : 48,0 KHz
Compression mode                         : Con perdita
Stream size                              : 894 KiB (3%)

Menu
ID                                       : 4096 (0x1000)
Menu ID                                  : 1 (0x1)
Duration                                 : 28s 640ms
List                                     : 256 (0x100) (AVC) / 257 (0x101) (MPEG Audio)
Service name                             : My Service
Service provider                         : My Provider
Service type                             : digital television

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
qw | 25 Aug 04:09 2015

sample format in wmav2 codec

Hi,

I use ffmpeg which version is shown below:

    commit eff2ed2fde8d6741e7a5218e036998846062c846
    Merge: a9f1d58 57cde2b
    Author: Michael Niedermayer <michaelni <at> gmx.at>
    Date:   Wed May 27 22:37:05 2015 +0200


I use wmav2 encoder in ffmpeg whose codec id is AV_CODEC_ID_WMAV2, sample format is AV_SAMPLE_FMT_FLTP. If input sample format is AV_SAMPLE_FMT_S16, does ffmpeg have wmav2 encoder whose sample format is AV_SAMPLE_FMT_S16? or I need write conversion routine for different sample formats? Does ffmpeg have some functions that convert one format to another?

Thanks!

B.R.

Andrew





_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
qw | 21 Aug 09:02 2015

about ffmpeg source code and api version

Hi,

I downloaded ffmpeg source code long time ago. And I find there are various versions of ffmpeg api and related documentation. How to know api version of my downloaded source code?

Below information maybe helpful:

git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/oldabi
  remotes/origin/release/0.10
  remotes/origin/release/0.11
  remotes/origin/release/0.5
  remotes/origin/release/0.6
  remotes/origin/release/0.7
  remotes/origin/release/0.8
  remotes/origin/release/0.9
  remotes/origin/release/1.0
  remotes/origin/release/1.1
  remotes/origin/release/1.2
  remotes/origin/release/2.0
  remotes/origin/release/2.1
  remotes/origin/release/2.2
  remotes/origin/release/2.3
  remotes/origin/release/2.4
  remotes/origin/release/2.5
  remotes/origin/release/2.6

git log
commit eff2ed2fde8d6741e7a5218e036998846062c846
Merge: a9f1d58 57cde2b
Author: Michael Niedermayer <michaelni <at> gmx.at>
Date:   Wed May 27 22:37:05 2015 +0200

    Merge commit '57cde2b180fcec0eaf60aad65f436ab6420546f5'
    
    * commit '57cde2b180fcec0eaf60aad65f436ab6420546f5':
      lavf: move TLS-related ifdeffery to library specific files
    
    Conflicts:
        libavformat/network.c
        libavformat/tls.h
        libavformat/tls_openssl.c
    
    See: a9f1d584e53fb39d983201585cb136986a85cac8
    Merged-by: Michael Niedermayer <michaelni <at> gmx.at>

commit a9f1d584e53fb39d983201585cb136986a85cac8
Author: wm4 <nfxjfg <at> googlemail.com>
Date:   Wed May 27 12:57:51 2015 +0200

    lavf: move TLS-related ifdeffery to library specific files
    
    There is no need to have this mess in network.c.
    
    Signed-off-by: Michael Niedermayer <michaelni <at> gmx.at>

Thanks!

B.R.

Andrew





_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
Kevin J. Brooks | 20 Aug 18:48 2015

File does not seem to close

Hello All,

I am using the following function call to open the file for encoding video:

avformat_alloc_output_context2(&m_oc, m_fmt, NULL, filePath.c_str());

Then when I want to stop recording the video, I use this function to free it:

avformat_free_context(m_oc);

The issue is, if my program is still running and the user opens Windows Explorer, the file size is showing as zero.  Also, inside my program the user can browse the directory and delete videos.  If the user tries to delete a video that was created during the current session, the file will not delete.  The user can open it and play it, however.

I am assuming there is another function call I need to make to properly close the file.  Can anyone tell me what call I am missing?

--
Sincerely,
Kevin J. Brooks


Senior Software Engineer


R2C Support Services


200 West Side Square Suite 604


Huntsville, AL 35801

Office: 256-684-8383 ext. 104




_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user

Gmane