Discussion:
[FFmpeg-user] Extracting starting timecode info using ffmpeg/ffprobe
Kieran O Leary
2015-09-01 22:43:14 UTC
Permalink
I am trying to create h264 low res proxies that have a burnt in
timecode which derives from the source video's timecode. I'm making a
bash script that stores the value and uses it as the starting timecode
for the drawtext filter. Can anyone recommend a way for ffprobe or
ffmpeg to always return a timecode start value? I'm guessing that I'm
calling the wrong command?

From some googling, I've had occasional success with the following command:
ffprobe.exe -show_entries format_tags=timecode -of
default=noprint_wrappers=1 inputfile

I've found that I had to use "format_tags=timecode" as
"format=timecode" would not return a value (only mentioning this as
the ffprobe tips page uses the latter in its examples).

Some videos produce a timecode value, some don't, even though my test
videos show a timecode in ffprobe/mediainfo regardless. I was using -v
error as recommended by the ffprobe tips page.

Full output of a file that shows a timecode value, followed by one
that does not return a value.
ffmpeg-20150901-git-b54e03c-win64-static\ffmpeg-20150901-git-b54e03c-win64-static\bin\ffprobe.exe
-show_entries format_tags=timecode -of default=noprint_wrappers=1
DHC36.v210.pcm.mov
ffprobe version N-74751-gb54e03c Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libbs2b --enable-libcaca --enable-libdcadec
--enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs
--enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 59.100 / 56. 59.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.100 / 5. 40.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'DHC36.v210.pcm.mov':
Metadata:
creation_time : 2010-05-25 22:46:56
timecode : 00:30:40:13
Duration: 00:00:09.91, start: 0.040375, bitrate: 230674 kb/s
Stream #0:0(eng): Video: v210 (v210 / 0x30313276),
yuv422p10le(bt470bg/smpte240m/unknown), 720x486, 222820 kb/s, 29.85
fps, 29.97 tbr, 2997 tbn, 2997 tbc (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
encoder : Uncompressed 10 bit
timecode : 00:30:40:13
Stream #0:1(eng): Subtitle: eia_608 (c608 / 0x38303663), 640x480,
4 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz,
mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz,
mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz,
mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz,
mono, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
Stream #0:6(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
Metadata:
creation_time : 2010-05-25 22:47:06
handler_name : Apple Alias Data Handler
reel_name : DHC0034_1984.0040_pmaster
timecode : 00:30:40:13
Unsupported codec with id 0 for input stream 6
TAG:timecode=00:30:40:13


Video that does not declare a timecode even though I can see timecode
values in the ffprobe readout:

ffmpeg-20150901-git-b54e03c-win64-static\ffmpeg-20150901-git-b54e03c-win64-static\bin\ffprobe.exe
-show_entries format_tags=timecode -of default=noprint_wrappers=1
ffv1.mkv
ffprobe version N-74751-gb54e03c Copyright (c) 2007-2015 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libbs2b --enable-libcaca --enable-libdcadec
--enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs
--enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 59.100 / 56. 59.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.100 / 5. 40.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, matroska,webm, from 'ffv1.mkv':
Metadata:
COMPATIBLE_BRANDS: qt
MAJOR_BRAND : qt
MINOR_VERSION : 512
ENCODER : Lavf56.40.101
Duration: 00:00:57.64, start: 0.000000, bitrate: 23305 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1
DAR 16:9, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
TIMECODE : 10:00:00:00
ENCODER : Lavc56.57.100 libx264
DURATION : 00:00:57.640000000
Stream #0:1(eng): Audio: pcm_s24le, 48000 Hz, 2 channels, s32 (24
bit), 2304 kb/s (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
DURATION : 00:00:56.160000000
Kieran O Leary
2015-09-01 23:03:06 UTC
Permalink
On Tue, Sep 1, 2015 at 11:43 PM, Kieran O Leary
Post by Kieran O Leary
ffprobe.exe -show_entries format_tags=timecode -of
default=noprint_wrappers=1 inputfile
I've found that I had to use "format_tags=timecode" as
"format=timecode" would not return a value (only mentioning this as
the ffprobe tips page uses the latter in its examples).
So I took another look at the ffprobe tips, and I realise that I
should have been using -show_entries stream instead of format. This
has produced a much more consistent output. I'd still welcome any
feedback.
Francois Visagie
2015-09-02 09:03:27 UTC
Permalink
-----Original Message-----
Kieran O Leary
Sent: 02 September 2015 01:03
Subject: Re: [FFmpeg-user] Extracting starting timecode info using
ffmpeg/ffprobe
Post by Kieran O Leary
From some googling, I've had occasional success with the following
ffprobe.exe -show_entries format_tags=timecode -of
default=noprint_wrappers=1 inputfile
I've found that I had to use "format_tags=timecode" as
"format=timecode" would not return a value (only mentioning this as
the ffprobe tips page uses the latter in its examples).
So I took another look at the ffprobe tips, and I realise that I should have
been using -show_entries stream instead of format. This has produced a
much more consistent output. I'd still welcome any feedback.
What is the exact command-line that works better for you now, along with some sample output?

The reason I ask is that after trying much I gave up on ffprobe for this purpose and started using exiftool instead. Instead of storing the original starting timecode in the file, I wrote a script that renames video files to "CCYYMMDDHHMMSSFF.ext ", using the earliest timecode reported by exiftool. Apart from being useful for ordering files, subsequent processes can then also use the filename to seed timecode counting e.g. for display purposes during editing, much as you seem to intend.

I'm unsure whether exiftool is available on platforms other than Windows.
Kieran O Leary
2015-09-03 08:26:28 UTC
Permalink
On Wed, Sep 2, 2015 at 10:03 AM, Francois Visagie
Post by Francois Visagie
What is the exact command-line that works better for you now, along with some sample output?
Here's the script, by the way, can you send me yours?
https://github.com/kieranjol/ifi-ffv1
Here's what the console looks like when it's executing that part of my script.

+ framerate=($(ffprobe -v error -select_streams v:0 -show_entries
stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 "$1"))

++ ffprobe -v error -select_streams v:0 -show_entries
stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1
'augtest/v210 space.mov'

+ IFS=:

+ read -a timecode

++ ffprobe -v error -show_entries stream_tags=timecode -of
default=noprint_wrappers=1:nokey=1 '/augtest/v210 space.mov'

+ printf -v timecode ''\''%s\:%s\:%s\:%s'\''' 01 00 00 00

+ echo ''\''01\:00\:00\:00'\'''

'01\:00\:00\:00'

+ drawtext_options=(fontsize=45 fontfile="/Library/Fonts/Arial
Black.ttf" fontcolor=white timecode="$timecode" rate="$framerate"
boxcolor=0x000000AA box=1 x=360-text_w/2 y=480)

++ IFS=:

++ echo 'fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxcolor=0x000000AA:box=1:x=360-text_w/2:y=480'

+ drawtext_options='fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxcolor=0x000000AA:box=1:x=360-text_w/2:y=480'

+ ffmpeg -i '//augtest/v210 space.mov' -c:v libx264 -crf 23 -pix_fmt
yuv420p -vf 'drawtext=fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxcolor=0x000000AA:box=1:x=360-text_w/2:y=480'
'/augtest/v210 space/proxy/v210 space_BITC.mov'

ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers

built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)

configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1
--enable-shared --enable-pthreads --enable-gpl --enable-version3
--enable-hardcoded-tables --enable-avresample --cc=clang
--host-cflags= --host-ldflags= --enable-opencl --enable-libx264
--enable-libmp3lame --enable-libvo-aacenc --enable-libxvid
--enable-libfreetype --enable-libfaac --enable-libass --enable-ffplay
--enable-libopenjpeg --disable-decoder=jpeg2000
--extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5
' --enable-nonfree --enable-vda

libavutil 54. 27.100 / 54. 27.100

libavcodec 56. 41.100 / 56. 41.100

libavformat 56. 36.100 / 56. 36.100

libavdevice 56. 4.100 / 56. 4.100

libavfilter 5. 16.101 / 5. 16.101

libavresample 2. 1. 0 / 2. 1. 0

libswscale 3. 1.101 / 3. 1.101

libswresample 1. 2.100 / 1. 2.100

libpostproc 53. 3.100 / 53. 3.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/augtest/v210 space.mov':

Metadata:

major_brand : qt

minor_version : 512

compatible_brands: qt

encoder : Lavf56.36.100

Duration: 00:00:01.02, start: 0.021333, bitrate: 219045 kb/s

Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le,
720x486, 223724 kb/s, SAR 10:11 DAR 400:297, 29.97 fps, 29.97 tbr,
11988 tbn, 11988 tbc (default)

Metadata:

handler_name : DataHandler

encoder : Lavc56.41.100 v210

timecode : 01:00:00:00

Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 110 kb/s (default)

Metadata:

handler_name : DataHandler

Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s

Metadata:

handler_name : DataHandler

timecode : 01:00:00:00

[libx264 @ 0x7fa2f382f000] using SAR=10/11

