[FFmpeg-user] 2-pass ENcoding with mpeg (switching from mencoder)

Francois Visagie francois.visagie at gmail.com
Thu Aug 8 09:51:33 CEST 2013


> -----Original Message-----
> From: ffmpeg-user-bounces at ffmpeg.org [mailto:ffmpeg-user-
> bounces at ffmpeg.org] On Behalf Of James Board
> Sent: 08 August 2013 03:26
> To: FFmpeg user questions
> Subject: Re: [FFmpeg-user] 2-pass ENcoding with mpeg (switching from
> mencoder)
> 
> >> What would be an example for doing 2-pass encoding, with the libx264
> 
> >> codec, at a video rate of 10 million bits per second, and merely copy
> >> the audio from input file to output file, and using an mp4 format?
> >
> >ffmpeg -y -i INPUT -an -c:v libx264 -preset veryslow -fastfirstpass 1
> >-f rawvideo -b:v 10000000 -pass 1 NUL ffmpeg -y -I INPUT -c:a copy -c:v
> >libx264 -preset veryslow -b:v 10000000 -pass 2 OUTPUT.mp4
> 
> I tried your commands to do 2-pass encoding with ffmpeg.  The input file
was
> a short 6 second video clip.  Both commands and their output are listed
> below.  The first command seemed seemed okay, but the second command
> failed.
> 
> 
> > ffmpeg -y -i IN.avi -an -c:v libx264 -preset veryslow -fastfirstpass 1
> > -f rawvideo -b:v 10000000 -pass 1 NUL

NUL refers to the null device on Windows. However, earlier in this thread I
seem to recall that you used /dev/null or something to that effect, which
indicates that you use Unix/Linux? I.e. replace NUL in my example command
line as appropriate.

> ffmpeg version N-54733-gab5f581 Copyright (c) 2000-2013 the FFmpeg
> developers
>   configuration: --enable-libfreetype --enable-gpl --enable-libx264
>   libavutil      52. 39.100 / 52. 39.100
>   libavcodec     55. 18.102 / 55. 18.102
>   libavformat    55. 12.102 / 55. 12.102
>   libavdevice    55.  3.100 / 55.  3.100
>   libavfilter     3. 80.101 /  3. 80.101
>   libswscale      2.  3.100 /  2.  3.100
>   libswresample   0. 17.102 /  0. 17.102
>   libpostproc    52.  3.100 / 52.  3.100 [avi @ 0x2645b00] Stream #0: not
enough
> frames to estimate rate; consider increasing probesize [avi @ 0x2645b00]

With such warnings I'd regard any results as suspicious/unreliable - use a
longer test clip.

> Stream #1: not enough frames to estimate rate; consider increasing
> probesize

Ditto

