cesar pachon | 24 Apr 18:33 2015
Picon

FFMPEG avformat_write_header changing my stream time_base

I am muxing video using ffmpeg 2.1.3 with libavcodec 55.39.101 (forced to that version because is the one available in google-chrome PNACL port project). all my frames seems to have bad the time. they try to be rendered all at once at the beggining of the video when playing it.

I am setting the stream time base to 1/25, but just after calling avformat_write_header, it has the value of -18082736/1. in each frame, when I print the stream time_base it says 1/12800, while the time_base of codec is always ok (1/25).

console log before and after av_format_write_header:

before avformat_write_header stream time_base: 1/25
after avformat_write_header ret 0 stream time_base: -18082736/1

the code (abreviated to keep the post short, all calls in the original version had error checking):

AVCodecContext *codecContext;
AVCodec * codec = avcodec_find_encoder(codec_id); 
myOutputStream->stream = avformat_new_stream(outputFormatContext, *codec);
myOutputStream->stream->id = outputFormatContext->nb_streams-1;
codecContext = myOutputStream->stream->codec;
codecContext->codec_id = codec_id;
codecContext->bit_rate = 400000;
codecContext->width    = width;
codecContext->height   = height;
myOutputStream->stream->time_base = (AVRational){ 1, 25 };
codecContext->time_base       = myOutputStream->stream->time_base;
codecContext->gop_size      = 12;
codecContext->pix_fmt       = AV_PIX_FMT_YUV420P;
AVDictionary *opt = NULL;
av_dict_copy(&opt, opt_arg, 0);
ret = avcodec_open2(codecContext, codec, &opt);
av_dict_free(&opt);
myOutputStream->frame = alloc_picture(codecContext->pix_fmt, codecContext->width, codecContext->height);
  myOutputStream->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, codecContext->width, codecContext->height);

//before: printing g_outputContext->stream time_base here
ret = avformat_write_header(g_outputContext, &opt);
//after: printing g_outputContext->stream time_base here


