Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect that a movie is 3D? [closed]

Tags:

ffmpeg

3d

Does anyone know how to detect that a video file is a 3D movie?

I've tried using ffmpeg tool, but i didn't succeeded to find out how to do.

sample

like image 319
mihaela Avatar asked May 02 '12 07:05

mihaela


People also ask

How do you know if a movie is in 3D?

The easiest, as has been mentioned, is to look at the credits or look on line. If you see titles such as stereoscopic supervisor, or companies such as Prime Focus, then it is most likely conversion. Something like 3d camera supervisor and at least part of it was shot is stereo.

What happens if you watch a 3D movie without the glasses?

The two parts of a 3D signal that reach your eyes require the use of either Active Shutter or Passive Polarized Glasses to see the result. When such images are viewed without 3D glasses, you see two overlapping images that look slightly out of focus.

Why do 3D movies not look 3D?

The reason that 3D television and movie experiences work – or don't – is because of a process known as binocular vision. In a healthy visual system, both your eyes are properly in sync, moving in unison to look at a certain object or point in space.

Why did movies stop doing 3D?

3D movies would cost a few dollars more than your regular 2D movie and when combined with ultra-large screens like the IMAX, ticket prices went through the roof.


1 Answers

It depends on the format.

On stream level: For AVC you could look for frame packing arrangement SEI messages. For MVC you could look for slice extension NALs (type=20).

http://www.merl.com/reports/docs/TR2011-022.pdf

I looked at your file. It is AVC 3D with frame packing type 3 (side by side - L is on the left, R on the right). I extraced the H.264 stream and I found at byte offset 0x23: 00 00 00 01 06 2D this is a SEI message (06) of type frame packing arrangement (2D). Indeed your file contains information indicating 3D

Comannd line tool to detect 3D

  1. Extract the h.264 stream using mp4box -raw 1 82-3D-LHelEIJVxiE.mp4 (http://gpac.wp.mines-telecom.fr/mp4box/)

take the H.264 elementary stream 82-3D-LHelEIJVxiE_track1.h264 and run it throught the followin code:

#include <iostream>
#include <fstream>

typedef unsigned char uint8_t;


enum ResultCode
{
   E_Error   = -1,
   E_OK      = 0,
   E_No3D    = 2,
   E_Found3D = 3,

};

enum NALType
{
   NALType_Unknown             =  0,
   NALType_Slice               =  1,
   NALType_Slice_DPA           =  2,
   NALType_Slice_DPB           =  3,
   NALType_Slice_DPC           =  4,
   NALType_Slice_IDR           =  5,
   NALType_SEI                 =  6,
   NALType_SPS                 =  7,
   NALType_PPS                 =  8,
   NALType_AU_Delimiter        =  9,
   NALType_SequenceEnd         = 10,
   NALType_StreamEnd           = 11,
   NALType_FillerData          = 12,
   NALType_CodedSliceExtension = 20,

   NALType_MAX                 = 0x1f
};

enum SEIType
{
   SEIType_FramePackingArrangement = 0x2D
};


enum StartCodeState
{
   StartCodeState_none,
   StartCodeState_0,
   StartCodeState_0_0,
   StartCodeState_0_0_1
};


int Is3D(std::ifstream & inputFile)
{
   int nResult = E_OK;

   StartCodeState eStartCodeState = StartCodeState_none;

   while( (E_OK == nResult) && ( ! inputFile.eof() ) )
   {
      uint8_t byte = inputFile.get();

      switch(eStartCodeState)
      {
         case  StartCodeState_none :
            eStartCodeState = (byte == 0) ? StartCodeState_0 : StartCodeState_none;
            break;

         case  StartCodeState_0 :
            eStartCodeState = (byte == 0) ? StartCodeState_0_0 : StartCodeState_none;
            break;

         case  StartCodeState_0_0 :
            switch(byte)
            {
               case 0  : eStartCodeState = StartCodeState_0_0;   break;
               case 1  : eStartCodeState = StartCodeState_0_0_1; break;
               default : eStartCodeState = StartCodeState_none;

            }

         default:
            ;
      }

      if(  eStartCodeState == StartCodeState_0_0_1 )
      {
         uint8_t cNALType  = inputFile.get();
                 cNALType &= NALType_MAX;

         switch(cNALType)
         {
            case NALType_CodedSliceExtension :
               nResult = E_Found3D;
               break;

            case NALType_SEI :
            {
               uint8_t cSEIType  = inputFile.get();
               if( cSEIType == SEIType_FramePackingArrangement )
               {
                  nResult = E_Found3D;
               }
               break;
            }

            default:
               ;
         }

         eStartCodeState = StartCodeState_none;
      }
   }

   return nResult;
}


int main(int argc, char * argv[])
{
   int nResult = E_OK;

   if( argc != 2 )
   {
      nResult = E_Error;

      std::cerr << "Usage: "
                << argv[0]
                << " <H.264 elementary stream input file>"
                << std::endl;

   }

   if( E_OK == nResult )
   {
      std::ifstream inputFile(argv[1], std::ios::binary);

      if( inputFile.is_open() )
      {
         if( E_Found3D == Is3D(inputFile) )
         {
            std::cout << "File: "
                      << argv[1]
                      << " contains 3D."
                      << std::endl;

            nResult = E_Found3D;

         }
         else
         {
            std::cout << "No 3D found" << std::endl;

            nResult = E_No3D;
         }


      }
      else
      {
         std::cerr << "Error opening input file: " 
                   << argv[1]
                   << std::endl;

         nResult = E_Error;
      }
   }

   return nResult;
}
like image 82
Markus Schumann Avatar answered Oct 05 '22 03:10

Markus Schumann