[FFmpeg-devel] decoding packets

aviad rozenhek aviadr1
Sun Sep 30 19:08:31 CEST 2007


Hi,

I have H264/AVC1 packets which I read from a file, and I want to decode them
using ffmpeg, but unfortunately *avcodec_decode_video* always returns -1 for
me.
if I use avformat to read the file and initialize the codecs, I am able to
decode the video.

so I have two methods
1) reading the file on my own, setting up AVCodecContext on my own - this
doesn't work.
2) reading the file and setting up AVCodecContext using avformat, ala
ffplay.c - this works.

solving this problem will enable me to glue the live555 RTSP streaming
library with ffmpeg, combining the strengths of both the libraries,
so I really need method (1) to work.

since the buffer I am giving avcodec to decode is the same in both methods,
I am assuming the problem is
in the initialization of the AVCodecContext strucutre. here is the dump of
the structure for method #2:

bit_rate : 0
bit_rate_tolerance : 4000000
flags : 0
sub_id : 0
me_method : 5
extradata: AU1AM//hABMnTUAzqRgoP2ANQYBBjCte98BAAQAEKM4JiA==
extradata_size: 34
time_base: 0.000333667
width: 320
height: 240
gop_size: 12
pix_fmt: 0 yuv420p
rate_emu: 0
draw_horiz_band: 00000000
sample_rate: 0
channels: 0
sample_fmt: 1
frame_size: 0
frame_number: 0
real_pict_num: 0
delay: 0
qcompress: 0.5
qblur: 0.5
qmin: 2
qmax: 31
max_qdiff: 3
max_b_frames: 0
b_quant_factor: 1.25
rc_strategy: 0
b_frame_strategy: 0
hurry_up: 0
codec->name: h264
codec->capabilities: 42
codec->pix_fmts : 00000000
codec->supported_framerates: 00000000
priv_data: 025C0A40
rtp_mode: 0
rtp_payload_size: 0
rtp_callback: 00000000
mv_bits: 0
header_bits: 0
i_tex_bits: 0
p_tex_bits: 0
i_count: 0
p_count: 0
skip_count: 0
misc_bits: 0
frame_bits: 0
opaque: 00000000
codec_name: H.264
codec_type: 0
codec_id: 28
codec_tag: 828601953
workaround_bugs: 1
luma_elim_threshold: 0
chroma_elim_threshold: 0
strict_std_compliance: 0
b_quant_offset: 1.25
error_resilience: 1
get_buffer: 01042DD0
release_buffer: 01041940
has_b_frames: 0
block_align: 0
parse_only: 0
mpeg_quant: 0
stats_out: NULL
stats_in: NULL
rc_qsquish: 0
rc_qmod_amp: 0
rc_qmod_freq: 0
rc_override: 00000000
rc_override_count: 0
rc_eq: tex^qComp
rc_max_rate: 0
rc_min_rate: 0
rc_buffer_size: 0
rc_buffer_aggressivity: 1
i_quant_factor: -0.8
i_quant_offset: 0
rc_initial_cplx: 0
dct_algo: 0
lumi_masking: 0
temporal_cplx_masking: 0
spatial_cplx_masking: 0
p_masking: 0
dark_masking: 0
unused: 0
idct_algo: 0
slice_count: 0
slice_offset: error_concealment: 3
dsp_mask: 0
bits_per_sample: 24
prediction_method: 0
sample_aspect_ratio: 0
coded_frame: 00000000
debug: 0
debug_mv: 0
error: 0000
mb_qmin: 0
mb_qmax: 0
me_cmp: 0
me_sub_cmp: 0
mb_cmp: 0
ildct_cmp: 8
dia_size: 0
last_predictor_count: 0
pre_me: 0
me_pre_cmp: 0
pre_dia_size: 0
me_subpel_quality: 8
get_format: 01041A50
dtg_active_format: 0
me_range: 0
intra_quant_bias: 999999
inter_quant_bias: 999999
color_table_id: 65535
internal_buffer_count: 0
internal_buffer: 00000000
global_quality: 0
coder_type: 0
context_model: 0
slice_flags: 0
xvmc_acceleration: 0
mb_decision: 0
intra_matrix: 00000000
inter_matrix: 00000000
stream_codec_tag: 0
scenechange_threshold: 0
lmin: 236
lmax: 3658
palctrl: 00000000
noise_reduction: 0
reget_buffer: 01042200
rc_initial_buffer_occupancy: 0
inter_threshold: 0
flags2: 256
error_rate: 0
antialias_algo: 0
quantizer_noise_shaping: 0
thread_count: 1
execute: 010419E0
thread_opaque: 00000000
me_threshold: 0
mb_threshold: 0
intra_dc_precision: 0
nsse_weight: 8
skip_top: 0
skip_bottom: 0
profile: -99
level: -99
lowres: 0
coded_width: 320
coded_height: 240
frame_skip_threshold: 0
frame_skip_factor: 0
frame_skip_exp: 0
frame_skip_cmp: 13
border_masking: 0
mb_lmin: 236
mb_lmax: 3658
me_penalty_compensation: 256
skip_loop_filter: 0
skip_idct: 0
skip_frame: 0
bidir_refine: 0
brd_scale: 0
crf: 0
cqp: -1
keyint_min: 25
refs: 1
chromaoffset: 0
bframebias: 0
trellis: 0
complexityblur: 20
deblockalpha: 0
deblockbeta: 0
partitions: 0
directpred: 2
cutoff: 0
scenechange_factor: 6
mv0_threshold: 256
b_sensitivity: 40
compression_level: -1
use_lpc: -1
lpc_coeff_precision: 0
min_prediction_order: -1
max_prediction_order: -1
prediction_order_method: -1
min_partition_order: -1
max_partition_order: -1
timecode_frame_start: 0


below is the dump of the AVCodecContext from method #1 (but showing only
differing fields):

extradata: AE0AMwMBABMnTUAzqRgoP2ANQYBBjCte98BAAQAEKM4JiA==
codec_name:
priv_data: 00AEEC40
debug: -1
color_table_id: 0
use_lpc: 0
min_prediction_order: 0
max_prediction_order: 0
prediction_order_method: 0
min_partition_order: 0
max_partition_order: 0
timecode_frame_start: 0


the difference in extradata is due to my reserved bits (according to
http://haali.cs.msu.ru/mkv/codecs.pdf ) are set to 0.

I am specially suspicious of the "priv_data" and "color_table_id" fields
since I don't have any code setting these up in method #1.
can someone help me?
am I looking in the right places?
do I need to set the color_table_id with some color table?
is it normal for the codec_name not being set even though I call
avcodec_open ?

thanks
Aviad Rozenhek




More information about the ffmpeg-devel mailing list