(note: I also posted this question in stackoverflow: http://stackoverflow.com/questions/29850246/ffmpeg-avformat-write-header-changing-my-stream-time-base)


Cesar  Pachón
-------------------------------------------------------------
www.cesarpachon.com, just a digital hermit

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Puneet B | 24 Apr 07:27 2015
Picon

FFMPEG android compilation issue.

HI All,

I want compile ffmpeg-2.4.3 to android , Here my script used to compile and error i am facing.

Script:

export NDKHOME=/home/embdes/Projects/A20/android-ndk-r10

export CCHOME=/home/embdes/Projects/A20/android-ndk-r10/toolchain/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi

export PLATFORM=$NDKHOME/platforms/android-18/arch-arm/

export CFLAGS="-O9 -march=armv7-a -ffast-math -fomit-frame-pointer -lc -lm  -L $NDKHOME/platforms/android-18/arch-arm/usr/lib/ -I $NDKHOME/platforms/android-18/arch-arm/usr/include/ -I. -mtune=cortex-a8 -mfpu=neon  -ldl -Ifreetype/include -fPIC -mfloat-abi=softfp -Wl,--fix-cortex-a8 -ftree-vectorize -mvectorize-with-neon-quad -nostdlib -fstack-protector-all -DHAVE_ASM_MOD_Q=1 -DHAVE_ASM_MOD_Y=1 -DMPLAYER_JAVA_PACKAGE_PATH=com_vnd_mplayer_neon_noad -DHAVE_VFP=1 -funroll-loops  -DNOAD=1 -D__linux__ -DHAVE_AS_FUNC=1 -DHAVE_LOCAL_ALIGNED_32=1 -DHAVE_AS_DN_DIRECTIVE=1"

export LDFLAGS="-L $NDKHOME/platforms/android-14/arch-arm/usr/lib/ -lc -lm -lgcc  -nostdlib -ljnigraphics -llog -Wredundant-decls"

./configure --cc=$CCHOME-gcc --nm=$CCHOME-nm  --ar=$CCHOME-ar --as=$CCHOME-as --ranlib=$CCHOME-ranlib --host-cc=gcc --target-os=linux --arch=arm --enable-armv6t2  --enable-cross-compile --extra-libs="-lgcc" --enable-static  

make

The ERROR in config log:

 /home/embdes/Projects/A20/android-ndk-r10/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-as: unrecognized option '-_ISOC99_SOURCE'
GNU assembler not found, install/update gas-preprocessor

Could anyone tell me how to solve this.

Regards
Punith
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
cesar pachon | 23 Apr 20:27 2015
Picon

av_packet_rescale_ts vs av_rescale_q

hello, I am trying to create a chrome extension to capture desktop video stream and produce a video file. I based my work on the muxer.c example and it works except for the fact that av_packet_rescale_ts is not defined (I commented that line and I am able to get a video where only the first frame is visible and the video duration is zero)

as I am using PNACL port of ffmepg (2.1.3), I am forced to use libavcodec 55.39.101, and in that version av_packet_rescale_ts is not defined.

in other tutorials I had found that av_rescale_q is used. I highly appreciate any suggestions about how to replace the call to av_packet_rescale_ts with av_rescale_q or similar.

this is the current code for my add_frame method:

int test_addframe(const uint8_t * data, uint32_t size, int w, int h){

   int ret;
    AVCodecContext *c;
    AVFrame *frame;
    int got_packet = 0;

    c = video_st.st->codec;
    frame = test_get_video_frame(&video_st, data, size, w, h);
  
        AVPacket pkt = { 0 };
        av_init_packet(&pkt);

        ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
        if (ret < 0) {
            fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
            exit(1);
        }

        if (got_packet) {
            //old version ret = write_frame(oc, &c->time_base, video_st.st, &pkt);
        //new version: this is the code of write_frame:   
        // rescale output packet timestamp values from codec to stream timebase
        
        //THIS METHOD DOES NOT EXIST IN PNACL VERSION OF FFMPEG 2.1.3
      //av_packet_rescale_ts(&pkt, &c->time_base, video_st.st->time_base);
        
        pkt.stream_index = video_st.st->index;

        // Write the compressed frame to the media file.
        log_packet(oc, &pkt);
        ret = av_interleaved_write_frame(oc, &pkt);
     
        } else {
            ret = 0;
        }
   

    if (ret < 0) {
        fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
        exit(1);
    }
    return (frame || got_packet) ? 0 : 1;
};
 


Cesar  Pachón
-------------------------------------------------------------
www.cesarpachon.com, just a digital hermit

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Eric Reichert | 23 Apr 20:04 2015

Possible memory leak with respect to cleaning up RtpMuxContexts

I’ve only been working with the FFMPEG libs (directly) for a few weeks so I’m not sure about what I’ve found.

I’ve created a short program that demonstrates the problem.  The program can be found at https://github.com/trafficland/rtpmemleak.

There’s a much more detailed explanation which can be found here https://github.com/trafficland/rtpmemleak/blob/master/README.md.

The short version is that after streaming packets to a multicast address using a RTP formatted stream, the RtpMuxContext.buf field is not released by avformat_close_input.  

The only way to clean up that field is to do it manually as follows (a snippet from the code found at the links).

//*** The memory assigned to dstFmtCtxt->priv_data->buf must be cleaned up manually as it is not cleaned up by avformat_close_input
//*** Comment out the next 2 lines and run valgrind to see the leak stats.
RTPMuxContext* x = (struct RTPMuxContext *) dstFmtCtxt->priv_data;
av_free(x->buf);
avformat_close_input(&dstFmtCtxt);

Sample valgrind reports can be found at the links as well.

Is this a genuine leak or am I missing a cleanup call?

Eric Reichert


CONFIDENTIALITY NOTICE - The information contained in this e-mail and any accompanying documents may contain information that is confidential or otherwise protected from disclosure. If you are not the intended recipient of this message, or if this message has been addressed to you in error, please immediately alert the sender by reply e-mail and then delete this message, including any attachments. Any dissemination, distribution or other use of the contents of this message by anyone other than the intended recipient is strictly prohibited.

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Randy Ly | 22 Apr 21:58 2015

Proper way to reset H264 Codec

Hello,

I am having some issues receiving RTSP image data from an IP camera. We get into a state where we can receive the data, feed it into the codec via avcodec_decode_video2(...), but we never get signaled that a full frame is ready for use (via the got_picture_ptr parameter). The return value for the function is > 0, so there is some bytes being decoded. If I restart the application, or start another instance of the same application (on a different PC, because of the application itself doesn't allow me to start 2 instances) , then we can get the video frames correctly, so that rules out networking and camera issues.

We currently call avcodec_flush_buffers(videoDecContext) to try and reset the the codec, and I can't find any non-pedagogic examples floating around on the internet.

Here's a sample of a dump of stderr when the logging level is set to WARN.

[h264 <at> 034ee100] illegal short term buffer state detected
[h264 <at> 034ee100] mmco: unref short failure
[h264 <at> 94c89660] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 9254e960] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 94c89660] no frame!
[h264 <at> 9254e960] no frame!
 
