-1

I need to split a section of a video, paste a logo and also blur a video online. I know how to do these but the problem is, I don't know how to make sure that the result video is suitable for web. For example there is a mp4 video in my website which is playing via the browser, and using this code I cut a section of it:

exec("ffmpeg -i ".$source." -ss ".$start." -to ".$end."  -c copy ".$newVideo);

The problem is, when the distance between $start and $end is more than a few minutes, the split operation is done but it is not played via browser.

What codec or library do I need to add as filter to make sure that the result video is always playing on all modern browsers?

M a m a D
  • 1,938
  • 2
  • 30
  • 61

1 Answers1

1

Use

exec("ffmpeg -i ".$source." -ss ".$start." -to ".$end." -movflags +faststart  ".$newVideo);

for a precise cut. This command will transcode the video.


Use

exec("ffmpeg -i ".$source." -ss ".$start." -to ".$end."  -c copy -avoid_negative_ts make_zero -movflags +faststart ".$newVideo);

for a cut, without transcoding. But this will be imprecise, depending on where the keyframes are.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • In order to build a progressbar for these operations, I need to output the statues of the operation in a text file. This is your code for blurring a video. `exec('ffmpeg -i '.$url.' -filter_complex "[0:v]scale=iw*sar:ih,setsar=1,split[bg][bb];[bb]crop='.$iWidth.'*iw/800:iw*'.$iHeight.'/800:'.$iWidth.'*iw/800:'.$iHeight.'*iw/800,boxblur=min(min(cw/2\,ch/2)\,10)[b0];[bg][b0]overlay='.$iLeft.'*W/800:'.$iTop.'*W/800" -movflags +faststart '.$newVideo.' > '.$txtfile.' 2>&1');` I added `-movflags +faststart` and also `> '.$txtfile.'`. Am I doing right? Because it doesn't work as expected. – M a m a D Jul 30 '16 at 19:01
  • This code blurs the video but the progressbar never gets to `100%`, it reaches `48%` and stops – M a m a D Jul 30 '16 at 19:03
  • I got the progressbar code from http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php – M a m a D Jul 30 '16 at 19:59