Get total duration of video files in a directory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












21














I have a list of .ts files:



out1.ts ... out749.ts out8159.ts out8818.ts


How can I get the total duration (running time) of all these files?










share|improve this question























  • How do you get the duration of a single file?
    – Hauke Laging
    Dec 2 '14 at 5:21










  • i dont know that too
    – k961
    Dec 2 '14 at 5:58










  • @Hauke Laging i found this program "mediainfo"
    – k961
    Dec 2 '14 at 6:09










  • These are media files, likely video.
    – slm
    Dec 2 '14 at 6:21






  • 1




    Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
    – Kantam Nagesh
    Dec 2 '14 at 7:17















21














I have a list of .ts files:



out1.ts ... out749.ts out8159.ts out8818.ts


How can I get the total duration (running time) of all these files?










share|improve this question























  • How do you get the duration of a single file?
    – Hauke Laging
    Dec 2 '14 at 5:21










  • i dont know that too
    – k961
    Dec 2 '14 at 5:58










  • @Hauke Laging i found this program "mediainfo"
    – k961
    Dec 2 '14 at 6:09










  • These are media files, likely video.
    – slm
    Dec 2 '14 at 6:21






  • 1




    Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
    – Kantam Nagesh
    Dec 2 '14 at 7:17













21












21








21


19





I have a list of .ts files:



out1.ts ... out749.ts out8159.ts out8818.ts


How can I get the total duration (running time) of all these files?










share|improve this question















I have a list of .ts files:



out1.ts ... out749.ts out8159.ts out8818.ts


How can I get the total duration (running time) of all these files?







shell-script video






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 '14 at 6:50









jasonwryan

49.3k14134184




49.3k14134184










asked Dec 2 '14 at 4:24









k961k961

235149




235149











  • How do you get the duration of a single file?
    – Hauke Laging
    Dec 2 '14 at 5:21










  • i dont know that too
    – k961
    Dec 2 '14 at 5:58










  • @Hauke Laging i found this program "mediainfo"
    – k961
    Dec 2 '14 at 6:09










  • These are media files, likely video.
    – slm
    Dec 2 '14 at 6:21






  • 1




    Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
    – Kantam Nagesh
    Dec 2 '14 at 7:17
















  • How do you get the duration of a single file?
    – Hauke Laging
    Dec 2 '14 at 5:21










  • i dont know that too
    – k961
    Dec 2 '14 at 5:58










  • @Hauke Laging i found this program "mediainfo"
    – k961
    Dec 2 '14 at 6:09










  • These are media files, likely video.
    – slm
    Dec 2 '14 at 6:21






  • 1




    Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
    – Kantam Nagesh
    Dec 2 '14 at 7:17















How do you get the duration of a single file?
– Hauke Laging
Dec 2 '14 at 5:21




How do you get the duration of a single file?
– Hauke Laging
Dec 2 '14 at 5:21












i dont know that too
– k961
Dec 2 '14 at 5:58




i dont know that too
– k961
Dec 2 '14 at 5:58












@Hauke Laging i found this program "mediainfo"
– k961
Dec 2 '14 at 6:09




@Hauke Laging i found this program "mediainfo"
– k961
Dec 2 '14 at 6:09












These are media files, likely video.
– slm
Dec 2 '14 at 6:21




These are media files, likely video.
– slm
Dec 2 '14 at 6:21




1




1




Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
– Kantam Nagesh
Dec 2 '14 at 7:17




Any media files(e.g: MP4, ASF & .264...) will have predefined standard header information, we can get the information from that file like resolution, frame rate, number of frames(GOP) & file length & duration of the media...
– Kantam Nagesh
Dec 2 '14 at 7:17










8 Answers
8






active

oldest

votes


















43














I have no .ts here but this works for .mp4. Use ffprobe (part of ffmpeg) to get the time in seconds, e.g:



ffprobe -v quiet -of csv=p=0 -show_entries format=duration Inception.mp4 
275.690000


so for all .mp4 files in the current dir:



find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ;
149.233333
130.146667
275.690000


then use paste to pass the output to bc and get the total time in seconds:



find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc
555.070000


So, for .ts files you could try:



find . -maxdepth 1 -iname '*.ts' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc


Another tool that works for the video files I have here is exiftool, e.g.:



exiftool -S -n Inception.mp4 | grep ^Duration
Duration: 275.69
exiftool -q -p '$Duration#' Inception.mp4
275.69


Total length for all .mp4 files in the current directory:



exiftool -S -n ./*.mp4 | awk '/^Duration/ print $2' | paste -sd+ -| bc
555.070000000000
exiftool -q -p '$Duration#' ./*.mp4 | awk 'sum += $0; ENDprint sum'
555.070000000000


You could also pipe the output to another command to convert the total to DD:HH:MM:SS, see the answers here.



Or use exiftool's internal ConvertDuration for that (you need a relatively recent version though):



exiftool -n -q -p '$Duration;our $sum;$_=ConvertDuration($sum+=$_)
' ./*.mp4| tail -n1
0:09:15





share|improve this answer






















  • Very nice, hadn't seen that trick w/ ffprobe before.
    – slm
    Dec 2 '14 at 7:24






  • 1




    Nice trick with paste and bc! much cleaner than with awk let's say.
    – fduff
    Dec 2 '14 at 12:03










  • @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
    – Stéphane Chazelas
    Dec 2 '14 at 12:29










  • Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
    – Joe
    Dec 16 '14 at 7:51










  • @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
    – don_crissti
    Dec 16 '14 at 17:09



















5














This uses ffmpeg and prints the time out in total seconds:



times=()
for f in *.ts; do
_t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ')
times+=("$_t")
done
echo "$times[@]" | sed 's/ /+/g' | bc


Explanation:



for f in *.ts; do iterates each of the files that ends in ".ts"



ffmpeg -i "$f" 2>&1 redirects output to stderr



grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' isolates the time



awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ' Converts time to seconds



times+=("$_t") adds the seconds to an array



echo "$times[@]" | sed 's/ /+/g' | bc expands each of the arguments and replaces the spaces and pipes it to bc a common linux calculator






share|improve this answer




















  • Nice! Also see my version which is heavily based on your ideas.
    – MvG
    Dec 2 '14 at 9:02










  • Short and elegant solution
    – Neo
    Mar 26 '17 at 2:48


















4














Streamlining @jmunsch's answer, and using the paste I just learned from @slm's answer, you could end up with something like this:



for i in *.ts; do LC_ALL=C ffmpeg -i "$i" 2>&1 | 
awk -F: '/Duration:/print $2*3600+$3*60+$4'; done | paste -sd+ | bc


Just like jmunsch did, I'm using ffmpeg to print the duration, ignoring the error about a missing output file and instead searching the error output for the duration line. I invoke ffmpeg with all aspects of the locale forced to the standard C locale, so that I won't have to worry about localized output messages.



Next I'm using a single awk instead of his grep | grep | head | tr | awk. That awk invocation looks for the (hopefully unique) line containing Duration:. Using colon as a separator, that label is field 1, the hours are field 2, the minutes filed 3 and the seconds field 4. The trailing comma after the seconds doesn't seem to bother my awk, but if someone has problems there, he could include a tr -d , in the pipeline between ffmpeg and awk.



Now comes the part from slm: I'm using paste to replace newlines with plus signs, but without affecting the trailing newline (contrary to the tr \n + I had in a previous version of this answer). That gives the sum expression which can be fed to bc.



Inspired by slm's idea of using date to handle time-like formats, here is a version which does use it to format the resulting seconds as days, hours, minutes and seconds with fractional part:



TZ=UTC+0 date +'%j %T.%N' --date=@$(for i in *.ts; do LC_ALL=C 
ffmpeg -i "$i" 2>&1 | awk -F: '/Duration:/print $2*3600+$3*60+$4'; done
| paste -sd+ | bc) | awk 'print $1-1 "d",$2' | sed 's/[.0]*$//'


The part inside $(…) is exactly as before. Using the @ character as an indication, we use this as the number of seconds since the 1 January 1970. The resulting “date” gets formatted as day of the year, time and nanoseconds. From that day of the year we subtract one, since an input of zero seconds already leads to day 1 of that year 1970. I don't think there is a way to get day of the year counts starting at zero.



The final sed gets rid of extra trailing zeros. The TZ setting should hopefully force the use of UTC, so that daylight saving time won't interfere with really large video collections. If you have more than one year worth of video, this approach still won't work, though.






share|improve this answer






























    3














    I'm not familiar with the .ts extension, but assuming they're some type of video file you can use ffmpeg to identify the duration of a file like so:



    $ ffmpeg -i some.mp4 2>&1 | grep Dura
    Duration: 00:23:17.01, start: 0.000000, bitrate: 504 kb/s


    We can then split this output up, selecting just the duration time.



    $ ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"
    00:23:17.01


    So now we just need a way to iterate through our files and collect these duration values.



    $ for i in *.mp4; do
    ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"; done
    00:23:17.01
    00:23:17.01
    00:23:17.01


    NOTE: Here for my example I simply copied my sample file some.mp4 and named it 1.mp4, 2.mp4, and 3.mp4.



    Converting times to seconds



    The following snippet will take the durations from above and convert them to seconds.



    $ for i in *.mp4; do 
    dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
    date -ud "1970/01/01 $dur" +%s; done
    1397
    1397
    1397


    This takes our durations and puts them in a variable, $dur, as we loop through the files. The date command is then used to calculate the number of seconds sine the Unix epoch (1970/01/01). Here's the above date command broken out so it's easier to see:



    $ date -ud "1970/01/01 00:23:17.01" +%s
    1397


    NOTE: Using date in this manner will only work if all your files have a duration that's < 24 hours (i.e. 86400 seconds). If you need something that can handle larger durations you can use this as an alternative:



    sed 's/^/((/; s/:/)*60+/g' | bc


    Example

    $ echo 44:29:36.01 | sed 's/^/((/; s/:/)*60+/g' | bc
    160176.01


    Totaling up the times



    We can then take the output of our for loop and run it into a paste command which will incorporate + signs in between each number, like so:



    $ for i in *.mp4; do 
    dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
    date -ud "1970/01/01 $dur" +%s; done | paste -s -d+
    1397+1397+1397


    Finally we run this into the command line calculator, bc to sum them up:



    $ for i in *.mp4; do 
    dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
    date -ud "1970/01/01 $dur" +%s; done | paste -s -d+ | bc
    4191


    Resulting in the total duration of all the files, in seconds. This can of course be converted to some other format if needed.






    share|improve this answer






















    • @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
      – slm
      Dec 2 '14 at 6:26










    • @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
      – don_crissti
      Dec 2 '14 at 7:08










    • @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
      – slm
      Dec 2 '14 at 7:17










    • Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
      – MvG
      Dec 2 '14 at 9:02










    • @MvG - paste is my favorite command 8-)
      – slm
      Dec 2 '14 at 12:16


















    0














    $ find -iname '*.ts' -print0 |
    xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
    perl -nle '/ID_LENGTH=([0-9.]+)/ && ($t += $1) && printf "%02d:%02d:%02d:%02dn",$t/86400,$t/3600%24,$t/60%60,$t%60'


    Be sure that you have MPlayer installed.






    share|improve this answer






















    • it doesnt give me any output
      – k961
      Dec 2 '14 at 6:00










    • do you have mplayer and perl installed?
      – ryanmjacobs
      Dec 3 '14 at 14:15










    • yes i installed mplayer and perl was already installed
      – k961
      Dec 3 '14 at 15:01






    • 1




      Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
      – ryanmjacobs
      Dec 4 '14 at 1:33



















    0














    As ubuntu ship libav instead of ffmpeg :



    #!/bin/sh
    for f in *.mp4; do
    avprobe -v quiet -show_format_entry duration "$f"
    done | paste -sd+ | bc


    Heavily based on MvG ideas






    share|improve this answer






























      0














      Going off the accepted answer and using the classic UNIX reverse-polish tool:



       find . -maxdepth 2 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 
      -show_entries format=duration ; ; printf '+n60n*np'; | dc



      783.493000




      I.e.: Appening + and p then piping that into dc and you'll get your sum.






      share|improve this answer


















      • 1




        bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
        – A T
        Feb 9 '17 at 13:59


















      0














      Well, these all solution need a bit of work, what I did was very simple,
      1)



      1. went to the desired folder and right click -> open with other
        application


      2. Then select VLC media player,


      3. this will start playing one of the videos, but then

      4. press ctrl + L, and you will see the playlist of the videos and somewhere on top left corner you will see total duration

      here is example



      1.
      List item



      2.enter image description here



      3.enter image description here



      You can see just under the toolbar, there is Playlist[10:35:51] written,
      so folder contains 10 hours 35 mins and 51 sec duration of total videos






      share|improve this answer




















        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "106"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f170961%2fget-total-duration-of-video-files-in-a-directory%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        8 Answers
        8






        active

        oldest

        votes








        8 Answers
        8






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        43














        I have no .ts here but this works for .mp4. Use ffprobe (part of ffmpeg) to get the time in seconds, e.g:



        ffprobe -v quiet -of csv=p=0 -show_entries format=duration Inception.mp4 
        275.690000


        so for all .mp4 files in the current dir:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ;
        149.233333
        130.146667
        275.690000


        then use paste to pass the output to bc and get the total time in seconds:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc
        555.070000


        So, for .ts files you could try:



        find . -maxdepth 1 -iname '*.ts' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc


        Another tool that works for the video files I have here is exiftool, e.g.:



        exiftool -S -n Inception.mp4 | grep ^Duration
        Duration: 275.69
        exiftool -q -p '$Duration#' Inception.mp4
        275.69


        Total length for all .mp4 files in the current directory:



        exiftool -S -n ./*.mp4 | awk '/^Duration/ print $2' | paste -sd+ -| bc
        555.070000000000
        exiftool -q -p '$Duration#' ./*.mp4 | awk 'sum += $0; ENDprint sum'
        555.070000000000


        You could also pipe the output to another command to convert the total to DD:HH:MM:SS, see the answers here.



        Or use exiftool's internal ConvertDuration for that (you need a relatively recent version though):



        exiftool -n -q -p '$Duration;our $sum;$_=ConvertDuration($sum+=$_)
        ' ./*.mp4| tail -n1
        0:09:15





        share|improve this answer






















        • Very nice, hadn't seen that trick w/ ffprobe before.
          – slm
          Dec 2 '14 at 7:24






        • 1




          Nice trick with paste and bc! much cleaner than with awk let's say.
          – fduff
          Dec 2 '14 at 12:03










        • @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
          – Stéphane Chazelas
          Dec 2 '14 at 12:29










        • Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
          – Joe
          Dec 16 '14 at 7:51










        • @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
          – don_crissti
          Dec 16 '14 at 17:09
















        43














        I have no .ts here but this works for .mp4. Use ffprobe (part of ffmpeg) to get the time in seconds, e.g:



        ffprobe -v quiet -of csv=p=0 -show_entries format=duration Inception.mp4 
        275.690000


        so for all .mp4 files in the current dir:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ;
        149.233333
        130.146667
        275.690000


        then use paste to pass the output to bc and get the total time in seconds:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc
        555.070000


        So, for .ts files you could try:



        find . -maxdepth 1 -iname '*.ts' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc


        Another tool that works for the video files I have here is exiftool, e.g.:



        exiftool -S -n Inception.mp4 | grep ^Duration
        Duration: 275.69
        exiftool -q -p '$Duration#' Inception.mp4
        275.69


        Total length for all .mp4 files in the current directory:



        exiftool -S -n ./*.mp4 | awk '/^Duration/ print $2' | paste -sd+ -| bc
        555.070000000000
        exiftool -q -p '$Duration#' ./*.mp4 | awk 'sum += $0; ENDprint sum'
        555.070000000000


        You could also pipe the output to another command to convert the total to DD:HH:MM:SS, see the answers here.



        Or use exiftool's internal ConvertDuration for that (you need a relatively recent version though):



        exiftool -n -q -p '$Duration;our $sum;$_=ConvertDuration($sum+=$_)
        ' ./*.mp4| tail -n1
        0:09:15





        share|improve this answer






















        • Very nice, hadn't seen that trick w/ ffprobe before.
          – slm
          Dec 2 '14 at 7:24






        • 1




          Nice trick with paste and bc! much cleaner than with awk let's say.
          – fduff
          Dec 2 '14 at 12:03










        • @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
          – Stéphane Chazelas
          Dec 2 '14 at 12:29










        • Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
          – Joe
          Dec 16 '14 at 7:51










        • @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
          – don_crissti
          Dec 16 '14 at 17:09














        43












        43








        43






        I have no .ts here but this works for .mp4. Use ffprobe (part of ffmpeg) to get the time in seconds, e.g:



        ffprobe -v quiet -of csv=p=0 -show_entries format=duration Inception.mp4 
        275.690000


        so for all .mp4 files in the current dir:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ;
        149.233333
        130.146667
        275.690000


        then use paste to pass the output to bc and get the total time in seconds:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc
        555.070000


        So, for .ts files you could try:



        find . -maxdepth 1 -iname '*.ts' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc


        Another tool that works for the video files I have here is exiftool, e.g.:



        exiftool -S -n Inception.mp4 | grep ^Duration
        Duration: 275.69
        exiftool -q -p '$Duration#' Inception.mp4
        275.69


        Total length for all .mp4 files in the current directory:



        exiftool -S -n ./*.mp4 | awk '/^Duration/ print $2' | paste -sd+ -| bc
        555.070000000000
        exiftool -q -p '$Duration#' ./*.mp4 | awk 'sum += $0; ENDprint sum'
        555.070000000000


        You could also pipe the output to another command to convert the total to DD:HH:MM:SS, see the answers here.



        Or use exiftool's internal ConvertDuration for that (you need a relatively recent version though):



        exiftool -n -q -p '$Duration;our $sum;$_=ConvertDuration($sum+=$_)
        ' ./*.mp4| tail -n1
        0:09:15





        share|improve this answer














        I have no .ts here but this works for .mp4. Use ffprobe (part of ffmpeg) to get the time in seconds, e.g:



        ffprobe -v quiet -of csv=p=0 -show_entries format=duration Inception.mp4 
        275.690000


        so for all .mp4 files in the current dir:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ;
        149.233333
        130.146667
        275.690000


        then use paste to pass the output to bc and get the total time in seconds:



        find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc
        555.070000


        So, for .ts files you could try:



        find . -maxdepth 1 -iname '*.ts' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration ; | paste -sd+ -| bc


        Another tool that works for the video files I have here is exiftool, e.g.:



        exiftool -S -n Inception.mp4 | grep ^Duration
        Duration: 275.69
        exiftool -q -p '$Duration#' Inception.mp4
        275.69


        Total length for all .mp4 files in the current directory:



        exiftool -S -n ./*.mp4 | awk '/^Duration/ print $2' | paste -sd+ -| bc
        555.070000000000
        exiftool -q -p '$Duration#' ./*.mp4 | awk 'sum += $0; ENDprint sum'
        555.070000000000


        You could also pipe the output to another command to convert the total to DD:HH:MM:SS, see the answers here.



        Or use exiftool's internal ConvertDuration for that (you need a relatively recent version though):



        exiftool -n -q -p '$Duration;our $sum;$_=ConvertDuration($sum+=$_)
        ' ./*.mp4| tail -n1
        0:09:15






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 11:33









        Community

        1




        1










        answered Dec 2 '14 at 6:48









        don_crisstidon_crissti

        50k15132161




        50k15132161











        • Very nice, hadn't seen that trick w/ ffprobe before.
          – slm
          Dec 2 '14 at 7:24






        • 1




          Nice trick with paste and bc! much cleaner than with awk let's say.
          – fduff
          Dec 2 '14 at 12:03










        • @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
          – Stéphane Chazelas
          Dec 2 '14 at 12:29










        • Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
          – Joe
          Dec 16 '14 at 7:51










        • @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
          – don_crissti
          Dec 16 '14 at 17:09

















        • Very nice, hadn't seen that trick w/ ffprobe before.
          – slm
          Dec 2 '14 at 7:24






        • 1




          Nice trick with paste and bc! much cleaner than with awk let's say.
          – fduff
          Dec 2 '14 at 12:03










        • @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
          – Stéphane Chazelas
          Dec 2 '14 at 12:29










        • Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
          – Joe
          Dec 16 '14 at 7:51










        • @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
          – don_crissti
          Dec 16 '14 at 17:09
















        Very nice, hadn't seen that trick w/ ffprobe before.
        – slm
        Dec 2 '14 at 7:24




        Very nice, hadn't seen that trick w/ ffprobe before.
        – slm
        Dec 2 '14 at 7:24




        1




        1




        Nice trick with paste and bc! much cleaner than with awk let's say.
        – fduff
        Dec 2 '14 at 12:03




        Nice trick with paste and bc! much cleaner than with awk let's say.
        – fduff
        Dec 2 '14 at 12:03












        @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
        – Stéphane Chazelas
        Dec 2 '14 at 12:29




        @fduff. While bc will do arbitrary precision, one drawback is that ...| paste -sd+ - | bc will either reach the line size limit in some bc implementations (for instance seq 429 | paste -sd+ - | bc fails with OpenSolaris bc) or have the potential of using up all the memory in others.
        – Stéphane Chazelas
        Dec 2 '14 at 12:29












        Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
        – Joe
        Dec 16 '14 at 7:51




        Can you do this (ffprobe method) with something like avconv? I can't find ffmpeg in my repos for Kubuntu 14.04 - so I don't have ffprobe either? I do have avprobe, but it doesn't like those arguments.
        – Joe
        Dec 16 '14 at 7:51












        @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
        – don_crissti
        Dec 16 '14 at 17:09





        @Joe - No avprobe in Arch repos (prolly because it conflicts with ffmpeg) so cannot try it ATM but does it give you the duration of the file if you run it like this: avprobe -show_format_entry duration myfile.mp4 or avprobe -loglevel quiet -show_format_entry duration myfile.mp4? I think one of these commands should give you a single line of output with the duration of the file. Not sure though.
        – don_crissti
        Dec 16 '14 at 17:09














        5














        This uses ffmpeg and prints the time out in total seconds:



        times=()
        for f in *.ts; do
        _t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ')
        times+=("$_t")
        done
        echo "$times[@]" | sed 's/ /+/g' | bc


        Explanation:



        for f in *.ts; do iterates each of the files that ends in ".ts"



        ffmpeg -i "$f" 2>&1 redirects output to stderr



        grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' isolates the time



        awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ' Converts time to seconds



        times+=("$_t") adds the seconds to an array



        echo "$times[@]" | sed 's/ /+/g' | bc expands each of the arguments and replaces the spaces and pipes it to bc a common linux calculator






        share|improve this answer




















        • Nice! Also see my version which is heavily based on your ideas.
          – MvG
          Dec 2 '14 at 9:02










        • Short and elegant solution
          – Neo
          Mar 26 '17 at 2:48















        5














        This uses ffmpeg and prints the time out in total seconds:



        times=()
        for f in *.ts; do
        _t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ')
        times+=("$_t")
        done
        echo "$times[@]" | sed 's/ /+/g' | bc


        Explanation:



        for f in *.ts; do iterates each of the files that ends in ".ts"



        ffmpeg -i "$f" 2>&1 redirects output to stderr



        grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' isolates the time



        awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ' Converts time to seconds



        times+=("$_t") adds the seconds to an array



        echo "$times[@]" | sed 's/ /+/g' | bc expands each of the arguments and replaces the spaces and pipes it to bc a common linux calculator






        share|improve this answer




















        • Nice! Also see my version which is heavily based on your ideas.
          – MvG
          Dec 2 '14 at 9:02










        • Short and elegant solution
          – Neo
          Mar 26 '17 at 2:48













        5












        5








        5






        This uses ffmpeg and prints the time out in total seconds:



        times=()
        for f in *.ts; do
        _t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ')
        times+=("$_t")
        done
        echo "$times[@]" | sed 's/ /+/g' | bc


        Explanation:



        for f in *.ts; do iterates each of the files that ends in ".ts"



        ffmpeg -i "$f" 2>&1 redirects output to stderr



        grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' isolates the time



        awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ' Converts time to seconds



        times+=("$_t") adds the seconds to an array



        echo "$times[@]" | sed 's/ /+/g' | bc expands each of the arguments and replaces the spaces and pipes it to bc a common linux calculator






        share|improve this answer












        This uses ffmpeg and prints the time out in total seconds:



        times=()
        for f in *.ts; do
        _t=$(ffmpeg -i "$f" 2>&1 | grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' | awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ')
        times+=("$_t")
        done
        echo "$times[@]" | sed 's/ /+/g' | bc


        Explanation:



        for f in *.ts; do iterates each of the files that ends in ".ts"



        ffmpeg -i "$f" 2>&1 redirects output to stderr



        grep "Duration" | grep -o " [0-9:.]*, " | head -n1 | tr ',' ' ' isolates the time



        awk -F: ' print ($1 * 3600) + ($2 * 60) + $3 ' Converts time to seconds



        times+=("$_t") adds the seconds to an array



        echo "$times[@]" | sed 's/ /+/g' | bc expands each of the arguments and replaces the spaces and pipes it to bc a common linux calculator







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 2 '14 at 6:09









        jmunschjmunsch

        1,6391922




        1,6391922











        • Nice! Also see my version which is heavily based on your ideas.
          – MvG
          Dec 2 '14 at 9:02










        • Short and elegant solution
          – Neo
          Mar 26 '17 at 2:48
















        • Nice! Also see my version which is heavily based on your ideas.
          – MvG
          Dec 2 '14 at 9:02










        • Short and elegant solution
          – Neo
          Mar 26 '17 at 2:48















        Nice! Also see my version which is heavily based on your ideas.
        – MvG
        Dec 2 '14 at 9:02




        Nice! Also see my version which is heavily based on your ideas.
        – MvG
        Dec 2 '14 at 9:02












        Short and elegant solution
        – Neo
        Mar 26 '17 at 2:48




        Short and elegant solution
        – Neo
        Mar 26 '17 at 2:48











        4














        Streamlining @jmunsch's answer, and using the paste I just learned from @slm's answer, you could end up with something like this:



        for i in *.ts; do LC_ALL=C ffmpeg -i "$i" 2>&1 | 
        awk -F: '/Duration:/print $2*3600+$3*60+$4'; done | paste -sd+ | bc


        Just like jmunsch did, I'm using ffmpeg to print the duration, ignoring the error about a missing output file and instead searching the error output for the duration line. I invoke ffmpeg with all aspects of the locale forced to the standard C locale, so that I won't have to worry about localized output messages.



        Next I'm using a single awk instead of his grep | grep | head | tr | awk. That awk invocation looks for the (hopefully unique) line containing Duration:. Using colon as a separator, that label is field 1, the hours are field 2, the minutes filed 3 and the seconds field 4. The trailing comma after the seconds doesn't seem to bother my awk, but if someone has problems there, he could include a tr -d , in the pipeline between ffmpeg and awk.



        Now comes the part from slm: I'm using paste to replace newlines with plus signs, but without affecting the trailing newline (contrary to the tr \n + I had in a previous version of this answer). That gives the sum expression which can be fed to bc.



        Inspired by slm's idea of using date to handle time-like formats, here is a version which does use it to format the resulting seconds as days, hours, minutes and seconds with fractional part:



        TZ=UTC+0 date +'%j %T.%N' --date=@$(for i in *.ts; do LC_ALL=C 
        ffmpeg -i "$i" 2>&1 | awk -F: '/Duration:/print $2*3600+$3*60+$4'; done
        | paste -sd+ | bc) | awk 'print $1-1 "d",$2' | sed 's/[.0]*$//'


        The part inside $(…) is exactly as before. Using the @ character as an indication, we use this as the number of seconds since the 1 January 1970. The resulting “date” gets formatted as day of the year, time and nanoseconds. From that day of the year we subtract one, since an input of zero seconds already leads to day 1 of that year 1970. I don't think there is a way to get day of the year counts starting at zero.



        The final sed gets rid of extra trailing zeros. The TZ setting should hopefully force the use of UTC, so that daylight saving time won't interfere with really large video collections. If you have more than one year worth of video, this approach still won't work, though.






        share|improve this answer



























          4














          Streamlining @jmunsch's answer, and using the paste I just learned from @slm's answer, you could end up with something like this:



          for i in *.ts; do LC_ALL=C ffmpeg -i "$i" 2>&1 | 
          awk -F: '/Duration:/print $2*3600+$3*60+$4'; done | paste -sd+ | bc


          Just like jmunsch did, I'm using ffmpeg to print the duration, ignoring the error about a missing output file and instead searching the error output for the duration line. I invoke ffmpeg with all aspects of the locale forced to the standard C locale, so that I won't have to worry about localized output messages.



          Next I'm using a single awk instead of his grep | grep | head | tr | awk. That awk invocation looks for the (hopefully unique) line containing Duration:. Using colon as a separator, that label is field 1, the hours are field 2, the minutes filed 3 and the seconds field 4. The trailing comma after the seconds doesn't seem to bother my awk, but if someone has problems there, he could include a tr -d , in the pipeline between ffmpeg and awk.



          Now comes the part from slm: I'm using paste to replace newlines with plus signs, but without affecting the trailing newline (contrary to the tr \n + I had in a previous version of this answer). That gives the sum expression which can be fed to bc.



          Inspired by slm's idea of using date to handle time-like formats, here is a version which does use it to format the resulting seconds as days, hours, minutes and seconds with fractional part:



          TZ=UTC+0 date +'%j %T.%N' --date=@$(for i in *.ts; do LC_ALL=C 
          ffmpeg -i "$i" 2>&1 | awk -F: '/Duration:/print $2*3600+$3*60+$4'; done
          | paste -sd+ | bc) | awk 'print $1-1 "d",$2' | sed 's/[.0]*$//'


          The part inside $(…) is exactly as before. Using the @ character as an indication, we use this as the number of seconds since the 1 January 1970. The resulting “date” gets formatted as day of the year, time and nanoseconds. From that day of the year we subtract one, since an input of zero seconds already leads to day 1 of that year 1970. I don't think there is a way to get day of the year counts starting at zero.



          The final sed gets rid of extra trailing zeros. The TZ setting should hopefully force the use of UTC, so that daylight saving time won't interfere with really large video collections. If you have more than one year worth of video, this approach still won't work, though.






          share|improve this answer

























            4












            4








            4






            Streamlining @jmunsch's answer, and using the paste I just learned from @slm's answer, you could end up with something like this:



            for i in *.ts; do LC_ALL=C ffmpeg -i "$i" 2>&1 | 
            awk -F: '/Duration:/print $2*3600+$3*60+$4'; done | paste -sd+ | bc


            Just like jmunsch did, I'm using ffmpeg to print the duration, ignoring the error about a missing output file and instead searching the error output for the duration line. I invoke ffmpeg with all aspects of the locale forced to the standard C locale, so that I won't have to worry about localized output messages.



            Next I'm using a single awk instead of his grep | grep | head | tr | awk. That awk invocation looks for the (hopefully unique) line containing Duration:. Using colon as a separator, that label is field 1, the hours are field 2, the minutes filed 3 and the seconds field 4. The trailing comma after the seconds doesn't seem to bother my awk, but if someone has problems there, he could include a tr -d , in the pipeline between ffmpeg and awk.



            Now comes the part from slm: I'm using paste to replace newlines with plus signs, but without affecting the trailing newline (contrary to the tr \n + I had in a previous version of this answer). That gives the sum expression which can be fed to bc.



            Inspired by slm's idea of using date to handle time-like formats, here is a version which does use it to format the resulting seconds as days, hours, minutes and seconds with fractional part:



            TZ=UTC+0 date +'%j %T.%N' --date=@$(for i in *.ts; do LC_ALL=C 
            ffmpeg -i "$i" 2>&1 | awk -F: '/Duration:/print $2*3600+$3*60+$4'; done
            | paste -sd+ | bc) | awk 'print $1-1 "d",$2' | sed 's/[.0]*$//'


            The part inside $(…) is exactly as before. Using the @ character as an indication, we use this as the number of seconds since the 1 January 1970. The resulting “date” gets formatted as day of the year, time and nanoseconds. From that day of the year we subtract one, since an input of zero seconds already leads to day 1 of that year 1970. I don't think there is a way to get day of the year counts starting at zero.



            The final sed gets rid of extra trailing zeros. The TZ setting should hopefully force the use of UTC, so that daylight saving time won't interfere with really large video collections. If you have more than one year worth of video, this approach still won't work, though.






            share|improve this answer














            Streamlining @jmunsch's answer, and using the paste I just learned from @slm's answer, you could end up with something like this:



            for i in *.ts; do LC_ALL=C ffmpeg -i "$i" 2>&1 | 
            awk -F: '/Duration:/print $2*3600+$3*60+$4'; done | paste -sd+ | bc


            Just like jmunsch did, I'm using ffmpeg to print the duration, ignoring the error about a missing output file and instead searching the error output for the duration line. I invoke ffmpeg with all aspects of the locale forced to the standard C locale, so that I won't have to worry about localized output messages.



            Next I'm using a single awk instead of his grep | grep | head | tr | awk. That awk invocation looks for the (hopefully unique) line containing Duration:. Using colon as a separator, that label is field 1, the hours are field 2, the minutes filed 3 and the seconds field 4. The trailing comma after the seconds doesn't seem to bother my awk, but if someone has problems there, he could include a tr -d , in the pipeline between ffmpeg and awk.



            Now comes the part from slm: I'm using paste to replace newlines with plus signs, but without affecting the trailing newline (contrary to the tr \n + I had in a previous version of this answer). That gives the sum expression which can be fed to bc.



            Inspired by slm's idea of using date to handle time-like formats, here is a version which does use it to format the resulting seconds as days, hours, minutes and seconds with fractional part:



            TZ=UTC+0 date +'%j %T.%N' --date=@$(for i in *.ts; do LC_ALL=C 
            ffmpeg -i "$i" 2>&1 | awk -F: '/Duration:/print $2*3600+$3*60+$4'; done
            | paste -sd+ | bc) | awk 'print $1-1 "d",$2' | sed 's/[.0]*$//'


            The part inside $(…) is exactly as before. Using the @ character as an indication, we use this as the number of seconds since the 1 January 1970. The resulting “date” gets formatted as day of the year, time and nanoseconds. From that day of the year we subtract one, since an input of zero seconds already leads to day 1 of that year 1970. I don't think there is a way to get day of the year counts starting at zero.



            The final sed gets rid of extra trailing zeros. The TZ setting should hopefully force the use of UTC, so that daylight saving time won't interfere with really large video collections. If you have more than one year worth of video, this approach still won't work, though.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 '17 at 12:36









            Community

            1




            1










            answered Dec 2 '14 at 8:31









            MvGMvG

            2,2011435




            2,2011435





















                3














                I'm not familiar with the .ts extension, but assuming they're some type of video file you can use ffmpeg to identify the duration of a file like so:



                $ ffmpeg -i some.mp4 2>&1 | grep Dura
                Duration: 00:23:17.01, start: 0.000000, bitrate: 504 kb/s


                We can then split this output up, selecting just the duration time.



                $ ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"
                00:23:17.01


                So now we just need a way to iterate through our files and collect these duration values.



                $ for i in *.mp4; do
                ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"; done
                00:23:17.01
                00:23:17.01
                00:23:17.01


                NOTE: Here for my example I simply copied my sample file some.mp4 and named it 1.mp4, 2.mp4, and 3.mp4.



                Converting times to seconds



                The following snippet will take the durations from above and convert them to seconds.



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done
                1397
                1397
                1397


                This takes our durations and puts them in a variable, $dur, as we loop through the files. The date command is then used to calculate the number of seconds sine the Unix epoch (1970/01/01). Here's the above date command broken out so it's easier to see:



                $ date -ud "1970/01/01 00:23:17.01" +%s
                1397


                NOTE: Using date in this manner will only work if all your files have a duration that's < 24 hours (i.e. 86400 seconds). If you need something that can handle larger durations you can use this as an alternative:



                sed 's/^/((/; s/:/)*60+/g' | bc


                Example

                $ echo 44:29:36.01 | sed 's/^/((/; s/:/)*60+/g' | bc
                160176.01


                Totaling up the times



                We can then take the output of our for loop and run it into a paste command which will incorporate + signs in between each number, like so:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+
                1397+1397+1397


                Finally we run this into the command line calculator, bc to sum them up:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+ | bc
                4191


                Resulting in the total duration of all the files, in seconds. This can of course be converted to some other format if needed.






                share|improve this answer






















                • @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                  – slm
                  Dec 2 '14 at 6:26










                • @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                  – don_crissti
                  Dec 2 '14 at 7:08










                • @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                  – slm
                  Dec 2 '14 at 7:17










                • Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                  – MvG
                  Dec 2 '14 at 9:02










                • @MvG - paste is my favorite command 8-)
                  – slm
                  Dec 2 '14 at 12:16















                3














                I'm not familiar with the .ts extension, but assuming they're some type of video file you can use ffmpeg to identify the duration of a file like so:



                $ ffmpeg -i some.mp4 2>&1 | grep Dura
                Duration: 00:23:17.01, start: 0.000000, bitrate: 504 kb/s


                We can then split this output up, selecting just the duration time.



                $ ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"
                00:23:17.01


                So now we just need a way to iterate through our files and collect these duration values.



                $ for i in *.mp4; do
                ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"; done
                00:23:17.01
                00:23:17.01
                00:23:17.01


                NOTE: Here for my example I simply copied my sample file some.mp4 and named it 1.mp4, 2.mp4, and 3.mp4.



                Converting times to seconds



                The following snippet will take the durations from above and convert them to seconds.



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done
                1397
                1397
                1397


                This takes our durations and puts them in a variable, $dur, as we loop through the files. The date command is then used to calculate the number of seconds sine the Unix epoch (1970/01/01). Here's the above date command broken out so it's easier to see:



                $ date -ud "1970/01/01 00:23:17.01" +%s
                1397


                NOTE: Using date in this manner will only work if all your files have a duration that's < 24 hours (i.e. 86400 seconds). If you need something that can handle larger durations you can use this as an alternative:



                sed 's/^/((/; s/:/)*60+/g' | bc


                Example

                $ echo 44:29:36.01 | sed 's/^/((/; s/:/)*60+/g' | bc
                160176.01


                Totaling up the times



                We can then take the output of our for loop and run it into a paste command which will incorporate + signs in between each number, like so:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+
                1397+1397+1397


                Finally we run this into the command line calculator, bc to sum them up:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+ | bc
                4191


                Resulting in the total duration of all the files, in seconds. This can of course be converted to some other format if needed.






                share|improve this answer






















                • @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                  – slm
                  Dec 2 '14 at 6:26










                • @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                  – don_crissti
                  Dec 2 '14 at 7:08










                • @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                  – slm
                  Dec 2 '14 at 7:17










                • Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                  – MvG
                  Dec 2 '14 at 9:02










                • @MvG - paste is my favorite command 8-)
                  – slm
                  Dec 2 '14 at 12:16













                3












                3








                3






                I'm not familiar with the .ts extension, but assuming they're some type of video file you can use ffmpeg to identify the duration of a file like so:



                $ ffmpeg -i some.mp4 2>&1 | grep Dura
                Duration: 00:23:17.01, start: 0.000000, bitrate: 504 kb/s


                We can then split this output up, selecting just the duration time.



                $ ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"
                00:23:17.01


                So now we just need a way to iterate through our files and collect these duration values.



                $ for i in *.mp4; do
                ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"; done
                00:23:17.01
                00:23:17.01
                00:23:17.01


                NOTE: Here for my example I simply copied my sample file some.mp4 and named it 1.mp4, 2.mp4, and 3.mp4.



                Converting times to seconds



                The following snippet will take the durations from above and convert them to seconds.



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done
                1397
                1397
                1397


                This takes our durations and puts them in a variable, $dur, as we loop through the files. The date command is then used to calculate the number of seconds sine the Unix epoch (1970/01/01). Here's the above date command broken out so it's easier to see:



                $ date -ud "1970/01/01 00:23:17.01" +%s
                1397


                NOTE: Using date in this manner will only work if all your files have a duration that's < 24 hours (i.e. 86400 seconds). If you need something that can handle larger durations you can use this as an alternative:



                sed 's/^/((/; s/:/)*60+/g' | bc


                Example

                $ echo 44:29:36.01 | sed 's/^/((/; s/:/)*60+/g' | bc
                160176.01


                Totaling up the times



                We can then take the output of our for loop and run it into a paste command which will incorporate + signs in between each number, like so:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+
                1397+1397+1397


                Finally we run this into the command line calculator, bc to sum them up:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+ | bc
                4191


                Resulting in the total duration of all the files, in seconds. This can of course be converted to some other format if needed.






                share|improve this answer














                I'm not familiar with the .ts extension, but assuming they're some type of video file you can use ffmpeg to identify the duration of a file like so:



                $ ffmpeg -i some.mp4 2>&1 | grep Dura
                Duration: 00:23:17.01, start: 0.000000, bitrate: 504 kb/s


                We can then split this output up, selecting just the duration time.



                $ ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"
                00:23:17.01


                So now we just need a way to iterate through our files and collect these duration values.



                $ for i in *.mp4; do
                ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)"; done
                00:23:17.01
                00:23:17.01
                00:23:17.01


                NOTE: Here for my example I simply copied my sample file some.mp4 and named it 1.mp4, 2.mp4, and 3.mp4.



                Converting times to seconds



                The following snippet will take the durations from above and convert them to seconds.



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done
                1397
                1397
                1397


                This takes our durations and puts them in a variable, $dur, as we loop through the files. The date command is then used to calculate the number of seconds sine the Unix epoch (1970/01/01). Here's the above date command broken out so it's easier to see:



                $ date -ud "1970/01/01 00:23:17.01" +%s
                1397


                NOTE: Using date in this manner will only work if all your files have a duration that's < 24 hours (i.e. 86400 seconds). If you need something that can handle larger durations you can use this as an alternative:



                sed 's/^/((/; s/:/)*60+/g' | bc


                Example

                $ echo 44:29:36.01 | sed 's/^/((/; s/:/)*60+/g' | bc
                160176.01


                Totaling up the times



                We can then take the output of our for loop and run it into a paste command which will incorporate + signs in between each number, like so:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+
                1397+1397+1397


                Finally we run this into the command line calculator, bc to sum them up:



                $ for i in *.mp4; do 
                dur=$(ffmpeg -i "$i" 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)");
                date -ud "1970/01/01 $dur" +%s; done | paste -s -d+ | bc
                4191


                Resulting in the total duration of all the files, in seconds. This can of course be converted to some other format if needed.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 2 '14 at 7:20

























                answered Dec 2 '14 at 6:19









                slmslm

                247k66514678




                247k66514678











                • @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                  – slm
                  Dec 2 '14 at 6:26










                • @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                  – don_crissti
                  Dec 2 '14 at 7:08










                • @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                  – slm
                  Dec 2 '14 at 7:17










                • Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                  – MvG
                  Dec 2 '14 at 9:02










                • @MvG - paste is my favorite command 8-)
                  – slm
                  Dec 2 '14 at 12:16
















                • @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                  – slm
                  Dec 2 '14 at 6:26










                • @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                  – don_crissti
                  Dec 2 '14 at 7:08










                • @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                  – slm
                  Dec 2 '14 at 7:17










                • Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                  – MvG
                  Dec 2 '14 at 9:02










                • @MvG - paste is my favorite command 8-)
                  – slm
                  Dec 2 '14 at 12:16















                @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                – slm
                Dec 2 '14 at 6:26




                @DamenSalvatore - no problem, hopefully it shows you how you can break the task down into various steps, so you can customize it as needed.
                – slm
                Dec 2 '14 at 6:26












                @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                – don_crissti
                Dec 2 '14 at 7:08




                @slm - I would use another way to convert the video duration to seconds as date might choke if ffmpeg -i some.mp4 2>&1 | grep -oP "(?<=Duration: ).*(?=, start.*)" returns something like 26:33:21.68 (that is, duration ≥ 24 hours/86400 seconds)
                – don_crissti
                Dec 2 '14 at 7:08












                @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                – slm
                Dec 2 '14 at 7:17




                @don_crissti - thanks, I hadn't tried it beyond 20 hours when testing it out. I'll add a note showing an alternative method.
                – slm
                Dec 2 '14 at 7:17












                Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                – MvG
                Dec 2 '14 at 9:02




                Thanks for your answer! Not only did it inspire mine, but it also brought paste to my attention. I guess java -classpath $(find -name *.jar | paste -sd:) is going to be very useful to me, considering the hacks I'd used for this in the past.
                – MvG
                Dec 2 '14 at 9:02












                @MvG - paste is my favorite command 8-)
                – slm
                Dec 2 '14 at 12:16




                @MvG - paste is my favorite command 8-)
                – slm
                Dec 2 '14 at 12:16











                0














                $ find -iname '*.ts' -print0 |
                xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
                perl -nle '/ID_LENGTH=([0-9.]+)/ && ($t += $1) && printf "%02d:%02d:%02d:%02dn",$t/86400,$t/3600%24,$t/60%60,$t%60'


                Be sure that you have MPlayer installed.






                share|improve this answer






















                • it doesnt give me any output
                  – k961
                  Dec 2 '14 at 6:00










                • do you have mplayer and perl installed?
                  – ryanmjacobs
                  Dec 3 '14 at 14:15










                • yes i installed mplayer and perl was already installed
                  – k961
                  Dec 3 '14 at 15:01






                • 1




                  Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                  – ryanmjacobs
                  Dec 4 '14 at 1:33
















                0














                $ find -iname '*.ts' -print0 |
                xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
                perl -nle '/ID_LENGTH=([0-9.]+)/ && ($t += $1) && printf "%02d:%02d:%02d:%02dn",$t/86400,$t/3600%24,$t/60%60,$t%60'


                Be sure that you have MPlayer installed.






                share|improve this answer






















                • it doesnt give me any output
                  – k961
                  Dec 2 '14 at 6:00










                • do you have mplayer and perl installed?
                  – ryanmjacobs
                  Dec 3 '14 at 14:15










                • yes i installed mplayer and perl was already installed
                  – k961
                  Dec 3 '14 at 15:01






                • 1




                  Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                  – ryanmjacobs
                  Dec 4 '14 at 1:33














                0












                0








                0






                $ find -iname '*.ts' -print0 |
                xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
                perl -nle '/ID_LENGTH=([0-9.]+)/ && ($t += $1) && printf "%02d:%02d:%02d:%02dn",$t/86400,$t/3600%24,$t/60%60,$t%60'


                Be sure that you have MPlayer installed.






                share|improve this answer














                $ find -iname '*.ts' -print0 |
                xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null |
                perl -nle '/ID_LENGTH=([0-9.]+)/ && ($t += $1) && printf "%02d:%02d:%02d:%02dn",$t/86400,$t/3600%24,$t/60%60,$t%60'


                Be sure that you have MPlayer installed.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 4 '14 at 1:31

























                answered Dec 2 '14 at 5:30









                ryanmjacobsryanmjacobs

                29127




                29127











                • it doesnt give me any output
                  – k961
                  Dec 2 '14 at 6:00










                • do you have mplayer and perl installed?
                  – ryanmjacobs
                  Dec 3 '14 at 14:15










                • yes i installed mplayer and perl was already installed
                  – k961
                  Dec 3 '14 at 15:01






                • 1




                  Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                  – ryanmjacobs
                  Dec 4 '14 at 1:33

















                • it doesnt give me any output
                  – k961
                  Dec 2 '14 at 6:00










                • do you have mplayer and perl installed?
                  – ryanmjacobs
                  Dec 3 '14 at 14:15










                • yes i installed mplayer and perl was already installed
                  – k961
                  Dec 3 '14 at 15:01






                • 1




                  Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                  – ryanmjacobs
                  Dec 4 '14 at 1:33
















                it doesnt give me any output
                – k961
                Dec 2 '14 at 6:00




                it doesnt give me any output
                – k961
                Dec 2 '14 at 6:00












                do you have mplayer and perl installed?
                – ryanmjacobs
                Dec 3 '14 at 14:15




                do you have mplayer and perl installed?
                – ryanmjacobs
                Dec 3 '14 at 14:15












                yes i installed mplayer and perl was already installed
                – k961
                Dec 3 '14 at 15:01




                yes i installed mplayer and perl was already installed
                – k961
                Dec 3 '14 at 15:01




                1




                1




                Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                – ryanmjacobs
                Dec 4 '14 at 1:33





                Sorry, I don't know why it's not working; but, you already have enough decent answers already anyways. :)
                – ryanmjacobs
                Dec 4 '14 at 1:33












                0














                As ubuntu ship libav instead of ffmpeg :



                #!/bin/sh
                for f in *.mp4; do
                avprobe -v quiet -show_format_entry duration "$f"
                done | paste -sd+ | bc


                Heavily based on MvG ideas






                share|improve this answer



























                  0














                  As ubuntu ship libav instead of ffmpeg :



                  #!/bin/sh
                  for f in *.mp4; do
                  avprobe -v quiet -show_format_entry duration "$f"
                  done | paste -sd+ | bc


                  Heavily based on MvG ideas






                  share|improve this answer

























                    0












                    0








                    0






                    As ubuntu ship libav instead of ffmpeg :



                    #!/bin/sh
                    for f in *.mp4; do
                    avprobe -v quiet -show_format_entry duration "$f"
                    done | paste -sd+ | bc


                    Heavily based on MvG ideas






                    share|improve this answer














                    As ubuntu ship libav instead of ffmpeg :



                    #!/bin/sh
                    for f in *.mp4; do
                    avprobe -v quiet -show_format_entry duration "$f"
                    done | paste -sd+ | bc


                    Heavily based on MvG ideas







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 13 '17 at 12:37









                    Community

                    1




                    1










                    answered Dec 27 '16 at 16:15









                    Ahed EidAhed Eid

                    1463




                    1463





















                        0














                        Going off the accepted answer and using the classic UNIX reverse-polish tool:



                         find . -maxdepth 2 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 
                        -show_entries format=duration ; ; printf '+n60n*np'; | dc



                        783.493000




                        I.e.: Appening + and p then piping that into dc and you'll get your sum.






                        share|improve this answer


















                        • 1




                          bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                          – A T
                          Feb 9 '17 at 13:59















                        0














                        Going off the accepted answer and using the classic UNIX reverse-polish tool:



                         find . -maxdepth 2 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 
                        -show_entries format=duration ; ; printf '+n60n*np'; | dc



                        783.493000




                        I.e.: Appening + and p then piping that into dc and you'll get your sum.






                        share|improve this answer


















                        • 1




                          bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                          – A T
                          Feb 9 '17 at 13:59













                        0












                        0








                        0






                        Going off the accepted answer and using the classic UNIX reverse-polish tool:



                         find . -maxdepth 2 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 
                        -show_entries format=duration ; ; printf '+n60n*np'; | dc



                        783.493000




                        I.e.: Appening + and p then piping that into dc and you'll get your sum.






                        share|improve this answer














                        Going off the accepted answer and using the classic UNIX reverse-polish tool:



                         find . -maxdepth 2 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 
                        -show_entries format=duration ; ; printf '+n60n*np'; | dc



                        783.493000




                        I.e.: Appening + and p then piping that into dc and you'll get your sum.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 9 '17 at 14:26

























                        answered Feb 9 '17 at 13:56









                        A TA T

                        1054




                        1054







                        • 1




                          bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                          – A T
                          Feb 9 '17 at 13:59












                        • 1




                          bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                          – A T
                          Feb 9 '17 at 13:59







                        1




                        1




                        bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                        – A T
                        Feb 9 '17 at 13:59




                        bc gets way too much love. You're all putting + signs between each line (joining on +), whereas with reverse-polish you can just chuck a + on the end and print it out ;)
                        – A T
                        Feb 9 '17 at 13:59











                        0














                        Well, these all solution need a bit of work, what I did was very simple,
                        1)



                        1. went to the desired folder and right click -> open with other
                          application


                        2. Then select VLC media player,


                        3. this will start playing one of the videos, but then

                        4. press ctrl + L, and you will see the playlist of the videos and somewhere on top left corner you will see total duration

                        here is example



                        1.
                        List item



                        2.enter image description here



                        3.enter image description here



                        You can see just under the toolbar, there is Playlist[10:35:51] written,
                        so folder contains 10 hours 35 mins and 51 sec duration of total videos






                        share|improve this answer

























                          0














                          Well, these all solution need a bit of work, what I did was very simple,
                          1)



                          1. went to the desired folder and right click -> open with other
                            application


                          2. Then select VLC media player,


                          3. this will start playing one of the videos, but then

                          4. press ctrl + L, and you will see the playlist of the videos and somewhere on top left corner you will see total duration

                          here is example



                          1.
                          List item



                          2.enter image description here



                          3.enter image description here



                          You can see just under the toolbar, there is Playlist[10:35:51] written,
                          so folder contains 10 hours 35 mins and 51 sec duration of total videos






                          share|improve this answer























                            0












                            0








                            0






                            Well, these all solution need a bit of work, what I did was very simple,
                            1)



                            1. went to the desired folder and right click -> open with other
                              application


                            2. Then select VLC media player,


                            3. this will start playing one of the videos, but then

                            4. press ctrl + L, and you will see the playlist of the videos and somewhere on top left corner you will see total duration

                            here is example



                            1.
                            List item



                            2.enter image description here



                            3.enter image description here



                            You can see just under the toolbar, there is Playlist[10:35:51] written,
                            so folder contains 10 hours 35 mins and 51 sec duration of total videos






                            share|improve this answer












                            Well, these all solution need a bit of work, what I did was very simple,
                            1)



                            1. went to the desired folder and right click -> open with other
                              application


                            2. Then select VLC media player,


                            3. this will start playing one of the videos, but then

                            4. press ctrl + L, and you will see the playlist of the videos and somewhere on top left corner you will see total duration

                            here is example



                            1.
                            List item



                            2.enter image description here



                            3.enter image description here



                            You can see just under the toolbar, there is Playlist[10:35:51] written,
                            so folder contains 10 hours 35 mins and 51 sec duration of total videos







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 27 '18 at 4:51









                            Patel Ujjval RajeshbhaiPatel Ujjval Rajeshbhai

                            1




                            1



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f170961%2fget-total-duration-of-video-files-in-a-directory%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown






                                Popular posts from this blog

                                Peggy Mitchell

                                Palaiologos

                                The Forum (Inglewood, California)