Any thoughts?
-Randy

--
Randy Ly
System Analyst
Searidge Technologies
19 Camelot dr, Ottawa, ON

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Nisar Ahmed | 23 Apr 15:57 2015
Picon

Packed variant of PIX_FMT_YUV420P

Where is packed variant of planar YUV420P format, I need packed version instead of planar while demuxing when libav, can someone please point me to the right direction, I don't want to swscale to ARGB because I think it will take extra CPU resources...

Thanks?
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Zahir Dhada | 21 Apr 17:25 2015

Deep copy of AVCodecContext

Hi all,

My application receives live h264 stream from a source, which I decode using libav. The source only sends an I-frame at the beginning of the stream, and never after. My application allows a user to record the stream at any random point in the stream, i.e., the user would press record button and the application would start recording the stream from that point. From the moment recording begins, I start storing the frames received in the stream in a file. And when the stream ends, I read one frame at a time from the file, and transcode it. The problem is, as the only I-frame I get is at the beginning of the stream, I cannot decode the frames stored in the file (as they are all P frames). I want to make a deep copy of the decoder I use to decode the stream right before I start writing frames to the file. That way I can resume decoding the frames stored in the file and re-encode them using the copied context. But I cannot seem to find anything on how to make a deep copy of the AVCodecContext.

Any help in the matter would be appreciated.

Cheers,
Zahir.
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Muhammad Ali | 19 Apr 10:50 2015

Trouble muxing H264 bitstream and ADTS AAC streams together into FLV

I am having trouble muxing H264 bitstream and ADTS AAC streams together into FLV.
If i pack H264 bitstream (source is hardware encoder) into FLV , it plays fine with proper duration and bitrate. But when I mux audio along , the bitrate and duration go all wrong and on the playback, I only hear the audio. The video gets stuck on first frame
Here is my muxing code : http://pastebin.com/C6bYqtsA

Notice that I haven't used pkt(AVPacket) flag . I am not sure what to do with it.

I am also assuming that I don't have to tell muxer about what type of frame I am writing (I frame or P frame). I have no idea if I have to tell that to the muxer.

I am just taking the frame as it comes from the encoder and passing it on to muxer. What else should I take care of ?

--
Muhammad Ali
And Or Logic
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Muhammad Ali | 20 Apr 05:46 2015

Trouble muxing H264 bitstream and ADTS AAC streams together into FLV

I am having trouble muxing H264 bitstream and ADTS AAC streams together into FLV.
If i pack H264 bitstream (source is hardware encoder) into FLV , it plays fine with proper duration and bitrate. But when I mux audio along , the bitrate and duration go all wrong and on the playback, I only hear the audio. The video gets stuck on first frame
Here is my muxing code : http://pastebin.com/C6bYqtsA

Notice that I haven't used pkt(AVPacket) flag . I am not sure what to do with it.

I am also assuming that I don't have to tell muxer about what type of frame I am writing (I frame or P frame). I have no idea if I have to tell that to the muxer.

