Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#3508 closed defect (needs_more_info)

Cannot open stats file on second pass when attempting to generate multiple outputs.

Reported by: Ian Kennedy Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

One input, two outputs. Second pass. Stats file cannot be opened. If the operation is broken into two commands run run serially then it works fine.

C:\X264Test>ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_mi
n 6 -vcodec libx264 -b:v 400k -pass 2 -an -f mp4 big_buck_bunny_100.mp4 -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min
6 -vcodec libx264 -b:v 700k -pass 2 -an -f mp4 big_buck_bunny_200.mp4
ffmpeg version N-61914-g657cee1 Copyright (c) 2000-2014 the FFmpeg developers

built on Mar 28 2014 22:02:04 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi

g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopenco
re-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-zlib

libavutil 52. 69.100 / 52. 69.100
libavcodec 55. 55.104 / 55. 55.104
libavformat 55. 36.100 / 55. 36.100
libavdevice 55. 11.100 / 55. 11.100
libavfilter 4. 3.100 / 4. 3.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100

Input #0, avi, from 'big_buck_bunny_720p_stereo.avi':

Metadata:

encoder : MEncoder 2:1.0~rc2-0ubuntu13

Duration: 00:09:56.46, start: 0.000000, bitrate: 3815 kb/s

Stream #0:0: Video: msmpeg4v2 (MP42 / 0x3234504D), yuv420p, 1280x720, 3556 kb/s, 24 tbr, 24 tbn, 24 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 245 kb/s

[libx264 @ 03ffd420] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 03ffd420] profile High, level 1.3
[libx264 @ 03ffd420] 264 - core 142 r2409 d6b4e63 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.or
g/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 m
e_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_thr
eads=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=48 keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=

2pass mbtree=1 bitrate=400 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
[libx264 @ 003c9de0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 003c9de0] ratecontrol_init: can't open stats file
Output #0, mp4, to 'big_buck_bunny_100.mp4':

Metadata:

encoder : MEncoder 2:1.0~rc2-0ubuntu13
Stream #0:0: Video: h264 (libx264), yuv420p, 240x134, q=-1--1, pass 2, 400 kb/s, 90k tbn, 24 tbc

Output #1, mp4, to 'big_buck_bunny_200.mp4':

Metadata:

encoder : MEncoder 2:1.0~rc2-0ubuntu13
Stream #1:0: Video: h264, yuv420p, 320x180, q=-1--1, pass 2, 700 kb/s, 90k tbn, 24 tbc

Stream mapping:

Stream #0:0 -> #0:0 (msmpeg4v2 -> libx264)
Stream #0:0 -> #1:0 (msmpeg4v2 -> libx264)

Error while opening encoder for output stream #1:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Change History (10)

comment:1 by Carl Eugen Hoyos, 11 years ago

Is this only reproducible using an external library or also with -vcodec mpeg4?

comment:2 by Ian Kennedy, 11 years ago

It throws a different error with "-vcodec mpeg4" in that it is looking for a second logfile for the second stream.

If you encode the two streams separately using the single log file then it works...as with x264.

comment:3 by Carl Eugen Hoyos, 11 years ago

I tested the following:
$ ffmpeg -f lavfi -i testsrc -pass 1 -vcodec mpeg4 -t 10 -vb 200k out.avi -t 10 -pass 1 -vb 300k out2.avi
$ ffmpeg -y -f lavfi -i testsrc -pass 2 -vcodec mpeg4 -t 10 -vb 200k out.avi -t 10 -pass 2 -vb 300k out2.avi

Two files with different bitrates are written, what do I miss?

comment:4 by Ian Kennedy, 11 years ago

Second pass generates two files. First pass makes LOG only. What I'm tyring to do is make N outputs on the second pass to facilitate smooth or HLS streaming.

ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 1 -an -f mp4 NUL
ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 2 -an -f mp4 big_buck_bunny_400.mp4 -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 2 -an -f mp4 big_buck_bunny_700.mp4

comment:5 by Carl Eugen Hoyos, 11 years ago

What's wrong with the following?

$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 1 -an -f mp4 NUL -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 1 -an -f mp4 NUL
$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 2 -an -f mp4 big_buck_bunny_400.mp4 -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 2 -an -f mp4 big_buck_bunny_700.mp4

(I don't remember if you are using -vf correctly, in theory, a complex filtergraph might be needed.)
Note that even if your command lines would work (they may work with a cp ffmpeg2pass-0.log ffmpeg2pass-1.log && cp ffmpeg2pass-0.log.mbtree ffmpeg2pass-1.log.mbtree in-between), this is not how two-pass encoding is supposed to be used to the best of my knowledge.

Last edited 11 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  5 comment:6 by Carl Eugen Hoyos, 11 years ago

Replying to cehoyos:

(I don't remember if you are using -vf correctly, in theory, a complex filtergraph might be needed.)

It works fine with two -vf's, see for example:

$ ffmpeg -t 10 -f lavfi -i testsrc=s=hd720 -vf scale=32x32 -qscale 2 out.avi -vf scale=hd1080 -qscale 2 out2.avi

in reply to:  5 ; comment:7 by Carl Eugen Hoyos, 11 years ago

Resolution: needs_more_info
Status: newclosed

Replying to cehoyos:

What's wrong with the following?

$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 1 -an -f mp4 NUL -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 1 -an -f mp4 NUL
$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 2 -an -f mp4 big_buck_bunny_400.mp4 -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 2 -an -f mp4 big_buck_bunny_700.mp4

Note that even if your command lines would work (they may work with a cp ffmpeg2pass-0.log ffmpeg2pass-1.log && cp ffmpeg2pass-0.log.mbtree ffmpeg2pass-1.log.mbtree in-between), this is not how two-pass encoding is supposed to be used to the best of my knowledge.

Please reopen if you believe there is a bug in FFmpeg that can be fixed.

in reply to:  7 comment:8 by Ian Kennedy, 10 years ago

Replying to cehoyos:

Replying to cehoyos:

What's wrong with the following?

$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 1 -an -f mp4 NUL -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 1 -an -f mp4 NUL
$ ffmpeg -y -i big_buck_bunny_720p_stereo.avi -vf scale=240:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 400k -pass 2 -an -f mp4 big_buck_bunny_400.mp4 -vf scale=320:trunc(ow/a/2)*2 -g 48 -keyint_min 6 -vcodec mpeg4 -b:v 700k -pass 2 -an -f mp4 big_buck_bunny_700.mp4

Note that even if your command lines would work (they may work with a cp ffmpeg2pass-0.log ffmpeg2pass-1.log && cp ffmpeg2pass-0.log.mbtree ffmpeg2pass-1.log.mbtree in-between), this is not how two-pass encoding is supposed to be used to the best of my knowledge.

Please reopen if you believe there is a bug in FFmpeg that can be fixed.

That works. Although it defeats the purpose of doing s single PASS1 for N PASS2 items.

I'd note that executing N PASS2 runs separately after a single PASS1 works. Hence my attempt at doing all of the PASS2 encodes in one go. Also, I was hoping that a single log file shared across N PASS2 encodes would enforce GOP structure across streams to enable smoothstreaming/HLS use.

But I think I can work around this.

comment:9 by Carl Eugen Hoyos, 10 years ago

Are you sure that two-pass encoding doesn't require both runs to use the same target bitrate for optimal results?

comment:10 by Office, 8 years ago

IM having this very same issue. I'm very new to FFMPEG so i have no idea where to start looking for a fix. Has this issue been solved or is there a way around it ?

Note: See TracTickets for help on using tickets.