Opened 12 years ago

Closed 11 years ago

#1386 closed defect (fixed)

ffprobe report different widths for some videos

Reported by: Đonny Owned by: stefano
Priority: normal Component: avcodec
Version: unspecified Keywords: coded_width coded_height vp6f avcodec_open2
Cc: zarubaj@rferl.org Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

For some video files ffprobe reports different width on stderr and different to XML/JSON stdout.
Environment: Win7 x64
Command line: ffprobe -print_format json -show_streams -show_format "368×288 00-06 barsandtone.flv"
Output:
d:\UGC testfiles\Video>ffprobe -print_format json -show_streams -show_format "368×288 00-06 barsandtone.flv" -v 9 -loglevel 99
ffprobe version N-41074-g9c27f29 Copyright (c) 2007-2012 the FFmpeg developers

built on May 27 2012 13:25:48 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass

--enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libope

njpeg --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 51. 55.100 / 51. 55.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.101 / 54. 6.101
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100

{[flv @ 0000000001e4ee60] Format flv probed with size=2048 and score=100
[flv @ 0000000001e4ee60] File position before avformat_find_stream_info() is 13
[flv @ 0000000001e4ee60] max_analyze_duration 5000000 reached at 5018000
[flv @ 0000000001e4ee60] File position after avformat_find_stream_info() is 70722
Input #0, flv, from '368├Ś288 00-06 barsandtone.flv':

Metadata:

audiodelay : 0
canSeekToEnd : true

Duration: 00:00:06.00, start: 0.000000, bitrate: 118 kb/s

Stream #0:0, 1, 1/1000: Video: vp6f, yuv420p, 360x288, 1/1000, 409 kb/s, 1k tbr, 1k tbn, 1k tbc
Stream #0:1, 195, 1/1000: Audio: mp3, 44100 Hz, stereo, s16, 96 kb/s

"streams": [

{

"index": 0,
"codec_name": "vp6f",
"codec_long_name": "On2 VP6 (Flash version)",
"codec_type": "video",
"codec_time_base": "1/1000",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"width": 368,
"height": 288,
"has_b_frames": 0,
"pix_fmt": "yuv420p",
"level": -99,
"r_frame_rate": "1000/1",
"avg_frame_rate": "0/0",
"time_base": "1/1000",
"start_time": "0.038000",
"bit_rate": "409600"

},
{

"index": 1,
"codec_name": "mp3",
"codec_long_name": "MP3 (MPEG audio layer 3)",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"sample_fmt": "s16",
"sample_rate": "44100",
"channels": 2,
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/1000",
"start_time": "0.000000",
"bit_rate": "96000"

}

],
"format": {

"filename": "368├Ś288 00-06 barsandtone.flv",
"nb_streams": 2,
"format_name": "flv",
"format_long_name": "FLV format",
"start_time": "0.000000",
"duration": "6.000000",
"size": "88722",
"bit_rate": "118296",
"tags": {

"audiodelay": "0",
"canSeekToEnd": "true"

}

}

}
================================================================

See - 360x288 vs. "width": 368, "height": 288

Attachments (1)

FLV 368×288.flv (86.6 KB ) - added by Đonny 12 years ago.
FLV 360x288 409 kb/s vp6f + mp3. This file causes ffprobe to detect two different widths: 360 on stderr and 368 in JSON/XML

Download all attachments as: .zip

Change History (5)

by Đonny, 12 years ago

Attachment: FLV 368×288.flv added

FLV 360x288 409 kb/s vp6f + mp3. This file causes ffprobe to detect two different widths: 360 on stderr and 368 in JSON/XML

comment:1 by Stefano Sabatini, 12 years ago

Analyzed by developer: set
Reproduced by developer: set
Status: newopen

av_dump_format() prints the information stored in the codec context.

ffprobe opens the codec (avcodec_open2), and sets width/height depending on the coded_width/height:

    if(avctx->coded_width && avctx->coded_height)
        avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
    else if(avctx->width && avctx->height)
        avcodec_set_dimensions(avctx, avctx->width, avctx->height);
    }

according to commit 21adafec2a42d5575ff0a36a028849a9b886c055.

ffprobe -show_frames shows a size of 360x288, so av_dump_format() seems right in this regard.

Last edited 11 years ago by Stefano Sabatini (previous) (diff)

comment:2 by DonMoir, 11 years ago

Before you call avcodec_open the AVCodecContext width and height are correct. After you call avcodec_open either the width or height of the AVCodecContext can be off by 8. With FLV 368x288.flv its the width. With the files from tickets #2268 and #465 its the height.

comment:3 by Stefano Sabatini, 11 years ago

See also sample in ticket #2268.

comment:4 by Stefano Sabatini, 11 years ago

Component: FFprobeavcodec
Keywords: coded_width coded_height vp6f avcodec_open2 added; height site XML JSON removed
Resolution: fixed
Status: openclosed

Should be fixed in:

commit 33b054986767a76bff64fe3091cca2eea07c27de
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Mon Mar 18 23:17:55 2013 +0100

    lavc/utils: add VP6F hack for setting correct video size in stream
    
    For some obscure reasons avcodec_set_dimensions() resets the width/height
    so that the resulting value set in the stream is equal to the
    corresponding coded_width/height, which is not the same as the correct
    width/height in case of the H.264 and VP6F codecs.
    
    This adds a codec-specific hack for VP6F which disables the call to
    avcodec_set_dimensions() in avcodec_open2(), like it is done with H264. A
    proper fix needs to be found yet.
    
    Fix trac ticket #1386.
    
    Based on a patch by Michael Niedermayer.
    
    Trolled-By: Daemon404
    
    See thread:
    Subject: [FFmpeg-devel] [PATCH] ffprobe: Stash and use width and height before opening the codec
    Date: Fri,  1 Mar 2013 10:41:34 -0500
Note: See TracTickets for help on using tickets.