Opened 9 years ago
Last modified 9 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)
Change History (4)
comment:1 by , 9 years ago
Keywords: | libx264 added; API MP4 transcoding H264 preset removed |
---|
comment:2 by , 9 years ago
For Ubuntu:
- Download the FFmpeg source code.
- Configure with --enable-gpl --enable-version3 --enable-libx264 --enable-libvo-aacenc
- run make && make examples
- cd to doc/examples
- run ./transcoding WildO.mp4 Wildh.mp4
WildO.mp4 is the file in the attachment.
For Windows 7:
- Download the Shared and Dev builds from Zeranoe
- Set up your windows installation
- cd to doc/examples and compile the examples with your preferred compiler
- 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.
comment:3 by , 9 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
How - exactly - can I reproduce the issue?