VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 42
Thread
  1. Hi

    https://dl.dropboxusercontent.com/u/39871584/C0020.mxf

    I would like extract timecode from a .mxf file and type it on a .txt file

    e.g. from C0020.mxf I would like generate a .txt file that have 01:34:21:15

    OR, better,

    supposing 01:34:21:15 the timecode

    simply with a batch procedure I would like extract the timecode from a .mxf file and put (e.g.)

    01 in a enviroment variable called "A"
    34 in a enviroment variable called "B"
    21 in a enviroment variable called "C"
    15 in a enviroment variable called "D"


    is it possibile? thanks in advance
    Quote Quote  
  2. to parse timecode formated as you wrote into variables is easy
    Code:
    set timecode=01:34:21:15
    for /f "tokens=1* delims=:" %%a in ("%timecode%") do (set A=%%a)
    for /f "tokens=2* delims=:" %%a in ("%timecode%") do (set B=%%a)
    for /f "tokens=3* delims=:" %%a in ("%timecode%") do (set C=%%a)
    for /f "tokens=4* delims=:" %%a in ("%timecode%") do (set D=%%a)
    echo %A%:%B%:%C%:%D%
    but I have no idea how to take particular timecode from video at any time
    Quote Quote  
  3. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Code:
    set timecode=01:34:21.150
    for /f "tokens=1,2,3,4 delims=:." %%g in ("%timecode%") do (
         set HOUR=%%g
         set MINS=%%h
         set SECS=%%i
         set MILLI=%%j
    )
    echo %HOUR%:%MINS%:%SECS%.%MILLI%
    -Edit- According to every program I've ever use the timecode would more likely be 01:34:21.150

    -Edit2- Which Timecodes exactly? Specific ones? Key Frames? Or every video/audio frame in the file?
    Last edited by ndjamena; 7th May 2014 at 22:23.
    Quote Quote  
  4. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Oh, MediaInfo says there are two timecode tracks in the file... interesting.
    Quote Quote  
  5. I try to insert timecode into files generated with Virtuadub: it don't write timecode data in avi output file.
    But it's very difficult... I try to change the header of avi as this:

    Click image for larger version

