2012-03-24 11 views
0

Ich versuche, ein Video nur FLV-Datei zu erzeugen, verwende ich:Encoding Video nur FLV

  1. libx264 + ffmpeg
  2. 30 fps (fest)
  3. Wiedergabe erfolgt mit VLC 2.0.1 und Animationen

Wenn die FLV spielen die Frame-Rate scheint ~ 1 Bild pro Sekunde, finden Sie die Art, wie ich cfg ffmpeg:

AVOutputFormat* fmtOutput = av_oformat_next(0); 
while((0 != fmtOutput) && (0 != strcmp(fmtOutput->name, "flv"))) 
    fmtOutput = av_oformat_next(fmtOutput); 
m_pFmtCtxOutput   = avformat_alloc_context(); 
m_pFmtCtxOutput->oformat = fmtOutput; 

AVStream* pOutVideoStream= av_new_stream(m_pFmtCtxOutput, pInVideoStream->id); 
AVCodec* videoEncoder = avcodec_find_encoder(CODEC_ID_H264); 

pOutVideoStream->codec->width = 640; 
pOutVideoStream->codec->height = 480; 
pOutVideoStream->codec->level = 30; 
pOutVideoStream->codec->pix_fmt = PIX_FMT_YUV420P; 
pOutVideoStream->codec->bit_rate = 3000000; 

pOutVideoStream->cur_dts   = 0; 
pOutVideoStream->first_dts  = 0; 
pOutVideoStream->index   = 0; 
pOutVideoStream->avg_frame_rate = (AVRational){ 30, 1 }; 
pOutVideoStream->time_base  = 
pOutVideoStream->codec->time_base= (AVRational){ 1, 30000 }; 
pOutVideoStream->codec->gop_size = 30; 
%% Some specific libx264 settings %% 
m_dVideoStep      = 1000;// packet dts/pts is incremented by this amount each frame 

pOutVideoStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; 
avcodec_open(pOutVideoStream->codec, videoEncoder); 

Die resultierende Datei scheint OK, mit Ausnahme der Wiedergabe-Bildrate.
im Sinn hat, daß:

  1. pOutVideoStream-> avg_frame_rate = (AVRational) {30, 1};
  2. pOutVideoStream-> time_base = (AVRational) {1, 30000};
  3. pOutVideoStream-> codec-> time_base = (AVRational) {1, 30000};
  4. Für jeden Rahmen I von 1000 die dts/pts erhöhen

Was mache ich hier falsch? Warum spielt die Datei abgehackt (~ 1 fps)?

Jede Hilfe wird geschätzt.

Nadav bei Sophin

Antwort

0

mit einem Debugger die FLV muxer Code schrittweise durch, ich habe die ffmpeg Umsetzung gefunden PTS einer Auflösung kein anderer als msec zu unterstützen, das heißt, mit time_base = (AVRational) {1, 1000}.

Außerdem muss 'AVStream :: r_frame_rate' gesetzt sein, damit der FLV-Muxer die Bildrate korrekt auflöst.

+0

1/1000 ist eine Einschränkung des FLV-Formats. – szatmary