Opened 10 months ago

Closed 7 months ago

#3093 closed defect (fixed)

filtering examples are broken

Reported by: ahsan Owned by:
Priority: important Component: documentation
Version: git-master Keywords: examples
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

Summary of the bug:

I build the filtering_video example code using latest
ffmpeg-20131026-git-c78a416-win32-dev version of ffmpeg on windows 7 platform using Micro Soft Visual Studio 2012.

When i try to use .mpg video stream with this example i get following crash at the "av_frame_free(&frame);" call in main with the message
==============================================================
First-chance exception at 0x52B832F8 (avutil-52.dll) in filtering_video.exe: 0xC0000005: Access violation reading location 0xFEEEFEF2.
==============================================================

Please let me know if there is something else which needs to be performed to avoid this crash for .mpg files

How to reproduce:

% filtering_video.exe Tank_T80U.mpg

ffmpeg version -- ffmpeg-20131026-git-c78a416-win32-dev
built on -- Windows 7 MSVC Express 2012

Please let me know if there is a work around to avoid this memory crash issue?

Attachments (1)

Tank_T80U--.mpg (2.3 MB) - added by ahsan 10 months ago.
mpeg file for memory crash issue with ffpmpeg filtering_video example code

Change History (15)

Changed 10 months ago by ahsan

mpeg file for memory crash issue with ffpmpeg filtering_video example code

comment:1 Changed 10 months ago by cehoyos

  • Resolution set to duplicate
  • Status changed from new to closed

Looks like a duplicate of ticket #3092.

comment:2 follow-up: Changed 10 months ago by ubitux

  • Keywords examples added
  • Priority changed from normal to important
  • Resolution duplicate deleted
  • Status changed from closed to reopened

I don't think so. Those filtering examples are broken because of the half switch to the new frame counting API.

Edit: ah, sorry, I thought the other ticket was about swscale; this ticket looks better, I'd close the other instead.

Last edited 10 months ago by ubitux (previous) (diff)

comment:3 in reply to: ↑ 2 Changed 10 months ago by cehoyos

Replying to ubitux:

Edit: ah, sorry, I thought the other ticket was about swscale; this ticket looks better, I'd close the other instead.

Please do so.

comment:4 Changed 10 months ago by cehoyos

  • Component changed from undetermined to documentation
  • Version changed from unspecified to git-master

comment:5 Changed 10 months ago by ahsan

Both Issue #3092 and 3093 are reproduceable with the files i uploaded with the ticket

From the comment "Those filtering examples are broken because of the half switch to the new frame counting API.", seems like these examples are not working for some cases i was wondering is this issue going to be fixed in the next release?

Is there a version of ffmpeg which does not have this issue, which i can use?

comment:6 Changed 10 months ago by ubitux

The problem is not with the version of FFmpeg but the code of the example which is plain wrong. The idea is that it's mixing both "old" and new reference counted frame API.

See this patch: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-September/147881.html

It provides a (hopefully) working decoding example, and shows how to use both APIs. You can try to look at that code instead until we fix properly our examples.

comment:7 Changed 10 months ago by ahsan

In the link below

http://ffmpeg.org/pipermail/ffmpeg-devel/2013-September/147881.html

I see reference to 2 different files in examples, [doc/examples/decoding.c, decoding_video.c], but in the actual example path of ffmpeg, I do not see any of these files, I see a file "doc/examples/decoding_encoding.c" instead, is this the file Clément is refering?

comment:8 Changed 10 months ago by ubitux

No, that patch was not pushed (yet); maybe I should push it. Just look at the diff.

comment:9 follow-up: Changed 10 months ago by ahsan

I will look into the diff

When do you think you, you will have the fix in filtering_video example code?

comment:10 Changed 10 months ago by ahsan

I merged the changes and it seems to fix the memory crash issue.

Thanks

comment:11 in reply to: ↑ 9 Changed 10 months ago by ubitux

Replying to ahsan:

I will look into the diff

You can now look at http://git.videolan.org/?p=ffmpeg.git;a=blob;f=doc/examples/demuxing_decoding.c;hb=HEAD

The filtering examples will be fixed later, hopefully soon.

comment:12 Changed 10 months ago by ahsan

Hi Ubitux,

I am trying to merge, demux and mux example codes so that i can take in any .mp4/.avi/mpg files and then re-encode them in the same format

I am having following issues

  1. MUX example code uses avformat_alloc_output_context2() to create the output context for example for .mpg it will choose MPEG1 encoder, the .mpg file i used is encoded using MPEG2 encoder. I was wondering how can i select different encoders, is there any API call which i can use to re-set the encoder name in the context encoder fails
  1. I uses the fmt_ctx from decoder to set the encoder parameters, i try to memcpy the context (decoder to encoder for the codec) but it fails by setting the different parameters from fmt_ctx to the c c->width = fmt_ctx->streams[video_stream_idx]->codec->width; c->height = fmt_ctx->streams[video_stream_idx]->codec->height; c->coded_width = fmt_ctx->streams[video_stream_idx]->codec->coded_width; ........................ c->gop_size = fmt_ctx->streams[video_stream_idx]->codec->gop_size;

/* emit one intra frame every twelve frames at most */

c->bit_rate = (fmt_ctx->streams[video_stream_idx]->codec->bit_rate == 0) ? 400000 :

fmt_ctx->streams[video_stream_idx]->codec->bit_rate;
/* i am seting it to 400kbps in case it is set to 0 as i am seeing it

for some stream */

........................

I am seeing different issue

  1. GOP Size fmt_ctx most of the time has gop_size = 12 which does not seems like the case for the stream


  1. bit-rate i am getting in the output .mp4 is way higher then the one i see from the fmt_ctx, it seems like encoded bit-stream is in 50Mbits/sec where as input .mp4 was 300kbps or 400kbps bit-rate

I am wondering what is the best way to set the encoder context using the input bitstream
[.mp4, .avi, .mpg etc] files

Regards
Ahsan

comment:13 follow-up: Changed 9 months ago by ubitux

  • Summary changed from exception at 0x52B832F8 (avutil-52.dll) in filtering_video.exe: 0xC0000005: Access violation reading location 0xFEEEFEF2. to filtering examples are broken

Filtering video should be fixed in 1f7b7d54471711b89f8a64bef1c6636b6aa08c12.

Filtering audio still needs to some adjustments.

Last edited 9 months ago by ubitux (previous) (diff)

comment:14 in reply to: ↑ 13 Changed 7 months ago by saste

  • Analyzed by developer set
  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to ubitux:

Filtering video should be fixed in 1f7b7d54471711b89f8a64bef1c6636b6aa08c12.

Filtering audio still needs to some adjustments.

Should be fixed in latest git.

Note: See TracTickets for help on using tickets.