Why does FFmpeg append blank black video to the end of my MP4 files when compressed from MOV?

1

I have several large MOV files that I want to compress to MP4.

Unfortunately, when I use FFmpeg, it appends lots of black (blank) video at the end.

(The destination file is longer than the source file.)

For example, I have a file that is 02:22:01 in duration (and the FFmpeg output logs confirm this).

But when I run the following command (which takes more than 20 minutes even on "ultrafast"), I get an MP4 file that looks mostly good but has lots of black frames appended to the end such that the total video duration becomes 3:59:59.

ffmpeg -i "F:\video_project\uncompressed\Tape_12.mov" -vcodec libx264 -preset ultrafast -crf 18 -n -threads 16 -f mp4 "F:\video_project\compressed\Tape_12.mp4" 2>&1

This happens with my other MOV-to-MP4 conversions too. The duration of black video appended to the end can be 20 to 80+ minutes long (it's not the same for each different video).

What am I doing wrong?

My logs are here.

P.S. I'm using PowerShell 4 in Windows 7.

Update:

In response to LordNeckBeard, when I run ffmpeg.exe -i F:\video_project\compressed\Tape_12.mp4, the result is:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\video_project\compressed\Tape_12.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.22.101
  Duration: 03:59:59.94, start: 0.033333, bitrate: 5389 kb/s
    Stream #0:0(eng): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 720x480 [SAR 10:11 DAR 15:11], 5252 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

In response to Rajib, when I run ffmpeg.exe -i F:\video_project\uncompressed\Tape_12.mov, the result is:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\video_project\uncompressed\Tape_12.mov':
  Metadata:
    creation_time   : 2014-01-05 02:35:17
  Duration: 02:22:01.04, start: -6.064083, bitrate: 51226 kb/s
    Stream #0:0(eng): Video: dvvideo (dvc  / 0x20637664), yuv411p, 720x480 [SAR 8:9 DAR 4:3], 28771 kb/s, SAR 10:11 DAR
15:11, 29.97 fps, 29.97 tbr, 2997 tbn, 29.97 tbc (default)
    Metadata:
      creation_time   : 2014-01-05 06:35:18
      handler_name    : Apple Alias Data Handler
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16, 768 kb/s (default)
    Metadata:
      creation_time   : 2014-01-05 06:35:18
      handler_name    : Apple Alias Data Handler
    Stream #0:2(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, s16, 768 kb/s (default)
    Metadata:
      creation_time   : 2014-01-05 06:35:18
      handler_name    : Apple Alias Data Handler

Ryan

Posted 2014-03-06T22:08:43.053

Reputation: 959

What does ffmpeg say of the duration of the output? ffmpeg -i Tape_12.mp4 What is telling you the duration is 3:59:59? All information should be included within your question instead of relying on external resources (you can omit the multiple repeating frame= lines). – llogan – 2014-03-06T23:41:21.690

@LordNeckbeard, ffmpeg and Windows Explorer ("Details" view) both say that the mp4 duration is 3:59:59. I'll paste the result of your suggested query above. – Ryan – 2014-03-07T00:22:57.110

@Rajib I added the information that you requested. – Ryan – 2014-03-07T03:46:43.267

@Rajib I did as you instructed, and the resulting videos were identical to the MP4s from before; each had the same amount of black video appended as each had before. The logs are here: https://drive.google.com/folderview?id=0B9iQ20nrMNYAakZSenZNRTBjRE0&usp=sharing

– Ryan – 2014-03-07T04:53:02.633

Well the workaround is to put -t 02:22:01.04 in the command explicitly, but it does not solve the issue. – Rajib – 2014-03-07T05:16:49.167

I think my problem is related to the fact that the MOV file seems to have a "start" value of -6.064083 (as shown in my question). I don't know why. Since it has an incorrect start time, I bet it also has an artificial "end" time. Then FFmpeg creates an mp4 file for the full duration instead of the actual playable duration. See also: http://stackoverflow.com/questions/10640088/why-does-ffmpeg-report-different-durations

– Ryan – 2014-03-11T16:22:05.897

Answers

0

The problem is probably that you are not speeding up the audio track so the new video stays as long as the original one. Either delete the audio track with the -an option or speed it up accordingly with the ​atempo audio filter.

muzzle

Posted 2014-03-06T22:08:43.053

Reputation: 21