doconnor
Posts: 2
Joined: Mon Feb 27, 2012 5:46 pm
Contact: Website

Re: MPEG-2 to MPEG-4 translation without decoding

Mon Feb 27, 2012 6:49 pm

One of the problem mentioned about the Raspberry Pi is that the GPU doesn't allow MPEG-2 decoding. This problem is not unique to this device. My current smartphone, the Palm Pre, and others also have this problem.

It seems to me one solution would be write a translate that would convert MPEG-2 to MPEG-4 without decoding. That should work if MPEG-4 supports a superset of the features of MPEG-2. I've only don't a little investigation into this (looking at Wikipedia), but it might work.

drgeoff
Posts: 9343
Joined: Wed Jan 25, 2012 6:39 pm

Re: MPEG-2 to MPEG-4 translation without decoding

Mon Feb 27, 2012 7:12 pm

It is possible to make a transcoder which is more intelligent than decoding fully to PCM video and inputting that to an encoder.  But there is enough difference between MPEG-2 and later MPEGs that fairly substantial processing is still required.  It certainly isn't just a case of "jiggling some bits around here and there".

I wrote "later MPEGs" to cover both MPEG-4 Part 2 and MPEG-4 Part 10 (better known by its ITU-T name Rec. H.264).  The two are not the same.

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: MPEG-2 to MPEG-4 translation without decoding

Tue Feb 28, 2012 12:00 am

I'm going to guess that because MPEG-2 reqires less CPU time and more bandwidth in comparison to MPEG-4 that the ARM CPU core will be able to software decode most MPEG-2 video.  Before someone here says it... who encodes HD video in MPEG-2 (aside from early BluRays)?  When I put stuff on my media server I don't think to myself I wish that all these videos were the same quality but the files were massivly bigger.  Anything that I can transcode into H.264 I do.

Yes there will be no MPEG-2 hardware decode on the R-PI, but I seriously doubt that will be an issue for people.  Software decode is still an option.  The bigger stumbling block for me is the lack of VC-1 support , since many of my .MKV files are encoded in VC-1(their native format.)  Now I have re-encode them, or watch them on another device.  Not that I'm complaining just a fact of life here.

drgeoff
Posts: 9343
Joined: Wed Jan 25, 2012 6:39 pm

Re: MPEG-2 to MPEG-4 translation without decoding

Tue Feb 28, 2012 12:27 pm

If you have a look at the "MythTV frontend" thread you will find that MPEG-2 is widely used for SD digital terrestrial and SD digital satellite in Europe.  Also for digital terrestrial HD in the US.

I think the jury is still out on whether the unaided ARM CPU can decode SD MPEG-2 as used on DVDs.  The proof of the pi will be in the decoding!  Some lucky people should be able to give us an answer "real soon now".

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: MPEG-2 to MPEG-4 translation without decoding

Wed Feb 29, 2012 12:19 am

I have some of the older 50GB Mpeg-2 encoded Blu-Rays in my collection I will rip and try it out as soon as I get my hands on one.  A BluRay will be the worst case scenario for Mpeg-2 content.

mooncrater
Posts: 3
Joined: Thu Feb 09, 2012 10:49 am

Re: MPEG-2 to MPEG-4 translation without decoding

Sat Mar 03, 2012 11:58 am

doconnor said:


It seems to me one solution would be write a translate that would convert MPEG-2 to MPEG-4 without decoding.



I suspect that there is not enough similarity. Although the basic principles of representing data are the same (i.e. macroblocks of pixels; encoding by motion compensation), the next layer looks different, e.g. MPEG-4 represents streams as video objects, where MPEG-2 uses groups of pictures.

I did a quick literature search and found one patented method (2007) of transcoding, which seemed to involve decoding to the macroblock level, then reconstructing. There is also a research paper involving transforming MPEG-2 into a downsampled MPEG-4 stream, again going down to the macroblock layer. I guess the positive side of this is that if you did find a way to transcode on-the-fly, it would be a worthy topic for a research paper!

mooncrater
Posts: 3
Joined: Thu Feb 09, 2012 10:49 am

Re: MPEG-2 to MPEG-4 translation without decoding

Sat Mar 03, 2012 3:10 pm

drgeoff said:


I wrote "later MPEGs" to cover both MPEG-4 Part 2 and MPEG-4 Part 10 (better known by its ITU-T name Rec. H.264).  The two are not the same.


True. I've sometimes wondered why H.264 is added as "part 10" to the MPEG-4 spec, as the two have little in common. H.264 is a direct descendant of H.261/H.263(+), and MPEG-4 comes from a completely different lineage.

MartenR
Posts: 46
Joined: Sat Mar 03, 2012 9:15 am

Re: MPEG-2 to MPEG-4 translation without decoding

Sat Mar 03, 2012 5:25 pm

Actually, I looked into the specs, it is not possible to transcode mpeg2 to mpeg4, the size of macroblocks and some other things are different, which will prevent you from doing this.

