1、 Approved November 28, 2012 Copyright 2012 by THE SOCIETY OF MOTION PICTURE AND TELEVISION ENGINEERS 3 Barker Avenue, White Plains, NY 10601 (914) 761-1100 Foreword . 2 Introduction 2 1 Scope . 3 2 Informative References 3 3 Definitions and Acronyms 3 4 Arithmetic Operators 4 5 Basic Conversion Form
2、ulas . 4 5.1 Conversion of SMPTE ST 12-1 Time-Address Value to Local Wall Clock Time . 4 5.2 Conversion of Local Wall Clock Time to MPEG-2 PCRtb Value . 6 5.3 Conversion of SMPTE ST 12-1 Time-Address Value to MPEG-2 PCRtb . 6 5.4 Conversion of MPEG-2 PCRtb Value to Local Wall Clock Time . 7 5.5 Conv
3、ersion of Local Wall Clock Time to SMTPE 12-1 Time-Address Value . 8 5.6 Conversion of MPEG-2 PCRtb Value to SMPTE ST 12-1 Time-AddressVvalue 12 6 Conversion Formulas with Audio Sample Number Extension . 13 6.1 Conversion of SMPTE ST 12-1 Time-Address Value with Sample Number to Local Wall Clock Tim
4、e . 14 6.2 Conversion of SMPTE ST 12-1 Time-Address Value with Sample Number to MPEG-2 PCRtb Value 14 6.3 Conversion of Local Wall Clock Time to SMPTE ST 12-1 Time-Address Value with Sample Number. 14 6.4 Conversion of MPEG-2 PCRtb Value to SMPTE ST 12-1 Time Address Value with Sample Number. 16 Ann
5、ex A Bibliography 17 Annex B Examples 19 B.1 SMPTE ST 12-1 Time Code to MPEG-2 PCR Time Base Conversion . 19 B.2 MPEG-2 PCR Time Base to SMPTE ST12-1 Time Code Conversion 19 Annex C Placement of SMPTE ST 12-1 Time Code into MPEG-2 or MPEG-4 AVC Video . 21 C.1 Placement in MPEG-2 Video . 21 C.2 Place
6、ment in MPEG-4 Part 2 Video . 22 C.3 Placement in MPEG-4 AVC Video . 21 SMPTE ENGINEERING GUIDELINE Conversion of Time Values Between SMPTE 12-1 Time Code, MPEG-2 PCR Time Base and Absolute Time Page 1 of 21 pages SMPTE EG 40:2012 Revision of EG 40-2002 SMPTE EG 40:2012 Page 2 of 21 pages Foreword S
7、MPTE (the Society of Motion Picture and Television Engineers) is an internationally-recognized standards developing organization. Headquartered and incorporated in the United States of America, SMPTE has members in over 80 countries on six continents. SMPTEs Engineering Documents, including Standard
8、s, Recommended Practices, and Engineering Guidelines, are prepared by SMPTEs Technology Committees. Participation in these Committees is open to all with a bona fide interest in their work. SMPTE cooperates closely with other standards-developing organizations, including ISO, IEC and ITU. SMPTE Engi
9、neering Documents are drafted in accordance with the rules given in Part XIII of its Operations Manual. SMPTE EG 40 was prepared by Technology Committee 33TS. Introduction This section is entirely informative and does not form an integral part of this Engineering Document. This Engineering Guideline
10、 provides a set of formulas for common time related conversions in the hope that implementers will do these calculations in a similar and interoperable manner. An earlier revision of this document used the term “absolute time” to refer to time that may be more clearly termed “local wall clock time.”
11、 This is the time of day in the local time zone typically measured by “the clock on the wall” and not necessarily tightly tied to an International standardized time reference (UTC, GPS, etc.). Other SMPTE Engineering documents may provide for defined calculations to convert “local wall clock time” t
12、o an International standardized time reference (UTC, GPS, etc.). SMPTE EG 40:2012 Page 3 of 21 pages 1 Scope This guideline specifies a set of formulas for converting between “SMPTE 12M time code” (correctly SMPTE ST 12-1 time code), MPEG-2 systems layer program clock reference (PCR) time base, and
13、local wall clock time. Included are formulas for converting SMPTE ST 12-1 time address values and MPEG-2 PCR time base values to local wall clock time, and formulas for converting SMPTE ST 12-1 time address values directly to/from MPEG-2 PCR time base values. Local wall clock time conversion formula
14、s are useful for converting between different frame rates of SMPTE ST 12-1 time code; e.g., a 24-fps SMPTE time code running at 23.976 fps could be converted to true time and then to a 29.97 drop frame SMPTE time code value. Finally, a discussion of how ST 12-1 time code may be carried within the co
15、ded video structures of both MPEG-2 and MPEG-4 AVC is provided. 2 Informative References Note: All references in this document to other SMPTE documents use the current numbering style (e.g. SMPTE ST 12-1:2008) although, during a transitional phase, the document as published (printed or PDF) may bear
16、 an older designation (such as SMPTE 12M-1-2008). Documents with the same root number (e.g. 12-1) and publication year (e.g. 2008) are functionally identical. At the time of publication, the editions indicated were valid. All standards are subject to revision, and parties to agreements based on this
17、 guideline are encouraged to investigate the possibility of applying the most recent edition of the standards indicated below. SMPTE ST 12-1:2008, Television Time and Control Code SMPTE ST 339:2008, Format for Non-PCM Audio and Data in AES3 Generic Data Types Recommendation ITU-T H.222.0 | ISO/IEC 1
18、3818-1, Information Technology Generic Coding of Moving Pictures and Associated Audio: Systems, (2007) Recommendation ITU-T H.262 | ISO/IEC 13818-2, Information Technology Generic Coding of Moving Pictures and Associated Audio: Video, (2000) Recommendation ITU-T H.264 | ISO/IEC 14496-10, Information
19、 technology Coding of audio-visual objects Part 10: Advanced Video Coding, (2010) 3 Definitions and Acronyms local wall clock time: This is the time of day in the local time zone typically measured by “the clock on the wall” and not necessarily tightly tied to an International standardized time refe
20、rence (UTC, GPS, etc.). AVC: An abbreviation for Advanced Video Coding, documented in ISO/IEC 14496-10. GPS: An abbreviation for Global Positioning System. MPEG-2: A suite of standards distributed as parts under the identifier ISO/IEC 13818. Part 1 is MPEG-2 Systems. Part 2 is MPEG-2 visual (video c
21、oding). MPEG-4: A suite of standards distributed as parts under the identifier ISO/IEC 14496. Part 2 is MPEG-4 visual. Part 10 is AVC. PCR: An abbreviation for Program Clock Reference. (Note: See ISO/IEC 13818-1.) UTC: An abbreviation for Coordinated Universal Time. SMPTE EG 40:2012 Page 4 of 21 pag
22、es WWV: The call sign of the United States National Institute of Standards and Technologys (NIST) HF (“shortwave“) radio station in Fort Collins, Colorado. 4 Arithmetic Operators The arithmetic operators used in the conversion formulas are defined as follows: + Addition Subtraction x Multiplication
23、/ or Division % Modulus operator int(x) Largest integer not greater than x ceil(x) Smallest integer not less than x 5 Basic Conversion Formulas The following formulas define the conversion between SMPTE ST 12-1 time code time-address values and the MPEG-2 PCR time base values, referred to as PCRtb.
24、The resulting PCR time base value may or may not be equal to the program clock reference base (PCRB) counter used in the MPEG-2 transport system; however, it will always be synchronous with the actual PCRB counter, differing by a constant. The formulas given here are limited to the resolution of the
25、 PCRB counter that is 1/300 of the MPEG-2 system clock frequency of 27 MHz (i.e., 90 kHz). Conversion to the full PCR counter resolution is not considered in these formulas. Time values are in units of seconds. This document does not account for the existence of frame rates greater than 30 Hz. Secti
26、on 12 of SMPTE ST 12-1 provides the necessary constraints for utilization of SMPTE ST 12-1 time code time-address values with 50-Hz and 60-Hz progressive scanning systems. The reader is cautioned that many applications of this guideline may require attention to video system frame rate before doing a
27、 calculation related to time code. The readers attention is called to the discussion regarding the required precision of these calculations which is found in the second “Note” within Section 5.1.2 of SMPTE ST 12-1. 5.1 Conversion of SMPTE ST 12-1 Time-Address Value to Local Wall Clock Time These for
28、mulas presume an alignment between midnight (time zero) and time-address 00:00:00:00. For systems with an integer number of frames per day, this alignment may be achieved and maintained. For systems with a noninteger count of frames per day, such as with 29.97-Hz frame rates, there will be a daily p
29、hase variation between midnight and time-address 00:00:00:00. 5.1.1 General timeframe_ countframe_ rate= where: frame_count = total number of elapsed frames since time address 00:00:00:00 SMPTE EG 40:2012 Page 5 of 21 pages 5.1.2 23.98. frames/sec non-drop frame ( )( )( )( )hours86,400minutes1440sec
30、onds24frames24,0001001hours60minutes60seconds24frames10001001241time+=+=5.1.3 24 frames/sec ( )( )( )( )hours86,400minutes1440seconds24frames241hours60minutes60seconds24frames241time+=+=5.1.4 25 frames/sec ( )( )( )( )hours90,000minutes1500seconds25frames251hours60minutes60seconds25frames251time+=+=
31、5.1.5 29.97. frames/sec drop frame ( )( )( )( )+=+=hours107,89210minutesint2+minutes1798seconds30frames30,0001001hours10810minutesint2minutes2hours60+minutes60seconds30frames10001001301time5.1.6 29.97. frames/sec nondrop frame ( )( )( )( )hours108,000minutes1800seconds30frames30,0001001hours60minute
32、s60seconds30frames10001001301time+=+=SMPTE EG 40:2012 Page 6 of 21 pages 5.1.7 30 frames/sec ( )( )( )( )hours108,000minutes1800seconds30frames301hours60minutes60seconds30frames301time+=+=5.2 Conversion of Local Wall Clock Time to MPEG-2 PCRtb Value ( )332%90,000timeintPCRtb = (Since the PCRtb is ba
33、sed on a 33-bit digital counter and the local wall clock time value can exceed this limit, a correction has been included that constrains the PCRtb value to 33-bits.) 5.3 Conversion of SMPTE ST 12-1 Time-Address Value to MPEG-2 PCRtb 5.3.1 General 90,000frame_ratetframe_counPCRtb = where: frame_coun
34、t = total number of elapsed frames since time address 00:00:00:00 Note: In the formulas below, 3750 = 90,000 24 and 3600 = 90,000 25. 5.3.2 23.98 frame/sec nondrop frame ( )( )( )( )+=+=+=hours,000324324,minutes004,55,40seconds0990,0frames000,24000,901001ceilhours86,400minutes1440seconds24frames000,
35、90000,241001ceilhours60minutes60seconds24frames000,90240001001ceilPCRtb5.3.3 24 frames/sec ( )( )( )( )hours0324,000,00minutes5,400,000seconds90,000frames3750hours86,400minutes1440seconds24frames3750hours60minutes60seconds24frames3750PCRtb+=+=+=SMPTE EG 40:2012 Page 7 of 21 pages 5.3.4 25 frames/sec
36、 ( )( )( )( )hours0324,000,00minutes5,400,000seconds90,000frames6003hours90,000minutes1500seconds25frames3600hours60minutes60seconds25frames3600PCRtb+=+=+=5.3.5 29.97. frames/sec drop frame ( )( )hours676,999,33210minutesint6006minutes394,3995,seconds9090,0frames0033hours107,89210minutesint2minutes1
37、798seconds30frames3003hours10810minutesint2minutes2hours60minutes60seconds30frames3003PCRtb+=+=+=5.3.6 29.97frames/sec nondrop frame ( )( )( )( )hours,000324324,minutes004,55,40seconds0990,0frames0033hours108,000minutes1800seconds30frames3003hours60minutes60seconds30frames3003PCRtb+=+=+=5.3.7 30 fra
38、mes/sec ( )( )( )( )hours0324,000,00minutes5,400,000seconds90,000frames0003hours108,000minutes1800seconds30frames3000hours60minutes60seconds30frames3000PCRtb+=+=+=5.4 Conversion of MPEG-2 PCRtb Value to Local Wall Clock Time =90,000PCRtbtime SMPTE EG 40:2012 Page 8 of 21 pages 5.5 Conversion of Loca
39、l Wall Clock Time to SMTPE ST 12-1 Time-Address Value 5.5.1 General ( )( )( )( )hours60minutes60secondsframe_ratetframe_counframesframe_ratehours60minutes60frame_ratetframe_counintseconds60frame_ratehours6060frame_ratetframe_counintminutes24%6060frame_ratetframe_couninthourstimeframe_rateinttframe_c
40、oun+= +=(Since the local wall clock time value can exceed 24 hours, while values of SMPTE ST 12-1 time-address must be constrained to be 24 hours, a correction has been included in the following formulas that generate the hours values.) 5.5.2 23.98. frames/sec non-drop frame ( )( )( )hours004,86minu
41、tes0441seconds24tframe_counhours606024minutes6024seconds24tframe_counhours60minutes60seconds24tframe_counframes24hours400,86minutes1440tframe_counint24hours606024minutes6024tframe_counint24hours60minutes6024tframe_counintseconds1440hours400,86tframe_counint6024hours606024tframe_counintminutes24%400,
42、86tframe_counint24%606024tframe_couninthourstime1001100024inttframe_coun=+= = = += =SMPTE EG 40:2012 Page 9 of 21 pages 5.5.3 24 frames/sec ( )( )( )( )hours004,86minutes0441seconds24tframe_counhours606024minutes6024seconds24tframe_counhours60minutes60seconds24tframe_counframes24hours400,86minutes14
43、40tframe_counint24hours606024minutes6024tframe_counint24hours60minutes6024tframe_counintseconds1440hours400,86tframe_counint6024hours606024tframe_counintminutes24%400,86tframe_counint24%606024tframe_couninthourstime24inttframe_coun=+= = = += =5.5.4 25 frames/sec ( )( )( )( )hours000,90minutes0501sec
44、onds25tframe_counhours606025minutes6025seconds25tframe_counhours60minutes60seconds25tframe_counframes25hours000,90minutes1500tframe_counint25hours606025minutes6025tframe_counint25hours60minutes6025tframe_counintseconds1500hours000,90tframe_counint6025hours606025tframe_counintminutes24%000,90tframe_c
45、ounint24%606025tframe_couninthourstime52inttframe_coun=+= = = += =SMPTE EG 40:2012 Page 10 of 21 pages 5.5.5 29.97. frames/sec drop frame ( )( )( )( )( )( )( )( )( )hours107,89210minutesint2minutes1798seconds30tframe_counhours18060603010minutesint2minutes26030seconds30tframe_counhours18010minutesint
46、2minutes2hours60minutes60seconds30tframe_counframeshours107,89210minutesint2minutes1798tframe_coun301inthours10860603010minutesint2minutes26030tframe_coun301inthours10810minutesint2minutes2hours60minutes6030tframe_coun301intsecondshours892,710000,81hours892,107tframe_counint28001hours892,107tframe_counint2tframe_coun18001intminutes24%107,892tframe_counint24%108606030tframe_couninthourstime1001100030inttframe_coun=+=+=+= +=SMPTE EG 40:2012 Page 11 of 21 pages 5.5.6 29.97. frames/sec nondrop frame (