I am just taking the frame as it comes from the encoder and passing it on to muxer. What else should I take care of ?
--
Muhammad Ali
And Or Logic
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Philip Schneider | 19 Apr 22:57 2015
Picon
Picon

ProRes 444(4) with FFmpeg API (libavcodec)?

Greetings -

I have some code that converts a sequence of still images (animation frames) to H.264, using either the
libx264 or libopenh264 library (depending on how I build libavcodec, etc). 

Now, I’d like to extend this to encoding ProRes format, both the 422 and 444(4) variants. I can set the
codec ID to AV_CODEC_ID_PRORES and the pixel format to AV_PIX_FMT_YUV422P10LE, and the resulting movie
is created with ProRes 4:2:2 format. Yay!

But, if instead I choose the AV_PIX_FMT_YUV444P10LE pixel format, I get the “Specified pixel format is
invalid or not supported” error at runtime. From what I’ve read, this indicates that my FFmpeg
libavcodec is using either “prores” or “prores_aw”, rather than “prores_ks”, the latter
supposedly supporting 4444 (or 444?)

While it seems easy to specify which ProRes encoder to use in the ffmpeg command-line program, I don’t
know how to do this via the libavcodec API? Do I need to compile it in some particular way (seems not…)? Or,
is this something I have to specify with the API, in addition to setting the codec ID to AV_CODEC_ID_PRORES?

In short, how do I use/specify the “prores_ks” encoder with the API?

Thanks!

_______________________________________________
Libav-user mailing list
Libav-user <at> ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user
declan harrison | 19 Apr 11:55 2015
Picon

Help in understanding seeking behaviour of FFmpeg API on MP4 video with hint tracks

I need help understanding the internals of FFmpeg API seek call with certain files.

Im using the ffmpeg libav* API in an appliaction that reduces the bitrate
of MP4 files.  The output MP4 file has 1 H264 video and 1 AAC audio track.

The application supports seeking on the input file to a specifc video frame using
the seek API call. 

I added some diagnostics to FFmpeg to help me see what happens during seek calls.

So generally seeking works fine for me. I make seek API call on the video track to a PTS and the MP4 demuxer
aligns its internal sample index pointers for each track, so the next time demuxer reads for the next frame, it will
seek to  position the file pointer into the required offset to get the required frame. The behaviour is predicatble
for input files that have audio and video tracks. So ffmpeg may 2 two phyical file/stream seeks if it need to 
locate the correct frame for audio and video.
        
Posted this originally to ffmpeg-devel, which is the wrong mailing list for this query so re-posting here. Apoligies for this.


However I have an issue when i Have an input flle with 6 tracks. 1 H264 Video track, 1 AAC audio
track, 2 Hint tracks (one for vidoe and audio), an OD track (has 1 sample) and a Scenes track (which has 1 sample).

the layout of this file is ftyp-moov-mdat-free-free

When I perform the seek API call this time on this file, the MP4 demuxer as expected aligns its internal sample index pointer for each track, so the next time we request a frame from demuxer it will seek to the correct postiion in the file to get the correct frame. 

This works as expected, we seek into the correct  location in the file, and align correctly for each of the other tracks.
Only 4 of the tracks have samples at the desired time, audio, video and both hint tracks.

So application is able to start demuxing the frames from this seek time (e.g. 1 second) for
all 4 tracks. 

However after reading a certain amount of data another 2 seek requests are made 
internally by FFmpeg to a position in bothj of the Hint tracks at a time unrelated
to the oriignal seek request e.g. 3 seconds.  

Im at a loss to explain, why FFmpeg internally needs to perform these 2 addiitonal
seek requests into each of the hint tracks, when no other seek API call is made.

Surely 1 seek request, results in at maximun 1 seek request per track.  However in this
case I have 2 seeks on the hint tracks.   The 'Scene'  and 'OD' track dont have any sample
for this seek location.

Im hoping someone can explain, why this happens and how predictable it is?

Thanks
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user

Gmane