[libx264 @ 0x7fa2f382f000] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX

[libx264 @ 0x7fa2f382f000] profile High, level 3.1

[libx264 @ 0x7fa2f382f000] 264 - core 146 r2555 0c21480 - H.264/MPEG-4
AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00

Output #0, mov, to '/augtest/v210 space/proxy/v210 space_BITC.mov':

Metadata:

major_brand : qt

minor_version : 512

compatible_brands: qt

encoder : Lavf56.36.100

Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661),
yuv420p, 720x486 [SAR 10:11 DAR 400:297], q=-1--1, 29.97 fps, 11988
tbn, 29.97 tbc (default)

Metadata:

handler_name : DataHandler

timecode : 01:00:00:00

encoder : Lavc56.41.100 libx264

Stream #0:1(eng): Audio: aac (libfaac) (mp4a / 0x6134706D), 48000
Hz, stereo, s16, 128 kb/s (default)

Metadata:

handler_name : DataHandler

encoder : Lavc56.41.100 libfaac

Stream mapping:

Stream #0:0 -> #0:0 (v210 (native) -> h264 (libx264))

Stream #0:1 -> #0:1 (aac (native) -> aac (libfaac))

Press [q] to stop, [?] for help

frame= 31 fps=0.0 q=-1.0 Lsize= 517kB time=00:00:01.02
bitrate=4134.2kbits/s dup=1 drop=0

video:500kB audio:14kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.562701%

[libx264 @ 0x7fa2f382f000] frame I:2 Avg QP:30.83 size: 50676

[libx264 @ 0x7fa2f382f000] frame P:29 Avg QP:27.50 size: 14149

[libx264 @ 0x7fa2f382f000] mb I I16..4: 16.4% 47.1% 36.5%

[libx264 @ 0x7fa2f382f000] mb P I16..4: 16.8% 23.6% 6.6% P16..4:
28.8% 6.3% 4.0% 0.0% 0.0% skip:13.9%

[libx264 @ 0x7fa2f382f000] 8x8 transform intra:49.9% inter:82.5%

[libx264 @ 0x7fa2f382f000] coded y,uvDC,uvAC intra: 52.3% 72.6% 42.9%
inter: 20.4% 60.6% 12.3%

[libx264 @ 0x7fa2f382f000] i16 v,h,dc,p: 59% 35% 4% 3%

