doc/examples/transcoding is not able to reencode with libx264.
Please help to teach it to do so.

This script reproduces the issue in automated fashion:
https://gist.github.com/andrey-utkin/925ce227b2b530d1e808
(ffmpeg.issue.sh attached).

The script applies one patch to the example program. The patch addresses
a bit different issue but is required to proceed with this usecase.
(7e12ed3c07e38d49b3aa025897a222a92fbaf3a5.patch attached.)

JEEB on IRC asked to try both static and shared builds, so the script
builds and runs both.

Here you can see what actually happens (what is the problem):
https://gist.github.com/andrey-utkin/c72034b68f7950101dbc
https://gist.github.com/andrey-utkin/9994afa6dd26627cee50 (to prove that
input pixel format doesn't change anything).

Quoting actual output exposing the problem here. See "broken ffmpeg
default settings detected".


 $ for x in /tmp/ffmpeg.{static,shared}
> do
>     pushd $x
>     export LD_LIBRARY_PATH="$x/lib"
>     ./bin/ffmpeg -f lavfi -i testsrc -t 1 -c:v libx264 -y test.mkv
>     ./transcoding test.mkv out.mkv || true # this fails
>     popd
> done
/tmp/ffmpeg.static /tmp
ffmpeg version N-78232-g9962718 Copyright (c) 2000-2016 the FFmpeg
developers
  built with gcc 5.3.0 (Gentoo 5.3.0 p1.0, pie-0.6.5)
  configuration: --enable-libx264 --enable-gpl --prefix=/tmp/ffmpeg.static
  libavutil      55. 16.101 / 55. 16.101
  libavcodec     57. 24.101 / 57. 24.101
  libavformat    57. 23.101 / 57. 23.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 27.100 /  6. 27.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240
[SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x35024e0] using SAR=1/1
[libx264 @ 0x35024e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x35024e0] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x35024e0] 264 - core 148 r2665M a01e339 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, matroska, to 'test.mkv':
  Metadata:
    encoder         : Lavf57.23.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p,
320x240 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.24.101 libx264
    Side data:
      unknown side data type 10 (24 bytes)
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-1.0 Lsize=       8kB time=00:00:00.92 bitrate=
74.0kbits/s speed=13.6x
video:7kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 11.975260%
[libx264 @ 0x35024e0] frame I:1     Avg QP:19.50  size:  2846
[libx264 @ 0x35024e0] frame P:9     Avg QP:17.62  size:   346
[libx264 @ 0x35024e0] frame B:15    Avg QP:14.18  size:    64
[libx264 @ 0x35024e0] consecutive B-frames: 20.0%  0.0%  0.0% 80.0%
[libx264 @ 0x35024e0] mb I  I16..4: 31.3% 41.7% 27.0%
[libx264 @ 0x35024e0] mb P  I16..4:  1.2%  2.0%  0.6%  P16..4:  8.6%
3.3%  2.0%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x35024e0] mb B  I16..4:  0.2%  0.1%  0.0%  B16..8:  4.8%
0.1%  0.0%  direct: 0.2%  skip:94.5%  L0:39.7% L1:54.9% BI: 5.4%
[libx264 @ 0x35024e0] 8x8 transform intra:44.1% inter:48.9%
[libx264 @ 0x35024e0] coded y,u,v intra: 12.2% 11.2% 11.0% inter: 0.7%
0.9% 0.8%
[libx264 @ 0x35024e0] i16 v,h,dc,p: 71% 19%  3%  7%
[libx264 @ 0x35024e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 71%  6% 23%  0%  0%
 0%  0%  0%  0%
[libx264 @ 0x35024e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 47% 31% 15%  2%  1%
 1%  0%  2%  0%
[libx264 @ 0x35024e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x35024e0] ref P L0: 63.4%  5.0% 23.5%  8.1%
[libx264 @ 0x35024e0] ref B L0: 73.3% 23.3%  3.5%
[libx264 @ 0x35024e0] ref B L1: 97.8%  2.2%
[libx264 @ 0x35024e0] kb/s:55.28
Input #0, matroska,webm, from 'test.mkv':
  Metadata:
    ENCODER         : Lavf57.23.101
  Duration: 00:00:01.00, start: 0.000000, bitrate: 68 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p, 320x240
[SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      ENCODER         : Lavc57.24.101 libx264
      DURATION        : 00:00:01.000000000
[libx264 @ 0x20b8b40] broken ffmpeg default settings detected
[libx264 @ 0x20b8b40] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x20b8b40] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x20b8b40] speed presets are listed in x264 --help
[libx264 @ 0x20b8b40] profile is optional; x264 defaults to high
Cannot open video encoder for stream #0
Error occurred: Generic error in an external library
/tmp
/tmp/ffmpeg.shared /tmp
ffmpeg version N-78232-g9962718 Copyright (c) 2000-2016 the FFmpeg
developers
  built with gcc 5.3.0 (Gentoo 5.3.0 p1.0, pie-0.6.5)
  configuration: --enable-libx264 --enable-gpl
--prefix=/tmp/ffmpeg.shared --enable-shared
  libavutil      55. 16.101 / 55. 16.101
  libavcodec     57. 24.101 / 57. 24.101
  libavformat    57. 23.101 / 57. 23.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 27.100 /  6. 27.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240
[SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x10394e0] using SAR=1/1
[libx264 @ 0x10394e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x10394e0] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x10394e0] 264 - core 148 r2665M a01e339 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, matroska, to 'test.mkv':
  Metadata:
    encoder         : Lavf57.23.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p,
