Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd February 2024, 01:13   #1  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: Japan
Posts: 29
How to add a time code to H264

How to add a time code to H264
Time code of first frame: 01:00:00:00
  1. General
  2. Complete name : C:\Users\Use\Desktop\00000.264
  3. Format : AVC
  4. Format/Info : Advanced Video Codec
  5. File size : 85.9 MiB
  6. Overall bit rate mode : Constant
  7. Frame rate : 23.976 FPS
  8. Video
  9. Format : AVC
  10. Format/Info : Advanced Video Codec
  11. Format profile : High@L4.1
  12. Format settings : CABAC / 4 Ref Frames
  13. Format settings, CABAC : Yes
  14. Format settings, Reference frames : 4 frames
  15. Format settings, Slice count : 4 slices per frame
  16. Bit rate mode : Constant
  17. Bit rate : 18.0 Mb/s
  18. Width : 1 920 pixels
  19. Height : 1 080 pixels
  20. Display aspect ratio : 16:9
  21. Frame rate : 23.976 (24000/1001) FPS
  22. Color space : YUV
  23. Chroma subsampling : 4:2:0
  24. Bit depth : 8 bits
  25. Scan type : Progressive
  26. Bits/(Pixel*Frame) : 0.362
  27. Time code of first frame : 01:00:00:00

I don't know how to add a time code?
KSSW is offline   Reply With Quote
Old 22nd February 2024, 12:08   #2  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,335
https://stackoverflow.com/questions/...ide-video-file might help
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 23rd February 2024, 02:12   #3  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: Japan
Posts: 29
If you follow this method, there will be no Time code of first frame: 01:00:00:00
Instead, there will be the following:



KSSW is offline   Reply With Quote
Old 23rd February 2024, 15:15   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,335
Ah okay, so set simply changes the first time code not set this info.
What do you get if you call:
Quote:
ffmpeg -i "path to inpu" -f ffmetadata in.txt
in the ffmetadata.txt if you call it on one of the files with this info?
If it includes the info you can probably use '-metadata' option in ffmpeg to set the info.

Quote:
Time code of first frame : 01:00:00:00
I only have this info on Quicktime Time code streams not on the raw video,...
Code:
Other
ID                                       : 3
Type                                     : Time code
Format                                   : QuickTime TC
Duration                                 : 160 ms
Frame rate                               : 25.000 FPS
Time code of first frame                 : 01:00:00:00
Time code of last frame                  : 01:00:00:03
Time code, stripped                      : Yes
Language                                 : English
Encoded date                             : 2016-01-18 21:44:55 UTC
Tagged date                              : 2016-01-18 21:44:55 UTC
Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 23rd February 2024 at 15:18.
Selur is offline   Reply With Quote
Old 23rd February 2024, 15:30   #5  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,335
I tried:
Code:
ffmpeg -y -i "g:\TestClips&Co\files\5000frames.mp4"  -timecode 01:02:03.04 -c copy g:\Output\test.mkv
and got:
Code:
General
Unique ID                                : 53443209611799196111184538750715928172 (0x2834C9AB657FEA584932404B99939E6C)
Complete name                            : g:\Output\test.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 799 KiB
Duration                                 : 3 min 20 s
Overall bit rate                         : 32.7 kb/s
Frame rate                               : 25.000 FPS
Writing application                      : Lavf60.20.100
Writing library                          : Lavf60.20.100
ErrorDetectionType                       : Per level 1
Time code of first frame                 : 01:02:03.04
Time code source                         : Matroska tags

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L4.1@Main
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 3 min 20 s
Bit rate                                 : 32.1 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.004
Stream size                              : 784 KiB (98%)
Writing library                          : x265 2.6+22-ff02513b92c0:[Windows][GCC 7.2.0][64 bit] 10bit
Encoding settings                        : cpuid=1173503 / frame-threads=4 / numa-pools=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=640x480 / interlace=0 / total-frames=0 / level-idc=41 / high-tier=0 / uhd-bd=0 / ref=3 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=25 / keyint=250 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=0 / scenecut=40 / radl=0 / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / weightp / no-weightb / no-analyze-src-pics / deblock=-1:-1 / sao / no-sao-non-deblock / rd=3 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.50 / psy-rdoq=10.00 / no-rd-refine / no-lossless / cbqpoffs=-2 / crqpoffs=-2 / rc=crf / crf=18.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=20000 / vbv-bufsize=20000 / vbv-init=0.9 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=1 / aq-strength=0.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=8 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=0 / overscan=0 / videoformat=5 / range=0 / colorprim=2 / transfer=2 / colormatrix=5 / chromaloc=0 / display-window=0 / max-cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr / no-hdr-opt / no-dhdr10-opt / analysis-save=(null) / analysis-load=(null) / analysis-reuse-level=5 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=0 / limit-sao / ctu-info=0 / no-lowpass-dct / refine-mv-type=0 / copy-pic=1
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Matrix coefficients                      : BT.470 System B/G
VENDOR_ID                                : [0][0][0][0]
video stream didn't chante to vfr, this might not be caused by the '-timecode ....' settings, but by something else.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 24th February 2024, 07:43   #6  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: Japan
Posts: 29
Quote:
Originally Posted by Selur View Post
Ah okay, so set simply changes the first time code not set this info.
What do you get if you call:

