volich | 24 Jul 08:18 2014
Picon

Re: [libav-user] queuing of avframe

Sorry for formating, it was first message.

Hi

I want to realise AVFrames handling with queue.
My code is

int decode(AVCodecContext *codec_ctx, AVPacket *packet)
{
  AVFrame *frame = av_frame_alloc();
  if (!frame)
    return -1;

  int got_frame;
  int ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, packet);
  if (ret >= 0 && got_frame) {
    /* Allocate buffer references */
    for (int i = 0; i < 3; i++) {
      uint8_t *data = frame->data[i];
      int size = frame->linesize[i] * frame->height;
      frame->buf[i] = av_buffer_create(data, size, av_buffer_default_free, NULL, 0);
    }

    enqueue(frame);
    return 0;
  }

  av_frame_free(&frame);
    return -1;
}
(Continue reading)

volich | 24 Jul 08:01 2014
Picon

Queuing of AVFrame

Hi

I want to realise AVFrames handling with queue.
My code is

int decode(AVCodecContext *codec_ctx, AVPacket *packet)
{
           AVFrame *frame = av_frame_alloc();
if (!frame) return -1;

int got_frame; int ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, packet); if (ret >= 0 && got_frame) {
/* Allocate buffer references */ for (int i = 0; i < 3; i++) { uint8_t *data = frame->data[i]; int size = frame->linesize[i] * frame->height; frame->buf[i] = av_buffer_create(data, size, av_buffer_default_free, NULL, 0); } enqueue(frame); return 0; }
av_frame_free(&frame); return -1;}

void someFunc()
{
           AVFrame *frame = dequeue();

....
if (frame) av_frame_free(&frame); }

Is it right?

Regards,
Yuriy

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Anthony Clark | 24 Jul 04:07 2014
Picon

RTP woes

Hey all,

The RTP libraries in FFMPEG aren't documented or really even used in many opensource projects I could find. My main questions are:

1) the RTP implementation only seems to support one (1) stream. Does this mean extra work has to be done one the receiver to coordinate the streams when using the SDP as input? As in, how do A/V steams get synchronized if the streams are delivered completely separately (ie - not muxed).

2) I'm interested in have a RAW binary data steam possibly implemented as an extension/part of FFMPEG. Where do I start for looking into creating my own encoder/decoder/muxer/demuxer/plugin?

3) Follow up to question 1, would muxing everything into an MPEGTS file be 'easier' to manage a central delivery mechanism?

Thanks all, I'm just a little overwhelmed with how large the API is and how little documentation there is. Most of the API is self explanatory, but it seems there are conventions I can't find the source of. 

Thanks!
Anthony C.

_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Matt Orlando | 23 Jul 23:06 2014
Picon

H.264 Looping

Hi everyone,

I need to implement a means of looping some h.264 videos.  I'll copy my current implementation here for my update so you can see how it's currently working.  I use Unity so this code resides in a native plug-in that I turn into a DLL.  My C# scripts track the current frame they've acquired since multiple streams run in conjunction with each other to form a single "asset".  For any looping clips, I'd like to reset the desired frame to 0 and have the DLL start streaming again from the beginning.

If anyone can help point me in the right direction for handling this, that'd be amazing.  I'm sure there are simple ways I could go that'd basically re-open the streams; however, I need to make sure there's no hiccup of course.

Here's the update code:

bool H264Stream::Update(int desiredFrame)
{
if( desiredFrame <= m_FrameRead )
return true;
int frameFinished = 0;
if( av_read_frame( m_AVFormat, &m_Packet ) >= 0 )
{
if( m_Packet.stream_index == m_AVStream->index )
{
avcodec_decode_video2( m_AVContext, m_AVFrame, &frameFinished, &m_Packet );
if( frameFinished != 0 )
{
sws_scale( m_SwsContext, m_AVFrame->data, m_AVFrame->linesize, 0, m_AVContext->height, m_Picture->data, m_Picture->linesize );
m_FrameRead++;
av_free_packet( &m_Packet );
}
}
else
{
av_free_packet( &m_Packet );
}
}
else if( !m_Completed )
{
m_Packet.data = NULL;
m_Packet.size = 0;
avcodec_decode_video2( m_AVContext, m_AVFrame, &frameFinished, &m_Packet );
if( frameFinished != 0 )
{
sws_scale( m_SwsContext, m_AVFrame->data, m_AVFrame->linesize, 0, m_AVContext->height, m_Picture->data, m_Picture->linesize );
m_FrameRead++;
}
else
{
m_Completed = true;
av_free_packet( &m_Packet );
}
}
return m_FrameRead >= desiredFrame;
}


Thanks for the help!
-Matt 
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Carl Eugen Hoyos | 23 Jul 12:49 2014
Picon

Re: MOV/MP4 format not playing in Windows Media Player (but does play in ffplay, vlc, ...)

Robin Stevens <rdstevens <at> ...> writes:

> The MP4 file is produced, and works just fine in 
> ffplay or vlc, but won't play in windows media player.

Did you test with ffmpeg (the application)?

Carl Eugen
Robin Stevens | 23 Jul 11:14 2014
Picon

