Convert AVI (Xvid) to MP4 (H.264) keeping the same quality












40














I want to compress an AVI file to MP4 using an h.264 codec. I could not get the same quality. How can I compress it?



Original Video:



Original Video Screen:





FFmpeg console output (ffmpeg -i input.avi):



FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopenc ore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libop enjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
[mpeg4 @ 0x626b50] Invalid and inefficient vfw-avi packed B frames detected
Input #0, avi, from 'input.avi':
Metadata:
encoder : VirtualDubMod 1.5.10.2 (build 2542/release)
Duration: 01:32:38.13, start: 0.000000, bitrate: 2094 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 23.98 tbr, 23.98 tbn, 23.98 tbc
Stream #0.1: Audio: ac3, 44100 Hz, 5.1, s16, 384 kb/s
At least one output file must be specified


Test 1



FFmpeg command:



ffmpeg -i input.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 1.mp4


Test 1 Screen:





FFmpeg console output (ffmpeg -i 1.mp4)



    FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.93.0
Duration: 00:01:00.01, start: 0.000000, bitrate: 618 kb/s
Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 437 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(und): Audio: aac, 44100 Hz, 5.1, s16, 176 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
At least one output file must be specified


Test 2



FFmpeg command:



ffmpeg -y -i input.avi -pass 1 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -f mp4 -an -y /dev/null
ffmpeg -y -i input.avi -pass 2 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -acodec libfaac -ab 128k -ac 2 2.mp4


Test 2 Screen:





FFmpeg console output (ffmpeg -i 2.mp4)



FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.93.0
Duration: 00:01:00.01, start: 0.000000, bitrate: 1097 kb/s
Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 1028 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 63 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
At least one output file must be specified