[libx264 @ 0x7fa2f382f000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 20% 30%
2% 1% 1% 1% 2% 2%

[libx264 @ 0x7fa2f382f000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 64% 11%
1% 1% 1% 1% 1% 2%

[libx264 @ 0x7fa2f382f000] i8c dc,h,v,p: 25% 43% 24% 9%

[libx264 @ 0x7fa2f382f000] Weighted P-Frames: Y:3.4% UV:0.0%

[libx264 @ 0x7fa2f382f000] ref P L0: 57.9% 10.1% 22.4% 9.5% 0.1%

[libx264 @ 0x7fa2f382f000] kb/s:3957.32

+ break
Francois Visagie
2015-09-03 12:02:07 UTC
Permalink
-----Original Message-----
Kieran O Leary
Sent: 03 September 2015 10:26
To: FFmpeg user questions
Subject: Re: [FFmpeg-user] Extracting starting timecode info using
ffmpeg/ffprobe
On Wed, Sep 2, 2015 at 10:03 AM, Francois Visagie
Post by Francois Visagie
What is the exact command-line that works better for you now, along with
some sample output?
Here's the script, by the way, can you send me yours?
https://github.com/kieranjol/ifi-ffv1
Here's what the console looks like when it's executing that part of my script.
+ framerate=($(ffprobe -v error -select_streams v:0 -show_entries
stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 "$1"))
++ ffprobe -v error -select_streams v:0 -show_entries
stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1
'augtest/v210 space.mov'
+ read -a timecode
++ ffprobe -v error -show_entries stream_tags=timecode -of
default=noprint_wrappers=1:nokey=1 '/augtest/v210 space.mov'
+ printf -v timecode ''\''%s\:%s\:%s\:%s'\''' 01 00 00 00
+ echo ''\''01\:00\:00\:00'\'''
'01\:00\:00\:00'
+ drawtext_options=(fontsize=45 fontfile="/Library/Fonts/Arial
Black.ttf" fontcolor=white timecode="$timecode" rate="$framerate"
boxcolor=0x000000AA box=1 x=360-text_w/2 y=480)
++ echo 'fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxc
olor=0x000000AA:box=1:x=360-text_w/2:y=480'
+ drawtext_options='fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxc
olor=0x000000AA:box=1:x=360-text_w/2:y=480'
+ ffmpeg -i '//augtest/v210 space.mov' -c:v libx264 -crf 23 -pix_fmt
yuv420p -vf 'drawtext=fontsize=45:fontfile=/Library/Fonts/Arial
Black.ttf:fontcolor=white:timecode='\''01\:00\:00\:00'\'':rate=2997/100:boxc
olor=0x000000AA:box=1:x=360-text_w/2:y=480'
'/augtest/v210 space/proxy/v210 space_BITC.mov'
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1
--enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-
hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-
ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-
libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libfaac --enable-
libass --enable-ffplay --enable-libopenjpeg --disable-decoder=jpeg2000
--extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5
' --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf56.36.100
Duration: 00:00:01.02, start: 0.021333, bitrate: 219045 kb/s
Stream #0:0(eng): Video: v210 (v210 / 0x30313276), yuv422p10le, 720x486,
223724 kb/s, SAR 10:11 DAR 400:297, 29.97 fps, 29.97 tbr,
11988 tbn, 11988 tbc (default)
handler_name : DataHandler
encoder : Lavc56.41.100 v210
timecode : 01:00:00:00
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 110 kb/s (default)
handler_name : DataHandler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74), 0 kb/s
handler_name : DataHandler
timecode : 01:00:00:00
SSE4.2 AVX
codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
major_brand : qt
minor_version : 512
compatible_brands: qt
encoder : Lavf56.36.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p,
720x486 [SAR 10:11 DAR 400:297], q=-1--1, 29.97 fps, 11988 tbn, 29.97 tbc
(default)
handler_name : DataHandler
timecode : 01:00:00:00
encoder : Lavc56.41.100 libx264
Stream #0:1(eng): Audio: aac (libfaac) (mp4a / 0x6134706D), 48000 Hz,
stereo, s16, 128 kb/s (default)
handler_name : DataHandler
encoder : Lavc56.41.100 libfaac
Stream #0:0 -> #0:0 (v210 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (libfaac))
Press [q] to stop, [?] for help
frame= 31 fps=0.0 q=-1.0 Lsize= 517kB time=00:00:01.02
bitrate=4134.2kbits/s dup=1 drop=0
video:500kB audio:14kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.562701%
28.8% 6.3% 4.0% 0.0% 0.0% skip:13.9%
inter: 20.4% 60.6% 12.3%
1% 1% 2% 2%
1% 1% 1% 2%
+ break
Pretty tidy script, that :-).

It appears we're looking for different information - you for a (single) stream-level timecode tag, and me for the per-frame one. I calibrate the camera timecode to absolute time and intend to use frame timecodes for time synchronisation during editing.

FWIW:

1. exiftool's per-frame output looks as follows:
...
Time Code : 17:51:41:22
Date/Time Original : 2014:01:30 17:51:42+02:00
Aperture Setting : 1.8
Gain : 0 dB
Exposure Program : Program AE
White Balance : Auto
Focus : Auto (0)
Image Stabilization : Off
Exposure Time : 1/50
Make : Canon
Recording Mode : Unknown (8)
Capture Frame Rate : 50
Video Frame Rate : 50
Audio Sample Rate : 48000
Time Code : 17:51:41:21
...

2. The file rename script MU_TC2name (the BELL character displays as a round dot):
@echo off
setlocal
setlocal ENABLEDELAYEDEXPANSION

goto INIT

:HELP
echo.
echo Metadata Utilities TC2name v1.0 (c) F. Visagie 2014/06/14
echo Function: rename video file to creation time of earliest frame, i.e. CCYYMMDDHHMMSSFF.ext
echo.
echo Usage:
echo MU_TC2name file [TCabsolute [TCspaired]] [frames]]]
echo.
echo where:
echo file video file to rename
echo TCabsolute 1=TimeCodes contain absolute HH:MM:SS:FF value used directly for new filename
echo 0=TimeCodes contain relative frame count added to DateTimeOriginal for new filename
echo (default %TCSABSLT%)
echo TCspaired 1=pairs of consecutive frames share the same TimeCode, e.g. Canon HF G30 AVCHD @50p
echo 0=individual frames have unique TimeCode values
echo (default %TCSPAIRD%)
echo frames number of frames at start of video to inspect for earliest TimeCode (default %READFRMS%)

rem Version History
rem v1.0 2014/06/14: Initial creation

:ERRPAUSE
echo

pause
goto END

