[Libav-user] asf (.wmv) muxer problem : duration is not good !

Stephane Debusne stephane.debusne at gmail.com
Fri Sep 28 14:01:56 CEST 2012


Hi all,

i'm developing a graphical application using libav libraries. The 
application typically takes one MJPEG avi file and a wav file as input 
and output a muxed video file.
I Know that ffmpeg.exe does it well but i have to do it inside my 
application, without a call to ffmpeg.exe, so i use the libav librairies.

A lot of things are working well and i can output avi files, or mov 
files, with different codec.
I can also output .wmv movies with AV_CODEC_ID_MSMPEG4V3 as video codec 
and CODEC_ID_MWAV2 as audio codec, but in that case, the video duration 
is not good. Typically, 50 dummy images are added and so the duration is 
2s too long.
If i remove the audio stream, then the duration is ok. So the audio 
stream seems to be involved in that problem.

Before calling av_write_trailer(), the data in the video and audio 
streams seems to be good. As an example, i've got a video with :
video stream : pts: val = 12760 num=12 den =25  ; nb frames = 319
audio stream : pts: val=12800 num=24000 den=48000 ; nb frames = 299

but after writing the trailer, if i close and reopen the file, the 
duration read by avlibs is 14805. not 12800...
However, the movie plays well and it plays only for 12.8 seconds.

If i do exactly the same thing, but in a avi file instead of a wmv file 
(so the muxer is not the same), movie duration is ok.

==> I really think this is due to asf muxer, but can see why and where. 
I think it can be solved because ffmpeg.exe has not this problem, so i 
probably missed something somewhere.
My intuition is that it is linked to time_base that is set to 1/1000 in 
asf files.

Just for more information : before sending images or sound to the 
encoders, i set frame->pts to AV_NOPTS_VALUE to let the encoders set up 
corrects pts. maybe i have to set pts to correct values (such as for the 
H264 encoder) but i tried and did not get correct results...


Have you ever heard about this problem ? Any suggestions ?


Thanks for any help
regards
Stephane



More information about the Libav-user mailing list