[mythtv] Editting .nuv, converting to Divx, (S)VCD, XVID, etc...

cwatson at linkline.com cwatson at linkline.com
Tue Mar 4 23:48:54 EST 2003


Hello Everyone, 

Want to edit your .nuv to take out commercials and or transcode to another 
codec?!  Well look no further than AVIDEMUX!  You can find 0.9 rc1 here: 
http://fixounet.free.fr/avidemux/
I've attached a patch that will allow Avidemux to read Myth's .nuv files.  I 
didn't write the patch the author of Avidemux did.  I wrote to him and 
within 24 hours he had the patch ready(Don't you just LOVE Open Source :)!  
Please drop him a thank you on the site.  I've tested it on a few files the 
a/v sync is off.  Talking to "mean"(the author) he states that the audio 
encode with mp3 encoded files the sync may be off, but uncompressed audio 
should be perfectly synced.  I transcoded the audio and video (you have to 
do both separately) to create a VCD.  The sync was off a just a little.  If 
you'd like to contribute, I'm sure he'd welcome it. 

Cecil-------------- next part --------------
Index: History
===================================================================
RCS file: /work/cvs/avidemux/History,v
retrieving revision 1.27
diff -u -r1.27 History
--- History	2 Mar 2003 17:50:37 -0000	1.27
+++ History	2 Mar 2003 18:55:10 -0000
@@ -35,6 +35,14 @@
           + Decimate ?
          		                                                                                                       
        ************************ /TODO ***************************
+01/03/2003
+			- Bumped MAX_SEG to 100 (jochen puchalla)
+			- Fixed LATEINTRA (Xvid CVS) (volker moell)
+			- Merged JSC warning patchs
+			- Merged & Fixed David Philippi anti warning patches
+			- Speed up in Blend
+			
+ -------------------------RC1----------------------------
 --33-6--       
 26-02-2003
 			- Fixed Mjpeg	
Index: buildLavCodec.sh
===================================================================
RCS file: /work/cvs/avidemux/buildLavCodec.sh,v
retrieving revision 1.2
diff -u -r1.2 buildLavCodec.sh
--- buildLavCodec.sh	21 Feb 2003 21:19:32 -0000	1.2
+++ buildLavCodec.sh	2 Mar 2003 18:24:08 -0000
@@ -8,7 +8,8 @@
 if [ -x libavcodec.a ]; then
 cd .. && exit 0;
 fi
- gmake # freebsd users need to GNU toolchain :(
+ make # freebsd users need to GNU toolchain :(
+          # yes but gmake is not always there on linux :(
  cd ..
 
 
Index: configure.in
===================================================================
RCS file: /work/cvs/avidemux/configure.in,v
retrieving revision 1.7
diff -u -r1.7 configure.in
--- configure.in	19 Feb 2003 18:51:00 -0000	1.7
+++ configure.in	2 Mar 2003 18:41:26 -0000
@@ -38,7 +38,7 @@
 AC_ARG_PROGRAM
 
 dnl Automake doc recommends to do this only here. (Janos)
-AM_INIT_AUTOMAKE(avidemux,0.9pre33)
+AM_INIT_AUTOMAKE(avidemux,0.9rc1)
 
 dnl almost the same like KDE_SET_PEFIX but the path is /usr/local
 dnl
Index: avidemux/ADM_editor/ADM_edit.cpp
===================================================================
RCS file: /work/cvs/avidemux/avidemux/ADM_editor/ADM_edit.cpp,v
retrieving revision 1.18
diff -u -r1.18 ADM_edit.cpp
--- avidemux/ADM_editor/ADM_edit.cpp	2 Mar 2003 19:00:34 -0000	1.18
+++ avidemux/ADM_editor/ADM_edit.cpp	3 Mar 2003 19:20:18 -0000
@@ -188,7 +188,9 @@
 					              *type=Mpeg_FileType;
 									return 1;
 					}