in the ffmetadata.txt if you call it on one of the files with this info?
If it includes the info you can probably use '-metadata' option in ffmpeg to set the info.


I only have this info on Quicktime Time code streams not on the raw video,...
Code:
Other
ID                                       : 3
Type                                     : Time code
Format                                   : QuickTime TC
Duration                                 : 160 ms
Frame rate                               : 25.000 FPS
Time code of first frame                 : 01:00:00:00
Time code of last frame                  : 01:00:00:03
Time code, stripped                      : Yes
Language                                 : English
Encoded date                             : 2016-01-18 21:44:55 UTC
Tagged date                              : 2016-01-18 21:44:55 UTC
Cu Selur
Hello Selur

Thank you for your the previous answer

So how does below H264 RAW file generate the time code (Time code of first frame : 01:00:00:00) parameter?

This is the H264 RAW file
https://drive.google.com/file/d/1DH_...usp=drive_link

If want to solve the problem

Container encapsulated time code parameters It is not advisable

But rather, the time code parameters need to be included in the RAW video file This is the main problem

Or perhaps the H264 RAW file of FFmpeg does not support the time code parameter at all (Time code of first frame: 01:00:00:00)

Last edited by KSSW; 24th February 2024 at 08:59.
KSSW is offline   Reply With Quote
Old 24th February 2024, 08:44   #7  |  Link
rwill
Registered User
 
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 373
Disclaimer: I have not looked at the example raw h.264 stream.

There can be a time code in the picture timing SEI message in H.264. It can contain hours:minutes:seconds:frames. How you get x264 to write such a timecode to the picture timing SEI I do not know.
rwill is offline   Reply With Quote
Old 24th February 2024, 08:57   #8  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: Japan
Posts: 29
Quote:
Originally Posted by rwill View Post
Disclaimer: I have not looked at the example raw h.264 stream.

There can be a time code in the picture timing SEI message in H.264. It can contain hours:minutes:seconds:frames. How you get x264 to write such a timecode to the picture timing SEI I do not know.
It was deleted just now and now it has been reissued

This is the H264 RAW file
https://drive.google.com/file/d/1DH_...usp=drive_link

Last edited by KSSW; 24th February 2024 at 09:01.
KSSW is offline   Reply With Quote
Old 24th February 2024, 10:31   #9  |  Link
KSSW
Registered User
 
Join Date: Sep 2022
Location: Japan
Posts: 29
Videos downloaded randomly from websites
KSSW is offline   Reply With Quote
Old 24th February 2024, 17:34   #10  |  Link
ivanb
Registered User
 
Join Date: May 2023
Posts: 26
Timecode is indeed contained within the pic_struct. Unfortunately, I haven't found a way to write it using x264.
ivanb is offline   Reply With Quote
Old 24th February 2024, 17:46   #11  |  Link
ivanb
Registered User
 
Join Date: May 2023
Posts: 26
Here is what x264 source says about it:
Code:
        
// These clock timestamps are not standardised so we don't set them
// They could be time of origin, capture or alternative ideal display
for( int i = 0; i < num_clock_ts[h->fenc->i_pic_struct]; i++ )
    bs_write1( &q, 0 ); // clock_timestamp_flag
ivanb is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.