Reinhard Nissl schrieb: > Hi, > > Stefan Lucke wrote: > >> Dumping the first 16 bytes of audio packets we get, shows the following: >> ff fc a4 0d b6 64 88 55 33 65 56 54 44 21 33 33 >> ff fc a4 0d 54 6a 88 65 33 44 56 54 33 33 33 33 >> ff fc a4 0d 02 a4 88 55 33 54 66 44 43 33 33 33 >> 99 77 1b e6 34 b2 5f 41 e8 5b 90 a9 d2 04 24 5e >> ff fc c4 04 7c c4 dd 44 44 66 57 55 55 55 33 33 >> ff fc c4 04 1d 61 dd 46 44 66 55 55 55 55 33 33 >> 68 6a 60 18 d8 52 92 4f 54 98 0b 93 27 22 4e 74 >> ff fc c4 04 94 01 dd 44 56 66 55 55 55 55 33 33 >> >> Is audio repacker active even for old recording ? >> When I deactivate audio repacker, sound is garbled allways. > > cAudioRepacker was introduced after VDR-1.3.26 and it is only active in > transfer mode or while recording. It is not active while replaying a > recording, so it has no influence on recordings taken with VDR-1.2.1. > > But when cAudioRepacker was not active, an audio PES packet may contain, > multiple audio frames and/or just a fragment of an audio frame at the > beginning or at the end of the PES packet. > > So if ffmpeg can only work on single and/or complete audio frames, > you'll have to break the PES packet apart and assemble the fragments at > the end and the beginning of the next PES packet. FFmpeg can handle handle packets with multiple audio frames well, one just has to use the av_read_frame() interface instead of av_read_packet() like the softdevice currently does. There has been a change in the audio decode some time ago, before the decoder could also split the packets, that is why it worked before... I attached a patch with make the softdevice use av_read_frame(), it has still some issues, but it solves the problems Stefan reports. Is there a reason why the cAudioRepacker is used in transfer mode and during recordings, but not while replaying? Bye, Martin -------------- next part -------------- Index: mpeg2decoder.c =================================================================== RCS file: /cvsroot/softdevice/softdevice/mpeg2decoder.c,v retrieving revision 1.72 diff -u -r1.72 mpeg2decoder.c --- mpeg2decoder.c 26 Feb 2007 23:00:34 -0000 1.72 +++ mpeg2decoder.c 17 Mar 2007 20:51:17 -0000 @@ -174,7 +174,7 @@ freezeMode=false; AVPacket *pkt; - while ( PacketQueue.Available() < 7 && active) { + while ( PacketQueue.Available() < 3 && active) { BUFDEB("wait while loop packets %d StreamDecoder pid:%d type %d\n", PacketQueue.Available(),getpid(),context->codec_type ); usleep(10000); @@ -1115,20 +1115,31 @@ usleep(50000); BUFDEB("av_read_frame start\n"); - //ret = av_read_frame(ic, &pkt); - ret = av_read_packet(ic, &pkt); + ret = av_read_frame(ic, &pkt); + //ret = av_read_packet(ic, &pkt); if (ret < 0) { BUFDEB("cMpeg2Decoder Stream Error!\n"); if (ThreadActive) usleep(10000); continue; } - //av_dup_packet(&pkt); + av_dup_packet(&pkt); PacketCount++; BUFDEB("got packet from av_read_frame!\n"); +#if LIBAVFORMAT_BUILD > 4623 + AVRational time_base; + time_base=ic->streams[pkt.stream_index]->time_base; + if ( pkt.pts != (int64_t) AV_NOPTS_VALUE ) { + pkt.pts=av_rescale(pkt.pts, AV_TIME_BASE* (int64_t)time_base.num, time_base.den)/100 ; + }; + + //printf("PTS: %lld new %lld num %d den %d\n",PTS,pkt.pts, + // time_base.num,time_base.den); +#else if ( pkt.pts != (int64_t) AV_NOPTS_VALUE ) pkt.pts/=9; +#endif QueuePacket(ic,pkt,packetMode); @@ -1184,9 +1195,6 @@ void cMpeg2Decoder::QueuePacket(const AVFormatContext *ic, AVPacket &pkt, bool PacketMode) { - BUFDEB("QueuePacket AudioIdx: %d VideoIdx %d pkt.stream_index: %d\n", - AudioIdx,VideoIdx,pkt.stream_index); - if (!ic) { fprintf(stderr,"Error: ic is null!\n"); av_free_packet(&pkt); @@ -1212,6 +1220,8 @@ BUFDEB("Unknown packet type! Return;\n"); return; }; + BUFDEB("QueuePacket AudioIdx: %d VideoIdx %d pkt.stream_index: %d, packet_type: %d\n", + AudioIdx,VideoIdx,pkt.stream_index,packet_type); // check if there are new streams if ( AudioIdx != DONT_PLAY && packet_type == CODEC_TYPE_AUDIO