projects
/
goodguy
/
history.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
drain last partial frame in ffmpeg close encoder
[goodguy/history.git]
/
cinelerra-5.1
/
cinelerra
/
ffmpeg.C
diff --git
a/cinelerra-5.1/cinelerra/ffmpeg.C
b/cinelerra-5.1/cinelerra/ffmpeg.C
index 70ccc272f1d16156a6634c43741f63ab1e7bfb4d..10ad05036ee64b71a5cb8d7e2336434fe2e52108 100644
(file)
--- a/
cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/
cinelerra-5.1/cinelerra/ffmpeg.C
@@
-549,7
+549,7
@@
int FFStream::seek(int64_t no, double rate)
}
}
if( ret < 0 ) {
}
}
if( ret < 0 ) {
-
//
printf("** seek fail %ld, %ld\n", pos, tstmp);
+printf("** seek fail %ld, %ld\n", pos, tstmp);
seeked = need_packet = 0;
st_eof(flushed=1);
return -1;
seeked = need_packet = 0;
st_eof(flushed=1);
return -1;
@@
-721,31
+721,39
@@
int FFAudioStream::encode(double **samples, int len)
if( encode_activate() <= 0 ) return -1;
ffmpeg->flow_ctl();
int ret = 0;
if( encode_activate() <= 0 ) return -1;
ffmpeg->flow_ctl();
int ret = 0;
- int64_t count = load_buffer(samples, len);
+ int64_t count = samples ? load_buffer(samples, len) : used();
+ int frame_sz1 = samples ? frame_sz-1 : 0;
FFrame *frm = 0;
FFrame *frm = 0;
- while( ret >= 0 && count >
= frame_sz
) {
+ while( ret >= 0 && count >
frame_sz1
) {
frm = new FFrame(this);
if( (ret=frm->initted()) < 0 ) break;
AVFrame *frame = *frm;
frm = new FFrame(this);
if( (ret=frm->initted()) < 0 ) break;
AVFrame *frame = *frm;
- float *bfrp = get_outp(frame_sz);
+ len = count >= frame_sz ? frame_sz : count;
+ float *bfrp = get_outp(len);
ret = swr_convert(resample_context,
ret = swr_convert(resample_context,
- (uint8_t **)frame->extended_data,
frame_sz
,
- (const uint8_t **)&bfrp,
frame_sz
);
+ (uint8_t **)frame->extended_data,
len
,
+ (const uint8_t **)&bfrp,
len
);
if( ret < 0 ) {
ff_err(ret, "FFAudioStream::encode: swr_convert failed\n");
break;
}
if( ret < 0 ) {
ff_err(ret, "FFAudioStream::encode: swr_convert failed\n");
break;
}
+ frame->nb_samples = len;
frm->queue(curr_pos);
frm = 0;
frm->queue(curr_pos);
frm = 0;
- curr_pos +=
frame_sz
;
- count -=
frame_sz
;
+ curr_pos +=
len
;
+ count -=
len
;
}
delete frm;
return ret >= 0 ? 0 : 1;
}
}
delete frm;
return ret >= 0 ? 0 : 1;
}
+int FFAudioStream::drain()
+{
+ return encode(0,0);
+}
+
int FFAudioStream::encode_frame(AVFrame *frame)
{
return FFStream::encode_frame(frame);
int FFAudioStream::encode_frame(AVFrame *frame)
{
return FFStream::encode_frame(frame);
@@
-867,6
+875,11
@@
int FFVideoStream::encode(VFrame *vframe)
return ret >= 0 ? 0 : 1;
}
return ret >= 0 ? 0 : 1;
}
+int FFVideoStream::drain()
+{
+ return 0;
+}
+
int FFVideoStream::encode_frame(AVFrame *frame)
{
if( frame ) {
int FFVideoStream::encode_frame(AVFrame *frame)
{
if( frame ) {
@@
-1214,7
+1227,7
@@
AVRational FFMPEG::to_sample_aspect_ratio(Asset *asset)
{
#if 1
double display_aspect = asset->width / (double)asset->height;
{
#if 1
double display_aspect = asset->width / (double)asset->height;
- double sample_aspect =
asset->aspect_ratio / display_aspect
;
+ double sample_aspect =
display_aspect / asset->aspect_ratio
;
int width = 1000000, height = width * sample_aspect + 0.5;
float w, h;
MWindow::create_aspect_ratio(w, h, width, height);
int width = 1000000, height = width * sample_aspect + 0.5;
float w, h;
MWindow::create_aspect_ratio(w, h, width, height);
@@
-2298,6
+2311,10
@@
void FFMPEG::run()
mux_lock->lock("FFMPEG::run");
if( !done ) mux();
}
mux_lock->lock("FFMPEG::run");
if( !done ) mux();
}
+ for( int i=0; i<ffaudio.size(); ++i )
+ ffaudio[i]->drain();
+ for( int i=0; i<ffvideo.size(); ++i )
+ ffvideo[i]->drain();
mux();
for( int i=0; i<ffaudio.size(); ++i )
ffaudio[i]->flush();
mux();
for( int i=0; i<ffaudio.size(); ++i )
ffaudio[i]->flush();