MOV/MP4 format not playing in Windows Media Player (but does play in ffplay, vlc, ...)

Hi,

I wonder if anyone can help with this, as I've been working on this
problem for a long time now without any progress.

I'm trying to produce an MP4 file with MPEG4p2 video and AAC audio.

The MP4 file is produced, and works just fine in ffplay or vlc, but
won't play in windows media player. (In fact, the audio stream does
play, but not the video.)

If I run the file through ffmpeg.exe -i test.mov -acodec copy -vcodec
copy test2.mov (ie. only remuxing) the resultant file plays fine in
all players.

So, it seems there must be some option that I'm failing to pass to the
muxer to get it to produce compatible files?

When I do a binary compare between the two files, there are only small
differences. The first difference is in the contents of the first
encoded video packet, which has a string like Libavc.63.100 in the bad
file, which has been stripped from the good file.

This data is produced by the video encoder, so is there a setting I
should be passing there?

(I've tried workaround_bugs = FF_BUG_MS, but that value never makes it
to the actual MpegEncContext used internally - please see my other
email. Hacking the ffmpeg code to force the value doesn't seem to make
any difference.)

I'm at my wits end with this; it feels like I'm so close and just need
one crucial piece of information from an expert to finish the job.
Please can anyone here help!!!

The code I'm using is below. I've removed the video signal generation,
error checking and audio generation for brevity. (The problem is the
same whether or not I include an audio stream.)

int main(int argc, char* argv[])
{
  av_register_all();

  AVFormatContext* avFormatContext = NULL;
  AVOutputFormat* avOutputFormat = NULL;

  AVCodecContext* avVideoCodecContext = NULL;
  AVCodec* avVideoCodec = NULL;
  AVStream* avVideoStream = NULL;

  int result = -1;

  const char * filename = "test.mp4";

  avOutputFormat = av_guess_format(NULL, filename, NULL);

  avFormatContext = avformat_alloc_context();
  avFormatContext->oformat = avOutputFormat;
  // Set up the video codec and stream
  avVideoCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);

  AVRational videoTimeBase;
  videoTimeBase.num = 1;
  videoTimeBase.den = 65535;

  AVRational msTimeBase;
  msTimeBase.num = 1;
  msTimeBase.den = 1000;

  avVideoStream = avformat_new_stream(avFormatContext, avVideoCodec);
  avVideoCodecContext = avVideoStream->codec;

  avVideoCodecContext->pix_fmt = PIX_FMT_YUV420P;
  avVideoCodecContext->time_base = videoTimeBase;
  //avVideoCodecContext->strict_std_compliance = 2;
  //avVideoCodecContext->workaround_bugs = FF_BUG_MS; // This doesn't
get copied into   internal private structure.
  // Use opts?
  avVideoCodecContext->width = 640;
  avVideoCodecContext->height = 480;

  result = avcodec_open2(avVideoCodecContext, avVideoCodec, NULL);

  avVideoCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;

  // Open the file, into the AVIOContext held in the format context
  result = avio_open(&avFormatContext->pb, filename, AVIO_FLAG_WRITE);

  result = avformat_write_header(avFormatContext, NULL);

  int got_packet_ptr = -1;

  AVPacket videoPacketOut;
  memset(&videoPacketOut, 0, sizeof(AVPacket));

  // Generate an image - removed for brevity

  // Iterate through 60 seconds worth of frames.

  __int64 endPtsMS = 60000; // 60s
  __int64 videoPtsMS = 0LL;

  int desiredFrameCount = 600;
  int calculatedFrameDurationMS = endPtsMS / desiredFrameCount;

  int __i = 0;
  int sampleCount = 0;

  bool moreVideo = true;
  while(moreVideo)
  {
    moreVideo = videoPtsMS < endPtsMS;
    if ((videoPtsMS < endPtsMS) && videoPacketOut.data == 0)
    {
      // BGR24 is a packed format, so all the data is in a single
plane. How do I know this?
      GenerateFrame(sourceFrame, videoPtsMS);

      result = sws_scale(swsContext, sourceFrame->data,
sourceFrame->linesize, 0, sourceHeight, rescaledFrame->data,
rescaledFrame->linesize);

      int64_t videoTimeBasePts = av_rescale_q(videoPtsMS, msTimeBase,
videoTimeBase);
      rescaledFrame->pts = videoTimeBasePts;

      // Compress the video data. libav will allocate the output
buffer, we need to free it
      result = avcodec_encode_video2(avVideoCodecContext,
&videoPacketOut, rescaledFrame, &got_packet_ptr);
      videoPacketOut.stream_index = avVideoStream->index;

    }

    if (videoPacketOut.data != 0 )
    {
      if (videoPacketOut.data != 0)
      {
        result = av_interleaved_write_frame(avFormatContext, &videoPacketOut);

        av_free_packet(&videoPacketOut);
        videoPacketOut.data = 0;
        videoPtsMS += calculatedFrameDurationMS;
      }
    }
  }

  result = av_write_trailer(avFormatContext);

  avcodec_close(avVideoCodecContext);

  avformat_free_context(avFormatContext);
  // todo... more cleaning
  return 0;
}
Dobány És Korik | 23 Jul 10:02 2014
Picon

