Ticket #12936: 0036-revert-ffmpeg-avformat-flvenc.c-do-not-write-duration-and-filesize-when-not-seekable.patch
File 0036-revert-ffmpeg-avformat-flvenc.c-do-not-write-duration-and-filesize-when-not-seekable.patch, 2.8 KB (added by , 7 years ago) |
---|
-
mythtv/external/FFmpeg/libavformat/flvenc.c
diff -Naur mythtv-master-build-old/mythtv/external/FFmpeg/libavformat/flvenc.c mythtv-master-build-new/mythtv/external/FFmpeg/libavformat/flvenc.c
old new 234 234 metadata_count_pos = avio_tell(pb); 235 235 metadata_count = 4 * !!flv->video_par + 236 236 5 * !!flv->audio_par + 237 1 * !!flv->data_par; 238 if (pb->seekable) { 239 metadata_count += 2; // +2 for duration and file size 240 } 237 1 * !!flv->data_par + 238 2; // +2 for duration and file size 239 241 240 avio_wb32(pb, metadata_count); 242 241 243 if (pb->seekable) { 244 put_amf_string(pb, "duration"); 245 flv->duration_offset = avio_tell(pb); 246 // fill in the guessed duration, it'll be corrected later if incorrect 247 put_amf_double(pb, s->duration / AV_TIME_BASE); 248 } 242 put_amf_string(pb, "duration"); 243 flv->duration_offset = avio_tell(pb); 244 245 // fill in the guessed duration, it'll be corrected later if incorrect 246 put_amf_double(pb, s->duration / AV_TIME_BASE); 249 247 250 248 if (flv->video_par) { 251 249 put_amf_string(pb, "width"); … … 321 319 metadata_count++; 322 320 } 323 321 324 if (pb->seekable) { 325 put_amf_string(pb, "filesize"); 326 flv->filesize_offset = avio_tell(pb); 327 put_amf_double(pb, 0); // delayed write 328 } 322 put_amf_string(pb, "filesize"); 323 flv->filesize_offset = avio_tell(pb); 324 put_amf_double(pb, 0); // delayed write 329 325 330 326 put_amf_string(pb, ""); 331 327 avio_w8(pb, AMF_END_OF_OBJECT); … … 547 543 548 544 file_size = avio_tell(pb); 549 545 550 if (pb->seekable) { 551 /* update information */ 552 if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) { 553 av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n"); 554 } else { 555 put_amf_double(pb, flv->duration / (double)1000); 556 } 557 if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) { 558 av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n"); 559 } else { 560 put_amf_double(pb, file_size); 561 } 562 } 546 /* update information */ 547 if (avio_seek(pb, flv->duration_offset, SEEK_SET) < 0) 548 av_log(s, AV_LOG_WARNING, "Failed to update header with correct duration.\n"); 549 else 550 put_amf_double(pb, flv->duration / (double)1000); 551 if (avio_seek(pb, flv->filesize_offset, SEEK_SET) < 0) 552 av_log(s, AV_LOG_WARNING, "Failed to update header with correct filesize.\n"); 553 else 554 put_amf_double(pb, file_size); 555 563 556 avio_seek(pb, file_size, SEEK_SET); 564 557 return 0; 565 558 }