share|improve this question





























    40














    I want to compress an AVI file to MP4 using an h.264 codec. I could not get the same quality. How can I compress it?



    Original Video:



    Original Video Screen:





    FFmpeg console output (ffmpeg -i input.avi):



    FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
    configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopenc ore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libop enjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
    libavutil 50.36. 0 / 50.36. 0
    libavcore 0.16. 1 / 0.16. 1
    libavcodec 52.108. 0 / 52.108. 0
    libavformat 52.93. 0 / 52.93. 0
    libavdevice 52. 2. 3 / 52. 2. 3
    libavfilter 1.74. 0 / 1.74. 0
    libswscale 0.12. 0 / 0.12. 0
    [mpeg4 @ 0x626b50] Invalid and inefficient vfw-avi packed B frames detected
    Input #0, avi, from 'input.avi':
    Metadata:
    encoder : VirtualDubMod 1.5.10.2 (build 2542/release)
    Duration: 01:32:38.13, start: 0.000000, bitrate: 2094 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0.1: Audio: ac3, 44100 Hz, 5.1, s16, 384 kb/s
    At least one output file must be specified


    Test 1



    FFmpeg command:



    ffmpeg -i input.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 1.mp4


    Test 1 Screen:





    FFmpeg console output (ffmpeg -i 1.mp4)



        FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
    configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
    libavutil 50.36. 0 / 50.36. 0
    libavcore 0.16. 1 / 0.16. 1
    libavcodec 52.108. 0 / 52.108. 0
    libavformat 52.93. 0 / 52.93. 0
    libavdevice 52. 2. 3 / 52. 2. 3
    libavfilter 1.74. 0 / 1.74. 0
    libswscale 0.12. 0 / 0.12. 0
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
    Duration: 00:01:00.01, start: 0.000000, bitrate: 618 kb/s
    Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 437 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
    creation_time : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, 5.1, s16, 176 kb/s
    Metadata:
    creation_time : 1970-01-01 00:00:00
    At least one output file must be specified


    Test 2



    FFmpeg command:



    ffmpeg -y -i input.avi -pass 1 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -f mp4 -an -y /dev/null
    ffmpeg -y -i input.avi -pass 2 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -acodec libfaac -ab 128k -ac 2 2.mp4


    Test 2 Screen:





    FFmpeg console output (ffmpeg -i 2.mp4)



    FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
    built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
    configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
    libavutil 50.36. 0 / 50.36. 0
    libavcore 0.16. 1 / 0.16. 1
    libavcodec 52.108. 0 / 52.108. 0
    libavformat 52.93. 0 / 52.93. 0
    libavdevice 52. 2. 3 / 52. 2. 3
    libavfilter 1.74. 0 / 1.74. 0
    libswscale 0.12. 0 / 0.12. 0
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
    Metadata:
    major_brand : isom
    minor_version : 512
    compatible_brands: isomiso2avc1mp41
    creation_time : 1970-01-01 00:00:00
    encoder : Lavf52.93.0
    Duration: 00:01:00.01, start: 0.000000, bitrate: 1097 kb/s
    Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 1028 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
    creation_time : 1970-01-01 00:00:00
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 63 kb/s
    Metadata:
    creation_time : 1970-01-01 00:00:00
    At least one output file must be specified









    share|improve this question



























      40












      40








      40


      32





      I want to compress an AVI file to MP4 using an h.264 codec. I could not get the same quality. How can I compress it?



      Original Video:



      Original Video Screen:





      FFmpeg console output (ffmpeg -i input.avi):



      FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopenc ore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libop enjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      [mpeg4 @ 0x626b50] Invalid and inefficient vfw-avi packed B frames detected
      Input #0, avi, from 'input.avi':
      Metadata:
      encoder : VirtualDubMod 1.5.10.2 (build 2542/release)
      Duration: 01:32:38.13, start: 0.000000, bitrate: 2094 kb/s
      Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 23.98 tbr, 23.98 tbn, 23.98 tbc
      Stream #0.1: Audio: ac3, 44100 Hz, 5.1, s16, 384 kb/s
      At least one output file must be specified


      Test 1



      FFmpeg command:



      ffmpeg -i input.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 1.mp4


      Test 1 Screen:





      FFmpeg console output (ffmpeg -i 1.mp4)



          FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      creation_time : 1970-01-01 00:00:00
      encoder : Lavf52.93.0
      Duration: 00:01:00.01, start: 0.000000, bitrate: 618 kb/s
      Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 437 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
      Metadata:
      creation_time : 1970-01-01 00:00:00
      Stream #0.1(und): Audio: aac, 44100 Hz, 5.1, s16, 176 kb/s
      Metadata:
      creation_time : 1970-01-01 00:00:00
      At least one output file must be specified


      Test 2



      FFmpeg command:



      ffmpeg -y -i input.avi -pass 1 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -f mp4 -an -y /dev/null
      ffmpeg -y -i input.avi -pass 2 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -acodec libfaac -ab 128k -ac 2 2.mp4


      Test 2 Screen:





      FFmpeg console output (ffmpeg -i 2.mp4)



      FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      creation_time : 1970-01-01 00:00:00
      encoder : Lavf52.93.0
      Duration: 00:01:00.01, start: 0.000000, bitrate: 1097 kb/s
      Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 1028 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
      Metadata:
      creation_time : 1970-01-01 00:00:00
      Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 63 kb/s
      Metadata:
      creation_time : 1970-01-01 00:00:00
      At least one output file must be specified









      share|improve this question















      I want to compress an AVI file to MP4 using an h.264 codec. I could not get the same quality. How can I compress it?



      Original Video:



      Original Video Screen:





      FFmpeg console output (ffmpeg -i input.avi):



      FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopenc ore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libop enjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      [mpeg4 @ 0x626b50] Invalid and inefficient vfw-avi packed B frames detected
      Input #0, avi, from 'input.avi':
      Metadata:
      encoder : VirtualDubMod 1.5.10.2 (build 2542/release)
      Duration: 01:32:38.13, start: 0.000000, bitrate: 2094 kb/s
      Stream #0.0: Video: mpeg4, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 23.98 tbr, 23.98 tbn, 23.98 tbc
      Stream #0.1: Audio: ac3, 44100 Hz, 5.1, s16, 384 kb/s
      At least one output file must be specified


      Test 1



      FFmpeg command:



      ffmpeg -i input.avi -vcodec libx264 -vpre lossless_slow -crf 25 -acodec libfaac -threads 0 -t 60 1.mp4


      Test 1 Screen:





      FFmpeg console output (ffmpeg -i 1.mp4)



          FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      creation_time : 1970-01-01 00:00:00
      encoder : Lavf52.93.0
      Duration: 00:01:00.01, start: 0.000000, bitrate: 618 kb/s
      Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 437 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
      Metadata:
      creation_time : 1970-01-01 00:00:00
      Stream #0.1(und): Audio: aac, 44100 Hz, 5.1, s16, 176 kb/s
      Metadata:
      creation_time : 1970-01-01 00:00:00
      At least one output file must be specified


      Test 2



      FFmpeg command:



      ffmpeg -y -i input.avi -pass 1 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -f mp4 -an -y /dev/null
      ffmpeg -y -i input.avi -pass 2 -vcodec libx264 -vpre slow -b 2000k -threads 0 -t 60 -acodec libfaac -ab 128k -ac 2 2.mp4


      Test 2 Screen:





      FFmpeg console output (ffmpeg -i 2.mp4)



      FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
      built on Dec 28 2012 10:03:40 with gcc 4.4.6 20120305 (Red Hat 4.4.6-4)
      configuration: --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-pthreads --enable-x11grab --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libfaac --enable-libmp3lame --enable-libopenjpeg --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-filter=drawtext
      libavutil 50.36. 0 / 50.36. 0
      libavcore 0.16. 1 / 0.16. 1
      libavcodec 52.108. 0 / 52.108. 0
      libavformat 52.93. 0 / 52.93. 0
      libavdevice 52. 2. 3 / 52. 2. 3
      libavfilter 1.74. 0 / 1.74. 0
      libswscale 0.12. 0 / 0.12. 0
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
      Metadata:
      major_brand : isom
      minor_version : 512
      compatible_brands: isomiso2avc1mp41
      creation_time : 1970-01-01 00:00:00
      encoder : Lavf52.93.0
      Duration: 00:01:00.01, start: 0.000000, bitrate: 1097 kb/s
      Stream #0.0(und): Video: h264, yuv420p, 720x304 [PAR 1:1 DAR 45:19], 1028 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
      Metadata:
      creation_time : 1970-01-01 00:00:00
      Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 63 kb/s
      Metadata:
      creation_time : 1970-01-01 00:00:00
      At least one output file must be specified






      ffmpeg video-conversion h.264 video-encoding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 22 '17 at 13:36









      grawity

      231k35487544




      231k35487544










      asked Dec 28 '12 at 14:42









      Ahmet KAPIKIRAN

      3321412




      3321412






















          1 Answer
          1






          active

          oldest

          votes


















          54














          First of all, install a more recent version of FFmpeg – grab a static build from the download page.



          The use of vpre presets (which is a way to set default values for ffmpeg settings, not encoder settings) is not really necessary; you usually want to use the -preset options defined by the encoders.



          The reasons you get low output quality are the following, for your two cases respectively:





          1. In the first case you use crf 25, a Constant Rate Factor that's going to give you worse quality than the default for the x264 encoder (which is 23). The CRF controls the quality. Try setting a lower CRF, maybe 20, 18, etc. Here, lower means better quality, but it'll increase the file size. A change of 6 in the CRF gives you twice/half the original average bitrate, roughly speaking.



            You'll have to set a lower CRF because of the generation loss. You're encoding something that was already encoded, so you're again throwing away visual information. That's never good, but if you have to, you're going to have to set a higher quality so as not to remove too much information from the input video.




          2. In the second case you're trying to set a constant bit rate of 2 MBit/s. Your input video roughly has the same bit rate. Now, x264 delivers much better visual quality than an MPEG-4 Visual encoder for the same bitrate, but due to the generation loss, again, you might want to use an even higher bitrate than the original – otherwise you'll end up compressing away too much information.



            Furthermore, constant bitrate encoding might result in some passages looking good, but other parts of the video looking worse. If you don't let the encoder freely choose the amount of bits it wants to spend on something, you're going to sacrifice quality at the expense of knowing the target file size.



            x264 does have a constant bit rate mode, but it's considered inferior to the other encoding methods. Actually, two-pass encoding isn't meant to target optimal quality, so scratch that.




          That all being said, try something along the following:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfdk_aac -b:a 192k -ac 2 out.mp4


          If libfdk_aac is not available, use this instead:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4


          The main quality control knob will be your CRF setting. Experiment with that and use a lower value if you need better quality.



          You can also choose the veryslow preset, which will give you better compression, but the encoding will obviously take longer.



          If you can't manage to get a decent quality file at a reasonable file size, then you're out of luck. Better keep the original file as-is, without re-encoding. There's no magic "keeping the same quality" tool when you're compressing something that's already compressed.






          share|improve this answer























          • If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
            – slhck
            Dec 28 '12 at 15:54






          • 8




            @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
            – llogan
            Dec 28 '12 at 18:24










          • @LordNeckbeard thank u for comment.
            – Ahmet KAPIKIRAN
            Dec 28 '12 at 20:52






          • 1




            @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
            – llogan
            Dec 28 '12 at 21:39








          • 3




            @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
            – slhck
            Jul 17 '14 at 17:27










          protected by slhck Sep 1 '14 at 17:15



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          54














          First of all, install a more recent version of FFmpeg – grab a static build from the download page.



          The use of vpre presets (which is a way to set default values for ffmpeg settings, not encoder settings) is not really necessary; you usually want to use the -preset options defined by the encoders.



          The reasons you get low output quality are the following, for your two cases respectively:





          1. In the first case you use crf 25, a Constant Rate Factor that's going to give you worse quality than the default for the x264 encoder (which is 23). The CRF controls the quality. Try setting a lower CRF, maybe 20, 18, etc. Here, lower means better quality, but it'll increase the file size. A change of 6 in the CRF gives you twice/half the original average bitrate, roughly speaking.



            You'll have to set a lower CRF because of the generation loss. You're encoding something that was already encoded, so you're again throwing away visual information. That's never good, but if you have to, you're going to have to set a higher quality so as not to remove too much information from the input video.




          2. In the second case you're trying to set a constant bit rate of 2 MBit/s. Your input video roughly has the same bit rate. Now, x264 delivers much better visual quality than an MPEG-4 Visual encoder for the same bitrate, but due to the generation loss, again, you might want to use an even higher bitrate than the original – otherwise you'll end up compressing away too much information.



            Furthermore, constant bitrate encoding might result in some passages looking good, but other parts of the video looking worse. If you don't let the encoder freely choose the amount of bits it wants to spend on something, you're going to sacrifice quality at the expense of knowing the target file size.



            x264 does have a constant bit rate mode, but it's considered inferior to the other encoding methods. Actually, two-pass encoding isn't meant to target optimal quality, so scratch that.




          That all being said, try something along the following:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfdk_aac -b:a 192k -ac 2 out.mp4


          If libfdk_aac is not available, use this instead:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4


          The main quality control knob will be your CRF setting. Experiment with that and use a lower value if you need better quality.



          You can also choose the veryslow preset, which will give you better compression, but the encoding will obviously take longer.



          If you can't manage to get a decent quality file at a reasonable file size, then you're out of luck. Better keep the original file as-is, without re-encoding. There's no magic "keeping the same quality" tool when you're compressing something that's already compressed.






          share|improve this answer























          • If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
            – slhck
            Dec 28 '12 at 15:54






          • 8




            @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
            – llogan
            Dec 28 '12 at 18:24










          • @LordNeckbeard thank u for comment.
            – Ahmet KAPIKIRAN
            Dec 28 '12 at 20:52






          • 1




            @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
            – llogan
            Dec 28 '12 at 21:39








          • 3




            @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
            – slhck
            Jul 17 '14 at 17:27
















          54














          First of all, install a more recent version of FFmpeg – grab a static build from the download page.



          The use of vpre presets (which is a way to set default values for ffmpeg settings, not encoder settings) is not really necessary; you usually want to use the -preset options defined by the encoders.



          The reasons you get low output quality are the following, for your two cases respectively:





          1. In the first case you use crf 25, a Constant Rate Factor that's going to give you worse quality than the default for the x264 encoder (which is 23). The CRF controls the quality. Try setting a lower CRF, maybe 20, 18, etc. Here, lower means better quality, but it'll increase the file size. A change of 6 in the CRF gives you twice/half the original average bitrate, roughly speaking.



            You'll have to set a lower CRF because of the generation loss. You're encoding something that was already encoded, so you're again throwing away visual information. That's never good, but if you have to, you're going to have to set a higher quality so as not to remove too much information from the input video.




          2. In the second case you're trying to set a constant bit rate of 2 MBit/s. Your input video roughly has the same bit rate. Now, x264 delivers much better visual quality than an MPEG-4 Visual encoder for the same bitrate, but due to the generation loss, again, you might want to use an even higher bitrate than the original – otherwise you'll end up compressing away too much information.



            Furthermore, constant bitrate encoding might result in some passages looking good, but other parts of the video looking worse. If you don't let the encoder freely choose the amount of bits it wants to spend on something, you're going to sacrifice quality at the expense of knowing the target file size.



            x264 does have a constant bit rate mode, but it's considered inferior to the other encoding methods. Actually, two-pass encoding isn't meant to target optimal quality, so scratch that.




          That all being said, try something along the following:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfdk_aac -b:a 192k -ac 2 out.mp4


          If libfdk_aac is not available, use this instead:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4


          The main quality control knob will be your CRF setting. Experiment with that and use a lower value if you need better quality.



          You can also choose the veryslow preset, which will give you better compression, but the encoding will obviously take longer.



          If you can't manage to get a decent quality file at a reasonable file size, then you're out of luck. Better keep the original file as-is, without re-encoding. There's no magic "keeping the same quality" tool when you're compressing something that's already compressed.






          share|improve this answer























          • If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
            – slhck
            Dec 28 '12 at 15:54






          • 8




            @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
            – llogan
            Dec 28 '12 at 18:24










          • @LordNeckbeard thank u for comment.
            – Ahmet KAPIKIRAN
            Dec 28 '12 at 20:52






          • 1




            @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
            – llogan
            Dec 28 '12 at 21:39








          • 3




            @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
            – slhck
            Jul 17 '14 at 17:27














          54












          54








          54






          First of all, install a more recent version of FFmpeg – grab a static build from the download page.



          The use of vpre presets (which is a way to set default values for ffmpeg settings, not encoder settings) is not really necessary; you usually want to use the -preset options defined by the encoders.



          The reasons you get low output quality are the following, for your two cases respectively:





          1. In the first case you use crf 25, a Constant Rate Factor that's going to give you worse quality than the default for the x264 encoder (which is 23). The CRF controls the quality. Try setting a lower CRF, maybe 20, 18, etc. Here, lower means better quality, but it'll increase the file size. A change of 6 in the CRF gives you twice/half the original average bitrate, roughly speaking.



            You'll have to set a lower CRF because of the generation loss. You're encoding something that was already encoded, so you're again throwing away visual information. That's never good, but if you have to, you're going to have to set a higher quality so as not to remove too much information from the input video.




          2. In the second case you're trying to set a constant bit rate of 2 MBit/s. Your input video roughly has the same bit rate. Now, x264 delivers much better visual quality than an MPEG-4 Visual encoder for the same bitrate, but due to the generation loss, again, you might want to use an even higher bitrate than the original – otherwise you'll end up compressing away too much information.



            Furthermore, constant bitrate encoding might result in some passages looking good, but other parts of the video looking worse. If you don't let the encoder freely choose the amount of bits it wants to spend on something, you're going to sacrifice quality at the expense of knowing the target file size.



            x264 does have a constant bit rate mode, but it's considered inferior to the other encoding methods. Actually, two-pass encoding isn't meant to target optimal quality, so scratch that.




          That all being said, try something along the following:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfdk_aac -b:a 192k -ac 2 out.mp4


          If libfdk_aac is not available, use this instead:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4


          The main quality control knob will be your CRF setting. Experiment with that and use a lower value if you need better quality.



          You can also choose the veryslow preset, which will give you better compression, but the encoding will obviously take longer.



          If you can't manage to get a decent quality file at a reasonable file size, then you're out of luck. Better keep the original file as-is, without re-encoding. There's no magic "keeping the same quality" tool when you're compressing something that's already compressed.






          share|improve this answer














          First of all, install a more recent version of FFmpeg – grab a static build from the download page.



          The use of vpre presets (which is a way to set default values for ffmpeg settings, not encoder settings) is not really necessary; you usually want to use the -preset options defined by the encoders.



          The reasons you get low output quality are the following, for your two cases respectively:





          1. In the first case you use crf 25, a Constant Rate Factor that's going to give you worse quality than the default for the x264 encoder (which is 23). The CRF controls the quality. Try setting a lower CRF, maybe 20, 18, etc. Here, lower means better quality, but it'll increase the file size. A change of 6 in the CRF gives you twice/half the original average bitrate, roughly speaking.



            You'll have to set a lower CRF because of the generation loss. You're encoding something that was already encoded, so you're again throwing away visual information. That's never good, but if you have to, you're going to have to set a higher quality so as not to remove too much information from the input video.




          2. In the second case you're trying to set a constant bit rate of 2 MBit/s. Your input video roughly has the same bit rate. Now, x264 delivers much better visual quality than an MPEG-4 Visual encoder for the same bitrate, but due to the generation loss, again, you might want to use an even higher bitrate than the original – otherwise you'll end up compressing away too much information.



            Furthermore, constant bitrate encoding might result in some passages looking good, but other parts of the video looking worse. If you don't let the encoder freely choose the amount of bits it wants to spend on something, you're going to sacrifice quality at the expense of knowing the target file size.



            x264 does have a constant bit rate mode, but it's considered inferior to the other encoding methods. Actually, two-pass encoding isn't meant to target optimal quality, so scratch that.




          That all being said, try something along the following:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfdk_aac -b:a 192k -ac 2 out.mp4


          If libfdk_aac is not available, use this instead:



          ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 out.mp4


          The main quality control knob will be your CRF setting. Experiment with that and use a lower value if you need better quality.



          You can also choose the veryslow preset, which will give you better compression, but the encoding will obviously take longer.



          If you can't manage to get a decent quality file at a reasonable file size, then you're out of luck. Better keep the original file as-is, without re-encoding. There's no magic "keeping the same quality" tool when you're compressing something that's already compressed.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 14 at 9:09

























          answered Dec 28 '12 at 14:53









          slhck

          159k47439463




          159k47439463












          • If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
            – slhck
            Dec 28 '12 at 15:54






          • 8




            @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
            – llogan
            Dec 28 '12 at 18:24










          • @LordNeckbeard thank u for comment.
            – Ahmet KAPIKIRAN
            Dec 28 '12 at 20:52






          • 1




            @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
            – llogan
            Dec 28 '12 at 21:39








          • 3




            @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
            – slhck
            Jul 17 '14 at 17:27


















          • If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
            – slhck
            Dec 28 '12 at 15:54






          • 8




            @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
            – llogan
            Dec 28 '12 at 18:24










          • @LordNeckbeard thank u for comment.
            – Ahmet KAPIKIRAN
            Dec 28 '12 at 20:52






          • 1




            @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
            – llogan
            Dec 28 '12 at 21:39








          • 3




            @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
            – slhck
            Jul 17 '14 at 17:27
















          If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
          – slhck
          Dec 28 '12 at 15:54




          If your video is smaller in size after the conversion with two passes, you need to specify a higher bitrate. Try -b:v 3M or more; but I'd recommend using the CRF method instead of the two-pass variant.
          – slhck
          Dec 28 '12 at 15:54




          8




          8




          @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
          – llogan
          Dec 28 '12 at 18:24




          @AhmetKa Another option is to simply re-mux the streams from AVI container to MP4 container: ffmpeg -i input.avi -c copy -map 0 output.mp4. There is no re-encoding so there is no quality loss.
          – llogan
          Dec 28 '12 at 18:24












          @LordNeckbeard thank u for comment.
          – Ahmet KAPIKIRAN
          Dec 28 '12 at 20:52




          @LordNeckbeard thank u for comment.
          – Ahmet KAPIKIRAN
          Dec 28 '12 at 20:52




          1




          1




          @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
          – llogan
          Dec 28 '12 at 21:39






          @AhmetKa I should have mentioned that muxing will not always work if the output container format does not support media formats of the input. See Comparison of container formats to get a general idea of what works.
          – llogan
          Dec 28 '12 at 21:39






          3




          3




          @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
          – slhck
          Jul 17 '14 at 17:27




          @hyde You should prefer -c:a aac -strict experimental instead of libvo_aacenc, because it delivers better quality.
          – slhck
          Jul 17 '14 at 17:27





          protected by slhck Sep 1 '14 at 17:15



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?



          Popular posts from this blog

          If I really need a card on my start hand, how many mulligans make sense? [duplicate]

          Alcedinidae

          Can an atomic nucleus contain both particles and antiparticles? [duplicate]