Ubuntu – Avconv creates zero byte file while trying to downsample mp4 video

avconvvideo

I am having a time lapse video created using my phone that I am trying to downsample from 1080p to 640×480.

According to this answer, I am using avconv command

avconv -i input.mp4 -s 640x480 output.mp4

but it creates a 0 byte file which obviously contains nothing.

The output of the command is as follows

a@b:~$avconv  -i ./Videos/CivilStudy.mp4 -s 640x480 ./abc.mp4
avconv version     9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Aug 10 2014 18:19:26 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Videos/CivilStudy.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.64.2
  Duration: 00:00:43.58, start: 0.000000, bitrate: 10159 kb/s
    Stream #0.0(und): Video: mpeg4 (Simple Profile), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 10025 kb/s, 24 fps, 24 tbr, 24 tbn, 24 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, mono, fltp, 129 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
[libx264 @ 0x843bde0] using SAR=4/3
[libx264 @ 0x843bde0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 0x843bde0] profile High, level 3.0
[libx264 @ 0x843bde0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec -     Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00
encoder 'aac' is experimental and might produce bad results.
Add '-strict experimental' if you want to use it

What do I do now?

Best Answer

During this conversion both video and audio need to be decoded from the original file and then encoded to the target file. In this case the original file happens to have the audio encoded with 'aac' (Advanced Audio Coding). The decoding of the audio is not a problem, only encoding to 'aac' encoded audio seems to be problematic.

See the last two lines of the output above:

encoder 'aac' is experimental and might produce bad results.
Add '-strict experimental' if you want to use it

As stated in the message the encoder 'aac' is experimental. To use it anyway add '-strict experimental' like this:

avconv -i input.mp4 -s 640x480 -strict experimental output.mp4

This will use the experimental encoder to produce a video with embedded audio which is encoded with 'aac'. If the parameter is omitted no output is created (only a zero byte file). So, no encoder is used in that case. I was able to convert a video like that with no problem. If the codec does not work for you, you can specify an other codec for audio like that (using mp3 as an example):

avconv -i input.mp4 -acodec mp3 -s 640x480 output.mp4

If is no audible soundtrack in that recording at all - since you are converting a time lapse - you might not want to embed audio at all. To achieve this use the parameter -an:

avconv -i input.mp4 -an -s 640x480 output.mp4