Anyway, using software decoder (ffmpeg as example) on the arm, might be sufficient for SD. If it is too tight, opengl es supports shaders. That means at least yuv to rgb can be done using them. If this is not fast enough, it will be possible to the motion compensation using the shaders and if this is still to slow do also the DCT with shaders. Propably one can use the output of ffmpeg in xvmc as input for these.

The way I want to go along, when I start porting vomp (vdr client) to the raspberry pi, but first I waiting for it.....

Marten

drgeoff
Posts: 9343
Joined: Wed Jan 25, 2012 6:39 pm

Re: MPEG-2 to MPEG-4 translation without decoding

Sat Mar 03, 2012 7:43 pm

mooncrater said:


drgeoff said:


I wrote "later MPEGs" to cover both MPEG-4 Part 2 and MPEG-4 Part 10 (better known by its ITU-T name Rec. H.264).  The two are not the same.


True. I've sometimes wondered why H.264 is added as "part 10" to the MPEG-4 spec, as the two have little in common. H.264 is a direct descendant of H.261/H.263(+), and MPEG-4 comes from a completely different lineage.


It is a complicated story to do with the "love/hate" relationship between the ISO group and the ITU-T group.

drgeoff
Posts: 9343
Joined: Wed Jan 25, 2012 6:39 pm

Re: MPEG-2 to MPEG-4 translation without decoding

Sat Mar 03, 2012 8:28 pm

mooncrater said:


doconnor said:


It seems to me one solution would be write a translate that would convert MPEG-2 to MPEG-4 without decoding.


I suspect that there is not enough similarity. Although the basic principles of representing data are the same (i.e. macroblocks of pixels; encoding by motion compensation), the next layer looks different, e.g. MPEG-4 represents streams as video objects, where MPEG-2 uses groups of pictures.

I did a quick literature search and found one patented method (2007) of transcoding, which seemed to involve decoding to the macroblock level, then reconstructing. There is also a research paper involving transforming MPEG-2 into a downsampled MPEG-4 stream, again going down to the macroblock layer. I guess the positive side of this is that if you did find a way to transcode on-the-fly, it would be a worthy topic for a research paper!


The original MPEG-4 (Part 2) can use video objects and video objects can be complete frames rather than segments of frames.  Part 10 aka H.264 does not support object segmentation.  Groups of frames (GoP) is a completely different thing used by MPEG-4 Parts 4 and 10 and MPEG-2 Part 2 (aka H.262).  A GoP is independently decodable.  It does not use data from frames before or after the GoP and the data in a GoP is not needed to decode other GoPs.

I have done some work on transcoding in the past and have a patent or two on some aspects so I'd be interested in looking at the two items you mention if you can provide the references.

ProDigit
Posts: 125
Joined: Tue Aug 30, 2011 1:24 am

Re: MPEG-2 to MPEG-4 translation without decoding

Sun Mar 04, 2012 5:30 pm

My 2ct,may not be much worth, but I'll go ahead anyway:

Why spend the time wasting cycles encoding MPEG2 data, only to decode it in the video processor?
Couldn't 'your' effort (or the researcher's effort) not better be spent optimizing a decoder for the Pi's hardware?

The CPU is more than enough! Even on an x86 processor,you only need a 300Mhz processor to decode mpeg2 data, dvd quality.

The issue with bandwidth is also questionable, as loading the video and audio stream uses only a fraction of a USB2 interface's bandwidth.

Thiking that most mpeg2 data would be of DVD quality or lower, not HD quality like of blueray dvd's; and should be playing back on an RPI (correct me if I'm wrong, and if I'm wrong then there's probably a software bug preventing it from happening).

Otherwise,playing back HD mpeg2 could indeed reach the limits of an Rpi! I know that if it's capable of decoding 720p mp4 (avc or h264) video's, that it's quite an accomplishment, as the x86 architecture needs an 800MHz P3 the least to do that job!

krnewell
Posts: 4
Joined: Sun May 13, 2012 6:23 pm

Re: MPEG-2 to MPEG-4 translation without decoding

Wed May 16, 2012 4:50 am

I think the kicker here is that there's already MPEG2 support in the SoC, but it's not licensed. The hardware can do it natively, but you're probably never going to get better than what's already in the licensed version. I'm just starting to get into this issue myself, but it's very clear that there will have to be a transcode (on-the-fly or batched) unless the foundation/broadcom/someone releases a new binary blob with MPEG2 turned on.

MartenR
Posts: 46
Joined: Sat Mar 03, 2012 9:15 am

Re: MPEG-2 to MPEG-4 translation without decoding

Thu Aug 02, 2012 12:55 pm

MartenR wrote:Actually, I looked into the specs, it is not possible to transcode mpeg2 to mpeg4, the size of macroblocks and some other things are different, which will prevent you from doing this.
.
I have to correct my statement, it is only true for h264 aka mpeg4 part 10, as far as I understood mpeg4 part 2 (aka divx with b frames) is also supported by the raspberry pi.
And this can be used in an transcoder:
http://www.raspberrypi.org/phpBB3/viewt ... 19#p139319

Marten

Return to “General discussion”