videoffmpegh.264video-encodingamazon-elastic-transcoder

FFMPEG drops supposedly corrupt frames from original video while transcoding using h264 encoder


I am using h264 for optimising MP4 for web. I have a video which has some supposedly corrupt frame(s) within it's initial 1-2 seconds. (Frame provided below)Corrupt Frame As seen in VLC Media Player.

On transcoding using :

ffmpeg -i orig.mp4 -c:v libx264 -crf 25 -vf scale="-2:min(ih\,720)" -b:v 600K -g 90 -c:a libfdk_aac output.mp4

The output MP4 has these frames dropped out and I have my output with it's start about 1 to 2 seconds delayed from original video, thus resulting in overall less time duration in output video.

Moreover, most media players also skip these frames in playback (like quicktime player, etc). But VLC media player was able to play this video without skipping these frames.

Is there a way to not drop frames using ffmpeg? And if possible is it possible to identify and fix these frames in a video?

Note: I tried encoding same video using AWS Elastic transcoder which actually fixed these frames (Frame provided below) : Frame from video transcoded by Elastic Transcoder

Note: Original video can be found here - https://drive.google.com/file/d/0B9VkhR9Zu60ybXFDeno3RGpQTUE/view?usp=sharing Video transcoded by AWS Elsatic transcoder can be found here - https://drive.google.com/file/d/0B9VkhR9Zu60yWUVHQk5MTk05QVk/view?usp=sharing

EDIT1: As suggested by @Mulvya in comments, TS-transcoded video can be found here - (https://drive.google.com/file/d/0B9VkhR9Zu60yU0t6T0dMME9ZMmc/view?usp=sharing)


Solution

  • Your source video has some frames without timestamps.

    In this particular case, extracting to raw bitstream and then transcoding works:

    ffmpeg -i orig.mp4 -c copy orig.264
    
    ffmpeg -i orig.264 -i orig.mp4 -map 0 -map 1:a -c:v libx264 -crf 25 -vf scale="-2:min(ih\,720)" -b:v 600K -g 90 -c:a libfdk_aac output.mp4