0

I used youtube-dl to obtain a friends video. When I play it in VLC, I notice there is no time/length shown. As we need to cut part of this video with ffmpeg, can I use ffmpeg (or similar tool) to determine the length of the video, and then update the MP4 to contain the time/length ?

oygle
  • 11
  • 8
  • with a cli/term session you can 'ffmpeg -i $my.mp4' and the stdout will show various streams/tracks and the duration of each. thats not automated solution . may be other probes / parsers that have better api for gets on that metadata than ffmpeg. not sure – Robert Rowntree Dec 09 '15 at 01:51
  • Thanks Robert. That worked fine and I may only need Konsole to do it, as the previous mp4 file had the time/length in it (used youtube-dl to obtain it from periscope). Here is the part of the output .. Duration: 00:09:03.12, start: 24.154000, bitrate: 317 kb/s Program 1 Stream #0:0[0x102]: Data: timed_id3 (ID3 / 0x20334449) Stream #0:1[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 320x568, 24 tbr, 90k tbn, 180k tbc Stream #0:2[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, mono, fltp, 93 kb/s At least one output file must be specified – oygle Dec 09 '15 at 02:03
  • When I used ffmpeg to cut part of the mp4, without knowing the total length, the output didn't have any length/time. Now that I know the duration, and tried ffmpeg again, the output file contains the duration. Here is what I used `ffmpeg -ss 00:00:05 -i VideoClip2.mp4 -t 00:08:58 -c copy -bsf:a aac_adtstoasc VideoClip2.new.mp4` – oygle Dec 09 '15 at 02:25
  • Okay, so the duration has been added into the destination MP4. Still need to know how to write the duration into the source MP4 file. No doubt the duration is in a header/s. – oygle Dec 09 '15 at 03:39
  • Output will have time if you "move the atom" to the head of the file. ---flag is the name of the declarative for move atom – Robert Rowntree Dec 09 '15 at 04:29
  • Looked at https://ffmpeg.org/ffmpeg.html , and the only reference to atom was `-cpuflags flags (global)` – oygle Dec 09 '15 at 06:25
  • http://stackoverflow.com/questions/8061798/post-processing-in-ffmpeg-to-move-moov-atom-in-mp4-files-qt-faststart. -movflags faststart – Robert Rowntree Dec 09 '15 at 09:13
  • @oygle Try to simply remux it `fmpeg -i source.mp4 -c copy output.mp4`. `faststart` is only useful for progressive download. – aergistal Dec 09 '15 at 09:28
  • @aergistal - Tried that command, got errrors - `[mp4 @ 0x1ecace0] Codec for stream 0 does not use global headers but container format requires global headers [mp4 @ 0x1ecace0] Codec for stream 1 does not use global headers but container format requires global headers` and the conversion failed – oygle Dec 10 '15 at 06:42
  • Have simply used the `-i` parameter to get the duration. Then used that value to create an MP4 of _that_ length (duration). Then play it and determine where the start/stop should be. Thanks everyone for your help. – oygle Dec 10 '15 at 06:44
  • @oygle add `-flags +global_header` for the last error. – aergistal Dec 10 '15 at 08:57

0 Answers0