Name:	TC10.JPG
Views:	530
Size:	173.0 KB
ID:	25082

    so my nle can read timecode, and VLC play correctly the avi file but virtualdub won't open the avi file (say "invalid avi file. The main "movi" block is missing)... so this procedure is not full regular.

    Please do you know some programs the at certain point replace a block of data as shown in the attached? thanks
    Quote Quote  
  6. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    I'm still trying to figure out how to extract timecodes from a mxf file. I've downloaded the asdcplib source code and I'm trying to compile it at the moment...

    It's still not clear what you're trying to do, and now you've just confused things even further by bringing something about modifying AVI's into it...
    Quote Quote  
  7. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    OK, I see now. You want to get the time code of the first frame and add it into a virtualdub re-encode because they all start at zero, which is generally something I'm quite happy with since I only re-encode DVDs and having the first frame start at 01:34:21.150 is just ugly. FFMPEG -i displays the first timecode and you need to separate it from the other junk using batch:

    Code:
    SetLocal DisableDelayedExapansion
    :START
    if [%1]==[] (
         EndLocal
         goto :eof
    )
    
    set "HOUR="
    for /f "tokens=1,2,3,4,5 delims=: " %%g in ('FFMPEG.EXE -I "%~1"') DO (
         if "%%~g"=="timecode" (
              set "HOUR=%%h"
              set "MINS=%%I"
              set "SECS=%%j"
              set "MILLI=%%k"
              goto :next
         )
    )
    :NEXT
    
    if "%HOUR%"=="" (
         echo NO TIMECODE FOUND IN:
         echo "%~1"
         pause
    ) else (
         echo HOURS: %HOUR%>>"text.txt"
         echo MINUTES: %MINS%>>"text.txt"
         echo SECONDS: %SECS%>>"text.txt"
         echo MILLISECONDS: %MILLI%>>"text.txt"
    )
    echo %HOUR%:%MINS%:%SECS%.%MILLI%
    SHIFT
    goto :START
    Doesn't work because somehow FFMPEG.exe is bypassing the for loop and printing directly to the screen. So you may have to use the MediaInfo CLI instead.

    So we've got to figure out either how to process FFMPEG's output using batch or figure out how to get the timecode using MediaInfo (MediaInfo GUI shows it so it must be possible).

    Now I've just got to figure out if it's possible to tell an avicontainer to start at non-zero:
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd318183(v=vs.85).aspx

    Aren't those time-codes kept in the stream in an AVI and not the container?
    Quote Quote  
  8. Doesn't work because somehow FFMPEG.exe is bypassing the for loop and printing directly to the screen.
    I'm no real Windows batch user, but doesn't your batch only capture the standard output and not the error output? (iirc. ffmpeg outputs it's statistics&co to the error output)
    Quote Quote  
  9. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Yup!

    http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/
    68 Jason says.

    Still researching, I don't think I'm being much help, but at lest I'm learning outside my comfort zone.
    Quote Quote  
  10. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Thar we go!

    Code:
    @if "%EMode%"=="" Set EMode=OFF
    @ECHO %EMode%
    SetLocal DisableDelayedExpansion
    :START
    if [%1]==[] (
         EndLocal
         goto :eof
    )
    
    set "HOUR="
    for /f "tokens=1,2,3,4,5 delims=: " %%g in ('FFPROBE.EXE "%~1" 2^>^&1') DO (
         if "%%~g"=="timecode" (
              set "HOUR=%%~h"
              set "MINS=%%~i"
              set "SECS=%%~j"
              set "MILLI=%%~k"
              goto :next
         )
    )
    :NEXT
    
    if "%HOUR%"=="" (
         echo NO TIMECODE FOUND IN:
         echo "%~1"
         pause
    ) else (
         echo HOURS: %HOUR%>>"text.txt"
         echo MINUTES: %MINS%>>"text.txt"
         echo SECONDS: %SECS%>>"text.txt"
         echo MILLISECONDS: %MILLI%>>"text.txt"
    )
    echo %HOUR%:%MINS%:%SECS%.%MILLI%
    SHIFT
    goto :START
    Part 1 complete!

    -Edit- Modify to your hearts content!
    Quote Quote  
  11. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    It's possible to write a small GUI to do what you ask calling MediiaInfo CLI but where on earth did you get 01:34:21:15 from c0020.mxf? It's an MPG file and I could not find any reference to that timecode by searching with a Hex editor. With your example you could just search for ISMP and then parse the date but you cannot just add it in to a file since it changes the whole structure of the file container.
    Quote Quote  
  12. Originally Posted by Budman1 View Post
    It's possible to write a small GUI to do what you ask calling MediiaInfo CLI but where on earth did you get 01:34:21:15 from c0020.mxf? It's an MPG file and I could not find any reference to that timecode by searching with a Hex editor. With your example you could just search for ISMP and then parse the date but you cannot just add it in to a file since it changes the whole structure of the file container.
    Generale
    Nome completo : D:\C0020.mxf
    Formato : MXF
    Nome commereciale : XDCAM HD422
    Profilo formato : OP-1a
    Impostazioni formato : Closed / Complete
    Dimensione : 263MiB
    Durata : 36s 600ms
    Bitrate totale : 60,3 Mbps
    Data codifica : 2013-05-24 22:12:18.000
    Creato con : SONY Opt 1.22
    Compressore : SONY Opt 1.22

    Video
    ID : 2
    Formato : MPEG Video
    Nome commereciale : XDCAM HD422
    Versione formato : Version 2
    Profilo formato : 4:2:2@High
    Impostazioni formato, BVOP : Si
    Impostazioni formato, Matrix : Personalizzato
    Impostazioni formato, GOP : M=3, N=12
    Format_Settings_Wrapping : Frame
    Durata : 36s 600ms
    Bitrate : 50,0 Mbps
    Larghezza : 1.920 pixel
    Altezza : 1.080 pixel
    Rapporto aspetto visualizzazione : 16:9
    Frame rate : 25,000 fps
    Standard : Component
    Spazio colore : YUV
    Croma subsampling : 4:2:2
    Profondità bit : 8 bit
    Tipo scansione : Interlacciato
    Ordine scansione : Top field first
    Modo compressione : Con perdita
    Bit/(pixel*frame) : 0.965
    Dimensione della traccia : 218MiB (83%)
    Colori primari : BT.709
    Caratteristiche trasferimento : BT.709
    Coefficienti matrici : BT.709

    Audio #1
    ID : 3
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #2
    ID : 4
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #3
    ID : 5
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #4
    ID : 6
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #5
    ID : 7
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #6
    ID : 8
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #7
    ID : 9
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Audio #8
    ID : 10
    Formato : PCM
    Impostazioni formato, Endianness : Little
    Format_Settings_Wrapping : Frame (AES)
    Durata : 36s 600ms
    Modalità bitrate : Costante
    Bitrate : 1.152 Kbps
    Canali : 1 canale
    Sampling rate : 48,0 KHz
    Profondità bit : 24 bit
    Dimensione della traccia : 5,03MiB (2%)

    Altri #1
    ID : 1
    Type : Time code
    Formato : MXF TC
    TimeCode_FirstFrame : 01:34:21:15
    TimeCode_Settings : Striped

    Altri #2
    Type : Time code
    Formato : SMPTE TC
    Modo muxing : SDTI
    TimeCode_FirstFrame : 01:34:21:15
    Quote Quote  
  13. Originally Posted by ndjamena View Post
    OK, I see now. You want to get the time code of the first frame and add it into a virtualdub re-encode because they all start at zero, which is generally something I'm quite happy with since I only re-encode DVDs and having the first frame start at 01:34:21.150 is just ugly. FFMPEG -i displays the first timecode and you need to separate it from the other junk using batch:

    Code:
    SetLocal DisableDelayedExapansion
    :START
    if [%1]==[] (
         EndLocal
         goto :eof
    )
    
    set "HOUR="
    for /f "tokens=1,2,3,4,5 delims=: " %%g in ('FFMPEG.EXE -I "%~1"') DO (
         if "%%~g"=="timecode" (
              set "HOUR=%%h"
              set "MINS=%%I"
              set "SECS=%%j"
              set "MILLI=%%k"
              goto :next
         )
    )
    :NEXT
    
    if "%HOUR%"=="" (
         echo NO TIMECODE FOUND IN:
         echo "%~1"
         pause
    ) else (
         echo HOURS: %HOUR%>>"text.txt"
         echo MINUTES: %MINS%>>"text.txt"
         echo SECONDS: %SECS%>>"text.txt"
         echo MILLISECONDS: %MILLI%>>"text.txt"
    )
    echo %HOUR%:%MINS%:%SECS%.%MILLI%
    SHIFT
    goto :START
    Doesn't work because somehow FFMPEG.exe is bypassing the for loop and printing directly to the screen. So you may have to use the MediaInfo CLI instead.

    So we've got to figure out either how to process FFMPEG's output using batch or figure out how to get the timecode using MediaInfo (MediaInfo GUI shows it so it must be possible).

    Now I've just got to figure out if it's possible to tell an avicontainer to start at non-zero:
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd318183(v=vs.85).aspx

    Aren't those time-codes kept in the stream in an AVI and not the container?
    my target is this:

    I have c0020.mxf as source and with virtualdub I have to re-rencode it in morgan m-jpeg codec, but the avi file output of virtualdub don't have timecode. So I try to add it.

    Poison suggested me to do this:

    ffmpeg -i c0020.mxf -f ffmetadata metadata.txt
    ffmpeg -i c0020.avi -i metadata.txt -map_metadata 1 -vcodec copy -an c0020a.avi

    where C0020.mxf are the virtualdub output file, and C0020a.avi are the goal file that have timecode. But this procedure have a problem:

    my nle, strangely, don't read well the c0020a.avi generated from ffmpeg (maybe is the new header or I don't) meanwhile it read perfetly files generated from virtualdub (c0020.avi)

    Now I try to manually add timecode into the header of c0020.avi... the best solution would be another: which Virtualdub was rewritten to include at least the "printing" of the initial timecode.

    Click image for larger version

