Opened 11 years ago

Closed 10 years ago

#2042 closed defect (fixed)

av_find_best_stream fails to find best stream for included file

Reported by: DonMoir Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

http://sms.pangolin.com/temp/av_find_best_stream_fails.ts

The above file has 9 streams and 4 programs.

All the video streams have AVCodecContext.bit_rate set to zero.

So if you use av_find_best_stream to find the video stream it returns 0 which is the worst stream. The 0 stream has a related audio stream which has a sample_rate of 0.

For this file, if you first find the best audio stream and then find the related video file it works as expected finding a descent audio and video stream.

Typically I don't use av_find_best_stream but I noticed that it had changed so ran some test on it.

Probably when a file has programs, av_find_best_stream needs to look thru the programs and analyze the streams for both audio and video independent of the type passed to av_find_best_stream to find the actual best stream.

Appears to be a cut file but represents a case that can probably happen.

ffplay av_find_best_stream_fails.ts
ffplay version N-47062-g26c531c Copyright (c) 2003-2012 the FFmpeg developers

built on Nov 25 2012 12:23:20 with gcc 4.7.2 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3

--disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib
--enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb

--enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut
--enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger
--enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc
--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264
--enable-libxavs --enable-libxvid --enable-zlib

libavutil 52. 9.100 / 52. 9.100
libavcodec 54. 77.100 / 54. 77.100
libavformat 54. 37.100 / 54. 37.100
libavdevice 54. 3.100 / 54. 3.100
libavfilter 3. 23.102 / 3. 23.102
libswscale 2. 1.102 / 2. 1.102
libswresample 0. 17.101 / 0. 17.101
libpostproc 52. 2.100 / 52. 2.100

[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011b5240] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 1 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011b5240] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 2 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 1 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 2 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 2 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 1 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure

Last message repeated 1 times

[mpeg2video @ 011f38c0] mpeg_decode_postinit() failure
[mpeg2video @ 01184b20] mpeg_decode_postinit() failure
[mpegts @ 011608e0] Stream #1: not enough frames to estimate rate; consider incr
easing probesize
[mpegts @ 011608e0] Stream #8: not enough frames to estimate rate; consider incr
easing probesize
[mpegts @ 011608e0] Could not find codec parameters for stream 1 (Audio: ac3 (AC
-3 / 0x332D4341), 0 channels, s16): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 011608e0] Could not find codec parameters for stream 8 (Audio: ac3 (AC
-3 / 0x332D4341), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[NULL @ 0118aae0] start time is not set in estimate_timings_from_pts
[NULL @ 0120f8a0] start time is not set in estimate_timings_from_pts
[mpegts @ 011608e0] PES packet size mismatch

Last message repeated 2 times

Input #0, mpegts, from 'd:\flashfiles\movies\av_find_best_stream_fails.ts':

Duration: 00:00:09.11, start: 63323.810800, bitrate: 18418 kb/s
Program 2

Stream #0:5[0x21]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p

, 704x480 [SAR 10:11 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc

Stream #0:6[0x24]( ): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s1

6, 192 kb/s

Stream #0:7[0x25](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s1

6, 192 kb/s

Program 3

Stream #0:4[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p

, 704x480 [SAR 10:11 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc

Stream #0:8[0x34]( ): Audio: ac3 (AC-3 / 0x332D4341), 0 channels

Program 4

Stream #0:0[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p

, 704x480 [SAR 10:11 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc

Stream #0:1[0x164](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels, s16

Program 6

Stream #0:3[0x61]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p

, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc

Stream #0:2[0x64](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side),

s16, 384 kb/s

Invalid sample rate or channel count!
Frame changed from size:0x0 to size:704x480 8KB sq= 0B f=0/0
75431.85 A-V: 0.000 fd= 0 aq= 0KB vq= 11KB sq= 0B f=0/0

Invalid sample rate or channel count is displayed since it chose a video stream that had a related audio stream with sample_rate of zero.

VLC selected the wrong stream as well. WMP and Media Player Classic selected better streams.

Attachments (1)

zero_stream_image.png (40.0 KB ) - added by DonMoir 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Carl Eugen Hoyos, 11 years ago

Is this only reproducible with ffplay, or also with ffmpeg?

comment:2 by DonMoir, 11 years ago

It's going to be reproducible with any program that uses av_find_best_stream to find the best video stream first without doing further analysis. ffmpeg does not use av_find_best_stream.

comment:3 by DonMoir, 11 years ago

The zero stream just has a single image but has multiple frames associated with it which is the stream selected by av_find_best_stream. See attached zero_stream_image.png

The other video streams have regular animated video along with normal audio.

by DonMoir, 11 years ago

Attachment: zero_stream_image.png added

comment:4 by Carl Eugen Hoyos, 10 years ago

Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

Fixed in 6e678528

comment:5 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.