320x240 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.24.101 libx264
    Side data:
      unknown side data type 10 (24 bytes)
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-1.0 Lsize=       8kB time=00:00:00.92 bitrate=
74.0kbits/s speed=17.1x
video:7kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 11.975260%
[libx264 @ 0x10394e0] frame I:1     Avg QP:19.50  size:  2846
[libx264 @ 0x10394e0] frame P:9     Avg QP:17.62  size:   346
[libx264 @ 0x10394e0] frame B:15    Avg QP:14.18  size:    64
[libx264 @ 0x10394e0] consecutive B-frames: 20.0%  0.0%  0.0% 80.0%
[libx264 @ 0x10394e0] mb I  I16..4: 31.3% 41.7% 27.0%
[libx264 @ 0x10394e0] mb P  I16..4:  1.2%  2.0%  0.6%  P16..4:  8.6%
3.3%  2.0%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x10394e0] mb B  I16..4:  0.2%  0.1%  0.0%  B16..8:  4.8%
0.1%  0.0%  direct: 0.2%  skip:94.5%  L0:39.7% L1:54.9% BI: 5.4%
[libx264 @ 0x10394e0] 8x8 transform intra:44.1% inter:48.9%
[libx264 @ 0x10394e0] coded y,u,v intra: 12.2% 11.2% 11.0% inter: 0.7%
0.9% 0.8%
[libx264 @ 0x10394e0] i16 v,h,dc,p: 71% 19%  3%  7%
[libx264 @ 0x10394e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 71%  6% 23%  0%  0%
 0%  0%  0%  0%
[libx264 @ 0x10394e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 47% 31% 15%  2%  1%
 1%  0%  2%  0%
[libx264 @ 0x10394e0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x10394e0] ref P L0: 63.4%  5.0% 23.5%  8.1%
[libx264 @ 0x10394e0] ref B L0: 73.3% 23.3%  3.5%
[libx264 @ 0x10394e0] ref B L1: 97.8%  2.2%
[libx264 @ 0x10394e0] kb/s:55.28
Input #0, matroska,webm, from 'test.mkv':
  Metadata:
    ENCODER         : Lavf57.23.101
  Duration: 00:00:01.00, start: 0.000000, bitrate: 68 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p, 320x240
[SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      ENCODER         : Lavc57.24.101 libx264
      DURATION        : 00:00:01.000000000
[libx264 @ 0x2701b40] broken ffmpeg default settings detected
[libx264 @ 0x2701b40] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x2701b40] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x2701b40] speed presets are listed in x264 --help
[libx264 @ 0x2701b40] profile is optional; x264 defaults to high
Cannot open video encoder for stream #0
Error occurred: Generic error in an external library

Attachment: ffmpeg.issue.sh
Description: application/shellscript

From 7e12ed3c07e38d49b3aa025897a222a92fbaf3a5 Mon Sep 17 00:00:00 2001
From: Andrey Utkin <andrey.ut...@pb.com>
Date: Mon, 1 Feb 2016 00:54:15 +0200
Subject: [PATCH] doc/example/transcoding: handle case of empty encoder
 AVCodec.pix_fmts

---
 doc/examples/transcoding.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/examples/transcoding.c b/doc/examples/transcoding.c
index d5d410b..15fae4d 100644
--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -129,6 +129,9 @@ static int open_output_file(const char *filename)
                 enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
                 /* take first format from list of supported formats */
                 enc_ctx->pix_fmt = encoder->pix_fmts[0];
+                /* Below condition is true for libx264 */
+                if (enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
+                    enc_ctx->pix_fmt = dec_ctx->pix_fmt;
                 /* video time_base can be set to whatever is handy and supported by encoder */
                 enc_ctx->time_base = dec_ctx->time_base;
             } else {

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to