-         if( fourCC::check(magic[0],(uint8_t *)"Nupp"))
+         if( fourCC::check(magic[0],(uint8_t *)"Nupp")
+	 	|| fourCC::check(magic[0],(uint8_t *)"Myth")
+	 )
 			{
                       	printf(" \n Nuppelvideo file detected...\n");
 					              *type=Nuppel_FileType;
@@ -267,8 +269,8 @@
 	 
 	 fd=fopen(name,"rt");
 		 
-	 fscanf(fd,"Avidemux Config file 0 : %02lu segments\n",&nb);
-	 printf("WKB Reading workbench, %02ld segments to go\n",nb);
+	 fscanf(fd,"Avidemux Config file 0 : %lu segments\n",&nb);
+	 printf("WKB Reading workbench, %ld segments to go\n",nb);
 	 
 	 for(uint32_t i=0;i<nb;i++)
 	 {
Index: avidemux/ADM_nuv/ADM_nuv.cpp
===================================================================
RCS file: /work/cvs/avidemux/avidemux/ADM_nuv/ADM_nuv.cpp,v
retrieving revision 1.4
diff -u -r1.4 ADM_nuv.cpp
--- avidemux/ADM_nuv/ADM_nuv.cpp	17 Feb 2003 19:17:19 -0000	1.4
+++ avidemux/ADM_nuv/ADM_nuv.cpp	3 Mar 2003 20:17:23 -0000
@@ -41,7 +41,8 @@
 #define THRESHOLD 8192  //   /44.11*4 to gain the ms shit allowed
                                                  // 8192 ~ 45 ms
 														// 4410 ~  25 ms
-										
+
+//#define DEBUG																								
 //_____________________
 
 #include <stdio.h>
@@ -283,6 +284,7 @@
 #endif
    				return 1;		
 			case 'X':
+			case ';':
 						if(!_isXvid)
 							{
 									printf("\n Xvid detected WTF ???\n");
@@ -456,6 +458,11 @@
 		_nuv_header=(void *)head;
 	
 		assert(fread(head,sizeof(rtfileheader),1,_fd));
+		if(fourCC::check((uint8_t *)head->finfo,(uint8_t *)"Myth"))
+		{
+			_isMyth=1;
+			
+		}
 		Dump();
 		printf("\n Sizeof frame header : %d",sizeof(rtframeheader));
 		//
@@ -568,7 +575,7 @@
 #ifdef VERBOSE_SOUND
           					printf("\n Frame %lu, overshot %ld",v,overshot);
 #endif
-						if(overshot < -THRESHOLD)
+						if((overshot < -THRESHOLD)&&(_isPCM))
 						{
 						// we insert a dummy packet in audio chain to compensate
 												
@@ -608,7 +615,7 @@
 
 										
                                    						fread(buffer, frame.packetlength,1,_fd);
-										printf("\n Initializing jpeg table zith %u bytes\n",frame.packetlength);
+										printf("\n Initializing jpeg table with %u bytes\n",frame.packetlength);
 										 RTjpeg_init_decompress ( (uint32_t *)buffer, DXFIELD(width), DXFIELD(height) );
 										fseeko(_fd,old,SEEK_SET);
 										delete [] buffer;
@@ -616,6 +623,30 @@
 						break;
 				case 'S':
 						break;
+				case 'X':
+						// myth stuff
+						printf(" Myth info header\n");
+						_mythData=new mythHeader;
+						if(frame.packetlength!=sizeof(mythHeader))
+							{
+								GUI_Alert("\n Mmm size mismatch\n Expect a crash..");
+							
+							}
+						uint64_t old;
+						old=ftello(_fd);							
+						fread(_mythData, frame.packetlength,1,_fd);
+						_dump();
+						fseeko(_fd,old,SEEK_SET);
+						if(fourCC::check(_mythData->video_fourcc,(uint8_t *)"DIVX"))
+						{
+							printf("\n looks like mpeg4 video to me\n");
+						 	_isXvid=1;
+						 }
+						 if(!fourCC::check(_mythData->audio_fourcc,(uint8_t *)"RAWA"))
+						 {
+						 	_isPCM=0;						 
+						 }
+						break;
 				// Video Chunk !!
 				case 'V': 
 						if(!sync_met) break;
@@ -641,7 +672,24 @@
 				case 'A': 	
 						uint32_t alen;
 						if(!sync_met) break;
-
+						
+						// if it !PCM we take it as is
+						if(!_isPCM)
+						{
+							n=(ChaineD *)malloc(sizeof(ChaineD));
+							assert(n);
+							n->_next=NULL;
+							n->_frame=(rtframeheader *)malloc(sizeof(rtframeheader));
+							memcpy(n->_frame,&frame,sizeof(frame));				
+							alen= n->_frame->packetlength;
+							n->_pos=ftello(_fd);
+							aqueue->_next=n;
+							aqueue=n;
+							a++;
+							current_audio+=alen; //frame.packetlength;
+							break;
+						
+						}
 						if(overshot>THRESHOLD)
 							{
 #ifdef VERBOSE_SOUND
@@ -780,6 +828,7 @@
 		_vbuflzo=new uint8_t[max];
 		_vbufjpg=new uint8_t[DXFIELD(width)*DXFIELD(height)];
 
+		
 		if(a==0)
  			_isaudiopresent=0; 
 		else
@@ -829,7 +878,7 @@
 
 		if(a)
 			{
-				_audioTrack=new nuvAudio(_audioIndex,a,_fd);
+				_audioTrack=new nuvAudio(_audioIndex,a,_fd,_mythData);
 			}	
 #ifdef DEBUG
 
@@ -859,11 +908,51 @@
 _vbufjpg=NULL;
 _audioTrack=NULL;
 _isXvid=0;
+_isMyth=0;
 _max=0;
+_mythData=NULL;
+_isPCM=1;
 
 }
 
+void nuvHeader::_dump( void )
+{
+	if(!_mythData) return ;
+#ifdef DEBUG
+	#define VBS(x) printf(#x" : %s\n",_mythData->x);
+	#define VBI(x) printf(#x" : %d\n",_mythData->x);
+	uint32_t acc,vcc;
+	VBI(version);
+	vcc=(uint32_t )_mythData->video_fourcc;
+	acc=(uint32_t )_mythData->audio_fourcc;
+	
+	
+	
+	printf(" Video : %x",vcc);fourCC::print(_mythData->video_fourcc);printf("\n");
+	printf(" Audio : %x ",acc);fourCC::print(_mythData->audio_fourcc);printf("\n");
+	
+	
+	
+	VBI(audio_sample_rate);
+	VBI(audio_bits_per_sample);
+	VBI(audio_channels);
+	VBI(audio_compression_ratio);
+	VBI(audio_quality);
+	
+	VBI(rtjpeg_quality);
+	VBI(rtjpeg_luma_filter);
+	VBI(rtjpeg_chroma_filter);
+	
+	VBI(lavc_bitrate);
+	VBI(lavc_qmin);
+	VBI(lavc_qmax);
+  
+ 
+  
+#endif			
+
 
+}
 
 
 
Index: avidemux/ADM_nuv/ADM_nuv.h
===================================================================
RCS file: /work/cvs/avidemux/avidemux/ADM_nuv/ADM_nuv.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ADM_nuv.h
--- avidemux/ADM_nuv/ADM_nuv.h	26 Nov 2002 19:59:29 -0000	1.1.1.1
+++ avidemux/ADM_nuv/ADM_nuv.h	3 Mar 2003 20:11:03 -0000
@@ -24,6 +24,8 @@
 #include "ADM_editor/ADM_Video.h"
 #include "ADM_audio/aviaudio.hxx"
 
+#include "ADM_nuv/nuppel.h"
+
 typedef struct nuvIndex
 {
 	uint64_t _pos;
@@ -49,7 +51,7 @@
 public:
 				nuvAudio(nuvIndex *idx,
 					uint32_t nbchunk,
-					FILE * fd);
+					FILE * fd,mythHeader *hdr);
 		 virtual		~nuvAudio();
         virtual uint32_t 		read(uint32_t len,uint8_t *buffer);
         virtual uint8_t  		goTo(uint32_t newoffset);
@@ -71,7 +73,12 @@
 				nuvIndex *_tableIndex;
 				nuvAudio *_audioTrack;
 				uint8_t 		_isXvid;
-				uint32_t					_max;
+				uint8_t		_isPCM;
+				uint8_t		_isMyth;
+				uint32_t		_max;
+				mythHeader *_mythData;
+				
+				void			_dump(void);
 public:
 
 virtual   void 			Dump(void) ;
Index: avidemux/ADM_nuv/ADM_nuvAudio.cpp
===================================================================
RCS file: /work/cvs/avidemux/avidemux/ADM_nuv/ADM_nuvAudio.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ADM_nuvAudio.cpp
--- avidemux/ADM_nuv/ADM_nuvAudio.cpp	26 Nov 2002 19:59:29 -0000	1.1.1.1
+++ avidemux/ADM_nuv/ADM_nuvAudio.cpp	3 Mar 2003 20:16:20 -0000
@@ -49,7 +49,7 @@
 //
 //_______________________________________________________
 
-nuvAudio::nuvAudio(nuvIndex *idx, uint32_t nbchunk, FILE * fd)
+nuvAudio::nuvAudio(nuvIndex *idx, uint32_t nbchunk, FILE * fd,mythHeader *hdr)
 {
 	_nb_chunks=nbchunk;
 	_fd=fd;
@@ -59,6 +59,8 @@
 	_pos=0;
 	_index=idx;
 	// nuv format is fixed : PCM stero 44.1 khz
+	if(!hdr)
+	{
 	_wavheader=new WAVHeader;
 	memset(_wavheader,0,sizeof(WAVHeader));
 	_wavheader->bitspersample=16;
@@ -66,6 +68,27 @@
 	_wavheader->channels=2;
 	_wavheader->byterate=2*44100*2;
 	_wavheader->encoding=WAV_PCM;
+	}
+	else
+	{
+	_wavheader=new WAVHeader;
+	memset(_wavheader,0,sizeof(WAVHeader));
+	_wavheader->bitspersample=hdr->audio_bits_per_sample;;
+	_wavheader->frequency=hdr->audio_sample_rate;
+	_wavheader->channels=hdr->audio_channels;;
+	_wavheader->encoding=0xff; // ??
+	if(fourCC::check(hdr->audio_fourcc,(uint8_t *)"LAME"))
+		_wavheader->encoding=WAV_MP3;
+		
+		// _wavheader->byterate=2*44100*2;
+		float br;
+		br=hdr->audio_channels*2*hdr->audio_sample_rate;
+		if(hdr->audio_compression_ratio)
+			br/=hdr->audio_compression_ratio;
+		else br=16000;
+		_wavheader->byterate=(uint32_t)floor(br);
+		
+	}
 	_destroyable=1;	
 	strcpy(_name,"nuv audio");	
 	// compute length
Index: avidemux/ADM_nuv/nuppel.h
===================================================================
RCS file: /work/cvs/avidemux/avidemux/ADM_nuv/nuppel.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 nuppel.h
--- avidemux/ADM_nuv/nuppel.h	26 Nov 2002 19:59:29 -0000	1.1.1.1
+++ avidemux/ADM_nuv/nuppel.h	3 Mar 2003 19:37:37 -0000
@@ -1,4 +1,5 @@
-
+#ifndef NUPPEL_H
+#define NUPPEL_H
 /* nuppelvideo.h  rh */
 
 typedef struct rtfileheader
@@ -91,4 +92,31 @@
     int freeToBuffer;
     unsigned char *buffer_offset;
 } audbuffertyp;
+typedef struct mythHeader
+{
+   int version;            // yes, this is repeated from the file header
+   int video_fourcc;       // video encoding method used 
+   int audio_fourcc;       // audio encoding method used
+   // generic data
+   int audio_sample_rate;
+   int audio_bits_per_sample;
+   int audio_channels;
+   // codec specific
+   // mp3lame
+   int audio_compression_ratio;
+   int audio_quality;
+   // rtjpeg
+   int rtjpeg_quality;
+   int rtjpeg_luma_filter;
+   int rtjpeg_chroma_filter;
+   // libavcodec
+   int lavc_bitrate;
+   int lavc_qmin;
+   int lavc_qmax;
+   int lavc_maxqdiff;
+   // unused for later -- total size of 128 integers.
+   // new fields must be added at the end, above this comment.
+   int expansion[113];
+} mythHeader;
 
+#endif


More information about the mythtv-dev mailing list