Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I extract video file resolution of 320x240 , text on it is looking good and readable. In case if I give input video of resolution 1280x720 or any greater values the text on it isn't readable. It resizes or scales but the text is looking bad.

Is it possible to apply text filter after image converted or any method available.
You can find the image (at bottom of question) and ffmpeg output below.

$ ffmpeg.exe -ss 30 -i 1.mp4 -f image2 -vframes 1 -s 320x240 -vf \
  "drawtext=fontfile=/WINDOWS/Fonts/arial.ttf: timecode='00\:00\:00\:00': \
  r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" \
  ram.jpg

ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 26 2013 01:50:16 with gcc 4.8.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 38.100 / 52. 38.100
  libavcodec     55. 18.102 / 55. 18.102
  libavformat    55. 12.100 / 55. 12.100
  libavdevice    55.  3.100 / 55.  3.100
  libavfilter     3. 79.101 /  3. 79.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.12.100
  Duration: 00:19:57.82, start: 2.242000, bitrate: 1345 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x544, 1343 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      handler_name    : VideoHandler
Output #0, image2, to 'ram.jpg':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.12.100
    Stream #0:0(und): Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 23.98 tbc
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=0 drop=21    
video:9kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.244499%

Both pictures with and without size ram without specifying size
ram after specifying size

share|improve this question
    
Please include the complete ffmpeg console output. –  LordNeckbeard Oct 15 '13 at 17:29
    
@LordNeckbeard i have updated the ffmpeg out and also attached both image for above command in skydrive. –  RamKumar Oct 16 '13 at 9:55

1 Answer 1

up vote 4 down vote accepted

You should scale the image with the scale video filter before using drawtext:

$ ffmpeg.exe -ss 30 -i 1.mp4 -vframes 1 -q:v 2 -vf "scale=320:-1, \
  drawtext=fontfile=/WINDOWS/Fonts/arial.ttf: timecode='00\:00\:00\:00': \
  r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" \
  ram.jpg
  • Use the scale video filter instead of -s because you can control when the scale occurs: before or after any other filter(s).

  • Declaring just one dimension and then using -1 on the other will allow ffmpeg to automatically choose the correct value to preserve aspect.

  • I added -q:v 2 for output quality since I assume the defaults are not sufficient in this case. If you want it more compressed then use a higher value. Effective range is 2-31 for jpg.

  • I removed -f image2 because it is not needed here.

Also see:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.