:INIT
rem Control settings
rem ----------------
set READFRMS=5
rem Pairs of consecutive frames sharing same TimeCode, e.g. Canon HF G30 AVCHD @50p
set TCSPAIRD=1
rem No specific reference offset to TCs (i.e. relative) vs. referencing time of recording (i.e. absolute)
set TCSABSLT=1
rem Set to 'rem' to disable debug logging
set DSABLDBG=rem

rem Tag values used
rem ---------------
set TCTAG=TimeCode
set DTTAG=DateTimeOriginal

rem Parse input file
if [%1] == [] goto HELP
if [%1] == [?] goto HELP
if [%1] == [-?] goto HELP
if [%1] == [/?] goto HELP
if /i [%1] == [h] goto HELP
if /i [%1] == [-h] goto HELP
if /i [%1] == [/h] goto HELP
if /i [%1] == [help] goto HELP
if /i [%1] == [-help] goto HELP
if /i [%1] == [/help] goto HELP

if exist %1. goto GETTCABS
echo.
echo Invalid input file %1!
echo HINT: If it contains spaces, enclose input filename in quotes
goto ERRPAUSE

:GETTCABS
if [%2] equ [] goto MAIN
if [%2] equ [0] goto SETTCABS
if [%2] equ [1] goto SETTCABS
echo.
echo Invalid TCabsolute flag %2!
goto ERRPAUSE
:SETTCABS
set TCSABSLT=%2

if [%3] equ [] goto MAIN
if [%3] equ [0] goto SETTCPAR
if [%3] equ [1] goto SETTCPAR
echo.
echo Invalid TCspaired flag %3!
goto ERRPAUSE

:SETTCPAR
set TCSPAIRD=%3

if not [%4] equ [] set READFRMS=%4

:MAIN
%DSABLDBG% echo READFRMS: %READFRMS%&echo.
set TCOLD=23:59:59:999
set TC=%TCOLD%
set TCUPDATD=0
set DT=
set FRMSREAD=0
rem Even for relative TCs, look for earliest TC in case file had been cut
for /f "usebackq tokens=1* delims=: " %%i in (`exiftool -%TCTAG% -%DTTAG% -g0 -n -s2 -e -ee %1`) do (
%DSABLDBG% echo Read %%i: %%j
if /i %%i equ %TCTAG% (
if %%j lss !TC! (
set TC=%%j
rem Flag TimeCode updated in this frame
set TCUPDATD=1
)
) else (
if /i %%i equ %DTTAG% (
if !TCUPDATD! equ 1 (
rem Strip off any trailing timezone information
for /f "tokens=1* delims=+" %%I in ("%%j") do set DT=%%I
%DSABLDBG% echo ^> Updated TC: !TC!, DT: !DT!
set TCUPDATD=0
)
set /a FRMSREAD+=1
if !FRMSREAD! equ %READFRMS% goto GOTFRAMS
)
)
)
echo.
echo Found only %FRMSREAD% of required %READFRMS% occurrences of tag %DTTAG%
goto ERRPAUSE

:GOTFRAMS
%DSABLDBG% echo.&echo Final TCOLD: %TCOLD%, TC: %TC%, DT: %DT%
if %TC% equ %TCOLD% (
echo.
echo Failed to find %TCTAG% tag in first %READFRMS% frames
goto ERRPAUSE
)

for /f "tokens=1-4 delims=:" %%i in ("%TC%") do (
set HH=%%i
set MM=%%j
set SS=%%k
set FF=%%l
)
if %TCSPAIRD% equ 1 set /a FF*=2
%DSABLDBG% echo TCSPAIRD=%TCSPAIRD%: HH:MM:SS:FF=%HH%:%MM%:%SS%:%FF%
%DSABLDBG% echo TCSABSLT=%TCSABSLT%
if %TCSABSLT% equ 1 (
for /f "tokens=1-3 delims=: " %%i in ("%DT%") do set FILENAME=%%i%%j%%k%HH%%MM%%SS%
) else (
for /f "tokens=1-6 delims=: " %%i in ("%DT%") do set FILENAME=%%i%%j%%k%%l%%m%%n
)
set FILENAME=%FILENAME%%FF%
%DSABLDBG% echo Filename=%FILENAME%
for /f %%i in ("%1") do ren %1 %FILENAME%%%~xi

:END
set READFRMS=
set TCSPAIRD=
set TCSABSLT=
set DSABLDBG=
set TCTAG=
set DTTAG=
set TCOLD=
set TC=
set TCUPDATD=
set DT=
set FRMSREAD=
set HH=
set MM=
set SS=
set FF=
set FILENAME=
setlocal DISABLEDELAYEDEXPANSION
endlocal
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Loading...