Opened 9 years ago

Last modified 8 years ago

#4865 new defect

Using .mp4-files/libh264 with API Examples

Reported by: jepsen Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: libx264
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I just downloaded the source and compiled it on my Ubuntu machine. I wanted to a look at the API part of FFmpeg. When I run the example transcoding.c on a .mp4-file, encoded with h264, it gives the following error:
[libx264 @ 0xa2c5840] broken ffmpeg default settings detected
[libx264 @ 0xa2c5840] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0xa2c5840] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0xa2c5840] speed presets are listed in x264 --help
[libx264 @ 0xa2c5840] profile is optional; x264 defaults to high
Cannot open video encoder for stream #0
Error occurred: Generic error in an external library

I figured that the preset options for h264 were not set, so I looked at the decoding_encoding.c example which sets the preset like so:

if (codec_id == AV_CODEC_ID_H264) {

av_opt_set(c->priv_data, "preset", "slow", 0);

}

I copied that code to transcoding.c, but it had no effect. Surprisingly, when you remove these three lines from the decoding_encoding.c example, it has no effect either, because you can still use the example on .mp4-files, without getting the same error above, which is what I would expect.

I can reproduce this problem on Ubuntu and Windows 7, with the newest FFmpeg version and version 2.7.2. And I only get this problem when using the API functions. The console application ffmpeg works as it should.

Attachments (1)

WildO.mp4 (2.3 MB ) - added by jepsen 9 years ago.
Test .mp4-file

Change History (4)

comment:1 by Carl Eugen Hoyos, 9 years ago

Keywords: libx264 added; API MP4 transcoding H264 preset removed

How - exactly - can I reproduce the issue?

by jepsen, 9 years ago

Attachment: WildO.mp4 added

Test .mp4-file

comment:2 by jepsen, 9 years ago

For Ubuntu:

  1. Download the FFmpeg source code.
  2. Configure with --enable-gpl --enable-version3 --enable-libx264 --enable-libvo-aacenc
  3. run make && make examples
  4. cd to doc/examples
  5. run ./transcoding WildO.mp4 Wildh.mp4

WildO.mp4 is the file in the attachment.

For Windows 7:

  1. Download the Shared and Dev builds from Zeranoe
  2. Set up your windows installation
  3. cd to doc/examples and compile the examples with your preferred compiler
  4. run transcoding.exe WildO.mp4 Wildh.mp4

Those are the general steps that I took. If you have any further questions, please don't hesitate to ask.

Last edited 9 years ago by jepsen (previous) (diff)

comment:3 by Darko Jurić, 8 years ago

I had to add the following:

encoder = avcodec_find_encoder(dec_ctx->codec_id);
out_stream->codec = avcodec_alloc_context3(encoder); this line
enc_ctx = out_stream->codec;

h264 preset options are optional

Note: See TracTickets for help on using tickets.