[Cin] New thread on bdwrite + mpeg2 HDV video
Andrew Randrianasulu
randrianasulu at gmail.com
Mon Nov 7 18:30:02 CET 2022
пн, 7 нояб. 2022 г., 19:40 Andrew Randrianasulu <randrianasulu at gmail.com>:
>
>
> пн, 7 нояб. 2022 г., 19:10 Andrew Randrianasulu <randrianasulu at gmail.com>:
>
>> Because old thread now a bit too big for mobile gmail client.
>>
>> Yes, I'll try to see if it fails same way on my end.
>>
>> code seems to check first 100 frames
>>
>>
>> 2528 static int field_probe(AVFormatContext *fmt_ctx, AVStream *st)
>> 2529 {
>> 2530 AVDictionary *copts = 0;
>> 2531 //av_dict_copy(&copts, opts, 0);
>> 2532 AVCodecID codec_id = st->codecpar->codec_id;
>> 2533 #if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(58,134,100)
>> 2534 AVCodec *decoder = avcodec_find_decoder(codec_id);
>> 2535 #endif
>> 2536 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,16,100)
>> 2537 const AVCodec *decoder = avcodec_find_decoder(codec_id);
>> 2538 #endif
>> 2539 AVCodecContext *ctx = avcodec_alloc_context3(decoder);
>> 2540 if( !ctx ) {
>> 2541 fprintf(stderr,"codec alloc failed\n");
>> 2542 return -1;
>> 2543 }
>> 2544 avcodec_parameters_to_context(ctx, st->codecpar);
>> 2545 if( avcodec_open2(ctx, decoder, &copts) < 0 ) {
>> 2546 fprintf(stderr,"codec open failed\n");
>> 2547 return -1;
>> 2548 }
>> 2549 av_dict_free(&copts);
>> 2550
>> 2551 AVFrame *ipic = av_frame_alloc();
>> 2552 AVPacket ipkt;
>> 2553 av_init_packet(&ipkt);
>> 2554 int ilaced = -1;
>> 2555 for( int retrys=100; --retrys>=0 && ilaced<0; ) {
>> 2556 av_packet_unref(&ipkt);
>> 2557 int ret = av_read_frame(fmt_ctx, &ipkt);
>> 2558 if( ret == AVERROR_EOF ) break;
>> 2559 if( ret != 0 ) continue;
>> 2560 if( ipkt.stream_index != st->index ) continue;
>> 2561 if( !ipkt.data || !ipkt.size ) continue;
>> 2562 ret = avcodec_send_packet(ctx, &ipkt);
>> 2563 if( ret < 0 ) {
>> 2564 fprintf(stderr, "avcodec_send_packet failed\n");
>> 2565 break;
>> 2566 }
>> 2567 ret = avcodec_receive_frame(ctx, ipic);
>> 2568 if( ret >= 0 ) {
>> 2569 ilaced = ipic->interlaced_frame ? 1 : 0;
>> 2570 break;
>> 2571 }
>> 2572 if( ret != AVERROR(EAGAIN) )
>> 2573 fprintf(stderr, "avcodec_receive_frame failed %d\n", ret);
>> 2574 }
>> 2575 av_packet_unref(&ipkt);
>> 2576 av_frame_free(&ipic);
>> 2577 avcodec_free_context(&ctx);
>> 2578 return ilaced;
>>
>> may be we can add flags to force interlaced vs progressive to bdwrite ...
>> and/or debug why it fails.
>>
>>
> sorry, not m2t or m2ts files were found on my main harddrive, so blind
> shot!
>
> Terje, can you recompile bdwrite with attached patch and see if it
> improves situation?
>
err, I think second patch also needed, because ilace in bdwrite is just
1/0/-1 not more detailed.
>
>
>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20221107/19111fb2/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-TEST-better-field-probe-in-bdwrite.patch
Type: text/x-diff
Size: 1185 bytes
Desc: not available
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20221107/19111fb2/attachment-0001.bin>
More information about the Cin
mailing list