proxyauth backport

Dear libav-users,

I am using ffmpeg library in an embedded system, proxy works fine without auth method. I would need the
proxyauth patch (see the link below) backport to version "SVN-r24872".
http://ffmpeg.org/pipermail/ffmpeg-cvslog/2011-November/043346.html

1, Could you please advise me a simple way to do it (maybe I can do that job)?

2, Could you please give me detail how to use proxyauth settings with library,
as I cannot find information at "https://www.ffmpeg.org/libavformat.html"

3, Could you please advise me any of developers from the link below to do that job (maybe it is better to ask a
professional)? 
https://www.ffmpeg.org/consulting.html

Thanks,
Imre
Mert Gedik | 22 Jul 11:24 2014
Picon

About fetching RTMP metadata with ffmpeg

Hello everybody,

I need to show metadata information that attached by the Flash media server in RTMP streams, but according the reference in below, this information comes with the data key frames, does this mean I need to find this data in AVPacket structure ? 

I've found AV_PKT_DATA_METADATA_UPDATE flag in AVPacket but there isn't any information in internet about what this value is for and how to use this value

Please help If you have any experience or have any info about this

Regards,

MG

Flash Media Server can add data messages to the beginning of a live video stream. This metadata can contain information about the video, such as title, copyright information, duration of the video, or creation date. Metadata can also contain advertising information or current statistics like sports scores. Any client connecting to the server, even if they connect late, receives the metadata when the live video is played.

The metadata you add is in the form of data keyframes. Each data keyframe can contain multiple data properties, such as a title, height, and width.

Note: Because DVR applications use recorded streams, you do not need to use data keyframes to push metadata to the client. In DVR applications (and in all recorded video applications) the onMetaData() method is called at the beginning of the stream and during events such as seek and pause.





_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Ahsan Saba | 22 Jul 11:21 2014
Picon

Demuxing HLS without decoding the segments

Hi, 

I just started using libavformat and I am trying to receive an HLS stream. I don't want to decode the stream, I
will only be looking at duration and timestamps of select segments to analyse the video segments. 

The problem is that I want libavformat to parse the m3u8 file and give me all the different variants and
segments. So I use the following command to open the m3u8 link which is saved in src_url (from ffmpeg
example codes) 

    if (avformat_open_input(&fmt_ctx, src_url, NULL, NULL) < 0) {
        fprintf(stderr, "Could not open source file %s\n", src_filename);
        exit(1);
    }

It turns out that this is what happens : main -> avformat_open_input -> hls_read_header ->
avformat_find_stream_info and avformat_find_stream_info fails for the very first ts segment it
tries. My understanding is that avformat_find_stream_info tries to decode part of the ts segment and
fails because I am compiling without libx264 (my configure command is given at the end), is that right? 

Is there a way that I can stop libavformat from actually trying to download and read the ts segments. I want
the library to parse m3u8 and give me all the variant segments, then I want my application to decide which
segments to download and demux (not decode). I would think there is a flag somewhere, but I can't seem to
figure it out. Is this even possible to do? I have seen code that demuxes mov to extract only timestamps
without decoding (of course that was not HLS), but I am stuck with the m3u8/mpegts combination. 

Here is my configure command (the extra options are for some other formats that I am also demuxing).

./configure --enable-shared --disable-static --disable-optimizations --disable-mmx
--disable-stripping 
--prefix=/ --libdir=/lib --disable-all  --enable-avformat --enable-avcodec --enable-avutil 
--enable-demuxer=mpegts --enable-protocol=http --enable-protocol=crypto
--enable-protocol=https -
-enable-demuxer=hls --enable-demuxer=mov --enable-demuxer=matroska --enable-demuxer=flv 
--enable-parser=h264 --enable-parser=aac --disable-debug --enable-small --disable-zlib
--disable-bzlib 
--disable-pthreads --disable-symver --disable-runtime-cpudetect

Regards, 
Saba
Ankush | 22 Jul 07:41 2014
Picon

Packet reading issue after seeking



i am using ffmpeg in my application, everything so far is working fine
except when i flush the buffer after seeking, my av_read_frame function
cant find the video packet for almost 170 attempts which dosent alow the
playing to work real time.
is there any way i can find video packets quicker after a av_seek_frame
and then avcodec_flush_buffers.

Thank you
_______________________________________________
Libav-user mailing list
Libav-user@...
http://ffmpeg.org/mailman/listinfo/libav-user
Anthony Clark | 21 Jul 21:36 2014
Picon

MPEG2TS data stream

Hey all,

I'm interested in muxing a video stream AND a binary data stream into an mpegts context. The result would be something I could send via ffmpeg's RTP layer or to a container. I just have no idea where to start with the various libraries for creating a new 'raw' stream. I am familiar with the basics of muxing/demuxing/encoding/decoding with the ffmpeg libav* libraries but the mpegts interface is a little crazy. Any help/examples/or advice is very appreciated. 

--
Anthony Clark

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

Gmane