FFmpeg concat mp4 corruption

2

1

When I run

ffmpeg -f concat -i resizedvideolist.txt -c copy concatenated_time.mp4 2>&1

it concatenates all the videos in the txt, but there is one video around halfway through that get glitched out. The audio just doesn't play for that video, but then starts playing on the next video, so it has been delayed. Then somewhere the audio managed to catch up and gets back in sync. Seems like some major corruption going on here.

I do not know how to fix this as the codec is the same as all the other vidoes, H.264, it is an mp4 like the others. The individual video file runs fine as it is, and it already is in the same timescale, because before this ffmpeg command, I ran

ffmpeg -i ./tempDownloadedMemes/$videoFileName -filter_complex 'scale=1080:-1,pad=1080:1080:(ow-iw)/2:(oh-ih)/2:0x2F2F2F' -video_track_timescale 15360 ./resizedVideos/resized_videoFileName 2>&1

To be honest I don't even know what timescale is, but I read that it needs to be the same for it to work. I deleted the video from the list, tried this same command, and the problem was gone at the same time in the video that it would have appeared. It seems like it is something to do with that one file itself. Any known issues/workarounds on concat bugs? This is very important to me. Thanks.

Ethan SK

Posted 2017-04-11T15:18:37.343

Reputation: 31

1You need to show info about each input. ffmpeg -i input0 -i input1 -i input2 – llogan – 2017-04-11T19:10:41.560

Just found this answer on SO. The problem might be the call from shell_exec which might not let ffmpeg clean up memory and thus corrupt the video file.

– mab – 2018-11-14T15:47:02.903

Answers

1

meh, I found a really hacky workaround using another concat method.

$resizedVideoList = file('resizedVideoList.txt', FILE_IGNORE_NEW_LINES);
$inputStringForConcat = "";
$concatString = "";
$concateNvalue = 0;
 foreach ($resizedVideoList as $key => $value) {
   //$limiter++;
   //if ($limiter > 2)break;
   $inputStringForConcat .= " -i ".$value;
   $concatString .= "[$key:0][$key:1]";
   $concateNvalue++;
 }
 $concatString .= " concat=n=$concateNvalue:v=1:a=1[v][a]";
  echo ("<pre>");
    print_r($inputStringForConcat);
    print_r($concatString);


 echo shell_exec("./ffmpeg $inputStringForConcat -filter_complex '$concatString' -map '[v]' -map '[a]' concatenated_time.mp4 2>&1");

Ethan SK

Posted 2017-04-11T15:18:37.343

Reputation: 31