> Guessed Channel Layout for  Input Stream #0.1 : stereo Input #0,
> avi, from 'IN.avi':
>   Duration: 00:00:05.74, start: 0.000000, bitrate: 997780 kb/s
>     Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080,
> 29.97 tbr, 29.97 tbn, 29.97 tbc
>     Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo,
> s16, 1536 kb/s No pixel format specified, yuv422p for H.264 encoding
chosen.
> Use -pix_fmt yuv420p for compatibility with outdated media players.
> [libx264 @ 0x2649ee0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
> [libx264 @ 0x2649ee0] profile High 4:2:2, level 4.0, 4:2:2 8-bit Output
#0,
> rawvideo, to 'NUL':
>   Metadata:
>     encoder         : Lavf55.12.102
>     Stream #0:0: Video: h264 (libx264), yuv422p, 1920x1080, q=-1--1, pass
1,
> 10000 kb/s, 90k tbn, 29.97 tbc Stream mapping:
>   Stream #0:0 -> #0:0 (rawvideo -> libx264) Press [q] to stop, [?] for
help
> frame=  172 fps= 23 q=-1.0 Lsize=    7709kB time=00:00:05.67
> bitrate=11133.7kbits/s video:7709kB audio:0kB subtitle:0 global
headers:0kB
> muxing overhead 0.000000%
> [libx264 @ 0x2649ee0] frame I:2     Avg QP:11.39  size:300209
> [libx264 @ 0x2649ee0] frame P:39    Avg QP:18.47  size: 83146
> [libx264 @ 0x2649ee0] frame B:131   Avg QP:19.79  size: 30925
> [libx264 @ 0x2649ee0] consecutive B-frames:  1.2%  0.0% 14.0% 41.9% 20.3%
> 17.4%  0.0%  0.0%  5.2%
> [libx264 @ 0x2649ee0] mb I  I16..4: 25.5%  0.0% 74.5%
> [libx264 @ 0x2649ee0] mb P  I16..4: 39.8%  0.0%  0.0%  P16..4:
> 50.6%  0.0%  0.0%  0.0%  0.0%    skip: 9.6%
> [libx264 @ 0x2649ee0] mb B  I16..4:  6.3%  0.0%  0.0%  B16..8:
> 37.7%  0.0%  0.0%  direct:19.8%  skip:36.2%  L0:38.2% L1:41.8% BI:20.0%
> [libx264 @ 0x2649ee0] final ratefactor: 17.47
> [libx264 @ 0x2649ee0] direct mvs  spatial:90.1% temporal:9.9%
> [libx264 @ 0x2649ee0] coded y,uvDC,uvAC intra: 37.2% 72.0% 37.1% inter:
> 17.7% 33.7% 2.2%
> [libx264 @ 0x2649ee0] i16 v,h,dc,p: 29% 42% 19% 10%
> [libx264 @ 0x2649ee0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 27%
> 10%  6%  6%  7%  5%  7%  5%
> [libx264 @ 0x2649ee0] i8c dc,h,v,p: 42% 25% 24%  9%
> [libx264 @ 0x2649ee0] Weighted P-Frames: Y:2.6% UV:2.6%
> [libx264 @ 0x2649ee0] kb/s:11004.23
> 
> 
> > ffmpeg -y -i IN.avi -c:a copy -c:v libx264 -preset veryslow -b:v
> > 10000000 -pass 2 OUT.mp4
> ffmpeg version N-54733-gab5f581 Copyright (c) 2000-2013 the FFmpeg
> developers
>   configuration: --enable-libfreetype --enable-gpl --enable-libx264
>   libavutil      52. 39.100 / 52. 39.100
>   libavcodec     55. 18.102 / 55. 18.102
>   libavformat    55. 12.102 / 55. 12.102
>   libavdevice    55.  3.100 / 55.  3.100
>   libavfilter     3. 80.101 /  3. 80.101
>   libswscale      2.  3.100 /  2.  3.100
>   libswresample   0. 17.102 /  0. 17.102
>   libpostproc    52.  3.100 / 52.  3.100 [avi @ 0x1b2a9c0] Stream #0: not
enough
> frames to estimate rate; consider increasing probesize [avi @ 0x1b2a9c0]
> Stream #1: not enough frames to estimate rate; consider increasing
> probesize Guessed Channel Layout for  Input Stream #0.1 : stereo Input #0,
> avi, from 'IN.avi':
>   Duration: 00:00:05.74, start: 0.000000, bitrate: 997780 kb/s
>     Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080,
> 29.97 tbr, 29.97 tbn, 29.97 tbc
>     Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo,
> s16, 1536 kb/s No pixel format specified, yuv422p for H.264 encoding
chosen.
> Use -pix_fmt yuv420p for compatibility with outdated media players.
> [libx264 @ 0x1b2edc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
> [libx264 @ 0x1b2edc0] profile High 4:2:2, level 5.1, 4:2:2 8-bit
> [libx264 @ 0x1b2edc0] 264 - core 135 r2345 f0c1c53 - H.264/MPEG-4 AVC
> codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options:
> cabac=1
> ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=10 psy=1
> psy_rd=1.00:0.00
> mixed_ref=1 me_range=24 chroma_me=1 trellis=2 8x8dct=1 cqm=0
> deadzone=21,11
> fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3
> sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
> constrained_intra=0 bframes=8 b_pyramid=2 b_adapt=2 b_bias=0 direct=3
> weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
> intra_refresh=0 rc_lookahead=60 rc=2pass mbtree=1 bitrate=10000
> ratetol=1.0
> qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5
> ip_ratio=1.40
> aq=1:1.00
> [mp4 @ 0x1b2e500] Tag [1][0][0][0]/0x00000001 incompatible with output
> codec id '65536' ([0][0][0][0]) output #0, mp4, to 'OUT.mp4':

See below.

>     Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p,
> 1920x1080, q=-1--1, pass 2, 10000 kb/s, 90k tbn, 29.97 tbc
>     Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo,
> 1536 kb/s Stream mapping:
>   Stream #0:0 -> #0:0 (rawvideo -> libx264)
>   Stream #0:1 -> #0:1 (copy)
> Could not write header for output file #0 (incorrect codec parameters ?):

I stand to be corrected, but I'd suspect that this is related to the message
above, and if so, that the cause might be the PCM audio you're trying to
pack into an MP4 container. I'm not sure if that's supported. See what
happens with '-c:a copy' removed from both command lines; that will
implicitly enable AAC encoding for the MP4 container.

> Invalid data found when processing input
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user



More information about the ffmpeg-user mailing list