Name:	TC12.JPG
Views:	409
Size:	468.2 KB
ID:	25090

    all attempts to replace a block of code within the file generated by virtualdub are a stopgap to the limit of the impossible: the risk is to demage the header of the .avi file making it unusable.

    I think the best way is to recompile virtualdub, if anyone can do it, so that it correctly write the timecode in the output avi file.
    Image Attached Files
    Quote Quote  
  14. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Um, does anyone think creating an AVISynth script that adds '01:34:21:15' worth of blank frames to the beginning of the file, encoding it and then cutting off the blanks would achieve anything worthwhile? I'm pretty sure the initial time-code should be in the actual video stream rather than at the container level.
    Last edited by ndjamena; 9th May 2014 at 07:26.
    Quote Quote  
  15. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Code:
    V1 = DirectShowSource("C0020.mxf")
    
    BlankClip(V1, length=(1*25*60*60)+(34*25*60)+(21*25)+15) ++ V1
    Does that help?

    I couldn't tell if the 15 was supposed to be 150 milliseconds or Frame 15 of 25 so I went with Frame 15. I could turn it into an automated batch script using FFProbe if you like.
    Quote Quote  
  16. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    marcorocchini,
    You said you wished to read an MXF file and print a text file with the timecode of the first frame. This will do it:
    Click image for larger version

