0

I have some old videos collected using a canon camera, they are in avi format. I am not able to play the files on android though the audio works fine, it says Can't play video, videocodec not supported. I tried the following but it still doesn't work:

ffmpeg -i ip.avi -c:v libx264 -c:a aac -movflags +faststart op.mp4

Original avi video info:

Input #0, avi, from 'ip.avi'
Metadata:
    creation_time   : 2012-11-17 11:38:53
    encoder         : CanonMVI03
  Duration: 00:01:39.90, start: 0.000000, bitrate: 16256 kb/s
    Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 14844 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s

Converted mp4 video info:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'op.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:01:39.92, start: 0.000000, bitrate: 2048 kb/s
    Stream #0:0(und): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuvj422p(pc), 640x480, 1911 kb/s, 30 fps, 30 tbr, 1000k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
momo
  • 1,052
  • 5
  • 16
  • 34

1 Answers1

1

From posts here and here the following worked:

ffmpeg -i ip.avi -c:v libx264 -c:a aac op.mp4
ffmpeg -i op.mp4 -vf "scale=2*trunc(iw/2):-2,setsar=1" -profile:v main -pix_fmt yuv420p newop.mp4
momo
  • 1,052
  • 5
  • 16
  • 34
  • 2
    No need for two commands. Just use `ffmpeg -i ip.avi -pix_fmt yuv420p -movflags +faststart op.mp4`. The missing `-pix_fmt yuv420p` is the reason why Android couldn't play it since it can only play yuv420p pixel format. – llogan Jan 11 '21 at 17:49