Name:	ScreenHunter_66 May. 09 14.06.jpg
Views:	6270
Size:	38.4 KB
ID:	25107


    Do you want just one file or all in folder and do you just want the timecode or the name of the file in addition?

    01:34:21:15
    01:34:21:15

    or

    c0020.mxf = 01:34:21:15
    c0020.mpg = 01:34:21:15

    UPDATE: I haven't created the actual write to text file but that would end up in the TO folder location if that works.
    Quote Quote  
  17. Originally Posted by Budman1 View Post
    marcorocchini,
    You said you wished to read an MXF file and print a text file with the timecode of the first frame. This will do it:
    Image
    [Attachment 25107 - Click to enlarge]



    Do you want just one file or all in folder and do you just want the timecode or the name of the file in addition?

    01:34:21:15
    01:34:21:15

    or

    c0020.mxf = 01:34:21:15
    c0020.mpg = 01:34:21:15

    UPDATE: I haven't created the actual write to text file but that would end up in the TO folder location if that works.
    sorry: initially I tryed to extract the only timecode in a .txt file but my target is generate .avi files by virtualdub.

    My source is .mxf file : my target is .avi (mjpeg .avi) files possibly with timecode inserted from source.

    Source=C0020.mxf dest=C0020.avi (mjpeg .avi created by virtualdub, possibly with timecode)

    So you wonder? why you don't use ffmpeg to transcode in mjpeg?

    1) ffmpeg have a internal mjpeg codec his codec are not interlaced: progressive only. But I'm force to use interlace. The best mjpeg codec I have found is the Morgan Mjpeg codec V.3.99

    2) FFMPEG can insert timecode data (initialTimecode) into .avi file, and also into mjpeg .avi files, but ffmpeg generate a header .avi that are
    slightly incompatible with the mjpeg decompressor of my NLE.

    I can use virtualdub to generate the mjpeg .avi file with the morgan codec (c0020.avi, without timecode)
    and afterwards do:

    ffmpeg -i c0020.mxf -f ffmetadata metadata.txt
    ffmpeg -i c0020.avi -i metadata.txt -map_metadata 1 -vcodec copy -an c0020a.avi


    so I have a c0020a.avi that have timecode but my NLE play jeky the c0020a.avi because header .avi generate by ffmpeg are strangely incompatible.

    Maybe the only way to correctly add timecode is integrate this function internally at virtualdub ...
    Quote Quote  
  18. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    https://forum.videohelp.com/threads/364605-can-ffmpeg-directly-type-a-txt-file-with-onl...-timecode-data

    Check to see if %Timecode% is 2 characters long or more, then echo it into a file making sure to escape the last character in case it equals " 1", which it shouldn't, but you never know.

    Code:
    if NOT "%TimeCode:~2,1%"=="" echo %TimeCode:~0,-1%^%TimeCode:~-1,1%>"%~dpn1.txt"
    https://forum.videohelp.com/threads/364463-Avisynth-FFMS2-error-video-track-is-unseekab...=1#post2321703
    Quote Quote  
  19. mm so for example:
    I have a file C0020.mxf and for this file I would like generate a .txt that contatins only the timecode:

    if I do:

    ffmpeg -i c0020.mxf -f ffmetadata metadata.txt

    metadata.txt is (also in attachement):

    ;FFMETADATA1
    uid=41821e00-3664-05c1-0270-08004602023b
    generation_uid=41821e00-3664-05c2-0270-08004602023b
    company_name=SONY
    product_name=Opt
    product_version=1.22
    product_uid=060e2b34-0401-0103-0e06-012002010300
    modification_date=2013-05-24 22:12:18
    timecode=01:34:21:15

    so the script should isolate 01:34:21:15 from all the rest

    I should do a script that via commandline I type:

    tc.bat C0020.mxf

    and it generate a .txt that have 01:34:21:15

    can you help to do this? thanks
    Image Attached Files
    Last edited by marcorocchini; 18th May 2014 at 06:48.
    Quote Quote  
  20. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    My script can already do that. I'm not sure what you're trying to do or why you're asking.
    Quote Quote  
  21. I would like do a script that do this:

    in a dir I have a file C0020.mxf
    https://dl.dropboxusercontent.com/u/39871584/C0020.mxf

    from dos command I write:

    tc.bat C0020.mxf

    and it generate a C0020.txt that have 01:34:21:15 wich is the timecode

    I supposte it work with the ffmpeg (or others) but it's not important, the important is that the script generate a .txt file that contain timecode
    Quote Quote  
  22. possibly would be nice if I can drag and drop c0020.mxf into tc.bat and it generate c0020.txt
    Quote Quote  
  23. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    If you take my script, delete everything to do with virtualdubmod and it's files and folders, then add in the line I gave you this morning you'll have a script that does exactly that. Unless you really, really need to use FFMPEG rather than FFProbe for some reason.
    Quote Quote  
  24. I consider your:

    if NOT "%TimeCode:~2,1%"=="" echo %TimeCode:~0,-1%^%TimeCode:~-1,1%>"%~dpn1.txt"

    but I cannot understand if %timecode% is jet defined or not, what is the routine that define %timecode%

    I'd be curious to know what is the procedure using ffmpeg
    Quote Quote  
  25. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Code:
    for /f "tokens=1,2 delims=^=" %%g in ('FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~1" 2^>^&1') DO (
    		 if "%%~g"=="TAG:company_name" set "T_Company_Name=%%~h"
    		 if "%%~g"=="TAG:product_name" set "T_Product_Name=%%~h"
    		 if "%%~g"=="TAG:product_version" set "T_Product_Version=%%~h"
    		 if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h"
    		 if "%%~g"=="width" set "V_Width=%%~h"
    		 if "%%~g"=="height" set "V_Height=%%~h"
    		 if "%%~g"=="sample_aspect_ratio" set "V_PAR=%%~h"
    		 if "%%~g"=="codec_type" if "%%~h"=="audio" set /a AUCount+=1
    	)
    See the line with TAG:Timecode in it??? THAT'S where it's defined.

    Here:

    Code:
    @rem unless otherwise specified for debugging reasons turn echo off
    @if "%EMode%"=="" Set EMode=OFF
    @ECHO %EMode%
    
    rem delayed expansion is a bad idea when processing file names
    SetLocal DisableDelayedExpansion
    
    Set "EXTLIST=*.mxf"
    Set "DoPop=0"
    Set "ARGLVL=0"
    Set "FileName-DQ="
    
    echo Extracting Timecodes to .txt Files...
    echo.
    
    :MakeFolders
    Set "DestFolder="
    if "%DestFolder%"=="" goto :ARGS
    if EXIST "%DestFolder%" goto :ARGS
    type NUL
    mkdir "%DestFolder%"
    if "%ERRORLEVEL%"=="0" goto :ARGS
    echo Error!!! Cannot Make Destination Folder:
    echo "%DestFolder%"
    pause
    goto :eof
    
    rem process the arguments one by one.
    :ARGS
    	
    	rem if there are no further arguments then exit the batch.
    	if [%1]==[] (
    		if "%ARGLVL%"=="0" (
    			CALL :GetTargetName		
    			EndLocal
    			pause
    		)
    		goto :eof
    	)
    
    	rem wildcard processing
    	Set "FileName=%~1"
    	if "%FileName%"=="" (
    		SHIFT
    		goto :ARGS
    	)
    
    	rem if the argument doesn't exist in the file system in any form skip it.
    	if NOT EXIST %1 (
    		SHIFT
    		goto :ARGS
    	)
    
    	if NOT [%1]==[] if NOT "%FileName:^*=%%FileName:^?=%"=="%FileName%%FileName%" (
    		for %%w in (%1) DO (
    			Set /a ARGLVL+=1
    			CALL :ARGS "%%~fw"
    			Set /a ARGLVL-=1
    		)
    		SHIFT
    		goto :ARGS
    	)
    	Set "FileName="
    		
    	rem Set search/recursion variables
    	Set "Pattern=%EXTLIST%"
    	Set "STARTLVL=0"
    	Set "FOUNDLVL=1024"
    	
    	rem if the argument is the current directory then process everything in it.
    	if "%~f1"=="%CD%" (
    		echo Processing Directory; "%CD%"
    		CALL :START %1
    		SHIFT
    		goto :ARGS
    	)
    	rem Test if the argument is a directory, if it is move to it then process everything in it, if not then move to the file's parent directory and process the file.  Then return to starting directory.
    	Type NUL
    	pushd "%~f1" 2> nul
    	if NOT "%errorlevel%"=="0" (
    		if NOT "%CD%\"=="%~dp1" (
    			pushd "%~dp1"
    			Set "DoPop=1"
    		)
    		Set Pattern="%~nx1"
    	) else (
    		echo Processing Directory; "%~f1"
    		Set "DoPop=1"
    	)
    	CALL :START %1
    	if "%DoPop%"=="1" (
    		popd
    		Set "DoPop=0"
    	)
    	SHIFT
    
    goto :ARGS
    
    :START <CURRENT_ARG>
    
    	rem Count is superseded by FOUNDLVL but may still be useful for renaming purposes
    	Set "Count=0"
    	rem Process all files in the current directory fitting the arguments search pattern.
    	for /f "delims=" %%y in ('dir %Pattern% /b /od /a-d') do (
    		if /I NOT "%%~y"=="File Not Found" CALL :Process_File "%%~fy"
    	)
    	rem if it didn't find anything search all directories instead
    goto :eof
    	if "%Count%"=="0" if %STARTLVL% LSS %FOUNDLVL% (
    		for /d %%b in (*) do (
    			pushd "%%~fb"
    			echo Processing Directory; "%%~fb"
    			Set /a STARTLVL+=1
    			CALL :START "%%~fb"
    			Set /a STARTLVL-=1
    			popd
    		)
    	)
    
    goto :eof
    
    :Process_File <MXF_FILENAME>
    
    	Set /a Count+=1
    	Set "FOUNDLVL=%STARTLVL%"
    
    	echo Processing File; "%~nx1"
    	if /I NOT "%~x1"==".mxf" (
    		echo "%~nx1"
    		echo  Is not an mxf file.
    		pause
    		goto :eof
    	)
    
    	SetLocal DisableDelayedExpansion
    	rem Find TimeCode Info
    	Set AUCount=0;
    	for /f "tokens=1,* delims=^=" %%g in ('FFProbe -hide_banner -loglevel fatal -pretty -show_entries format_tags^=timecode^ "%~1" 2^>^&1') DO (
    		 if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h"
    	)
    	if "%TimeCode%"=="" (
    		echo Warning! no TimeCode Found!
    	) else (
    		if NOT "%TimeCode:~2,1%"=="" (
    			echo Timecode= %TIMECODE%
    			if "%DestFolder%"=="" (
    				echo %TimeCode:~0,-1%^%TimeCode:~-1,1%>"%~dpn1.txt"
    			) else (
    				echo %TimeCode:~0,-1%^%TimeCode:~-1,1%>"%DestFolder%\%~n1.txt"
    			)
    		)
    	)
    	echo.
    	echo Done!
    	echo.
    	EndLocal
    	
    goto :eof
    
    :GetTargetName
    
    	Set "FileName="
    	Set /p FileName=Enter Target Name:
    	
    	rem Add or remove double-quotes if necessary
    
    	if NOT DEFINED FileName (
    		Set "FileName-DQ="
    		goto :DQSkip
    	)
    	
    	Set "FileName-DQ=%FileName:"=%"
    	if NOT DEFINED FileName-DQ (
    		Set "FileName="
    		Set "FileName-DQ="
    		goto :DQSkip
    	)
    	
    	if EXIST "%FileName-DQ%" (
    		if "%FileName-DQ%"=="%FileName-DQ: =%" (
    			Set "FileName=%FileName-DQ%"
    		) else (
    			Set FileName="%FileName-DQ%"
    		)
    	)
    
    :DQSkip
    
    	if /I "%FileName-DQ%"=="" Set FileName="%CD%"
    	if /I "%FileName-DQ%"=="CD" Set FileName="%CD%"
    	if /I "%FileName-DQ%"=="EXIT" goto :eof
    	if /I "%FileName-DQ%"=="X" goto :eof
    	if /I "%FileName-DQ%"=="NOEXIT" goto :GetTargetName
    	if DEFINED FileName (
    		Set /a ARGLVL+=1
    		CALL :ARGS %FileName%
    		Set /a ARGLVL-=1
    	)
    	
    goto :GetTargetName
    That batch is only useful if putting timecodes into a txt file is all you want it to do, if you want it to do more, it's a waste of time. I've been updating the original script in the other thread to remove bugs. Use that if you want a more functional script.
    Quote Quote  
  26. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    If you are interested in a text file, you should see in my earlier post, I wrote a gui that pulls the date, lists the time code and saves it to a text file. I asked if you wanted something such name of file along with it. It is drag and drop as well.

    The other scripts here, privided by those that put in a lot of effort, work well also. You have several ways now to get your text file. Adding it to an avi is going to be a little more problem since I don't believe avi is originally set up for meta data unless its contained in the actual format of certain codecs.
    Quote Quote  
  27. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    I saw that, well done!
    Quote Quote  
  28. thanks budman, your bui I think if useful (but where is downloadable?) hoewver I have to put the timecode extract procedure internally to a batch process so for that I have to do is more useful the ndjamena's script. But a gui maybe helpful on many other occasions.

    In avifile timecode can be added even if the NLE can recognize it. Timecode data in general is suggested by the ISMP written inside the avi file. Virtualdub is not normally able to officially enter the timecode but with VirtualDubMod is possible to automate the insertion of timecode (changing a little VirtualDubMod.exe so that it can "print" ISMP in place e.g. of ISRC) by the addcomment option on the .vcf

    Click image for larger version

Name:	TG66.JPG
Views:	358
Size:	202.3 KB
ID:	25236
    Click image for larger version

Name:	TCF.JPG
Views:	2109
Size:	13.0 KB
ID:	25237
    Click image for larger version

Name:	VMOD2.JPG
Views:	283
Size:	270.4 KB
ID:	25238
    Quote Quote  
  29. Originally Posted by marcorocchini View Post
    I consider your:

    if NOT "%TimeCode:~2,1%"=="" echo %TimeCode:~0,-1%^%TimeCode:~-1,1%>"%~dpn1.txt"

    but I cannot understand if %timecode% is jet defined or not, what is the routine that define %timecode%

    I'd be curious to know what is the procedure using ffmpeg
    ndjamena please another thing:

    if I start from a file: metadata.txt (attached) and from it I would like extract timecode, how is the script?
    I tryed this but it don't work well

    for /F "usebackq tokens=1,* delims==" %%g in ("metadata.txt") DO (if "%%g"=="Timecode=" Set TimeCode %%h
    )
    Set "TimeCode=%TimeCode: =%"
    echo %TimeCode%


    please where I'm wrong in this case?
    Image Attached Files
    Last edited by marcorocchini; 18th May 2014 at 09:49.
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!