5

I would like to use Tesseract OCR with a video.

With ffmpeg I can export some (.jpeg) images from a video. Can I convert a .jpeg into a valid .tiff or export directly .tiff images from the video with ffmpeg?

slhck
  • 223,558
  • 70
  • 607
  • 592
Tenaciousd93
  • 445
  • 3
  • 5
  • 9
  • I think you can export directly to tiff from ffmpeg... http://stackoverflow.com/questions/1717331/convert-video-file-to-tiff-with-ffmpeg-dll-or-avcodec-dll-is-on-the-fly-possi – Kinnectus Oct 17 '14 at 07:45
  • Hello, thank you for your reply! No, the links in that accepted answer are broken and the other answers didn't export correcly `.tiff` images. – Tenaciousd93 Oct 17 '14 at 09:18

1 Answers1

8

Converting to TIFF

You can convert a JPEG to TIFF:

ffmpeg -i input.jpeg -pix_fmt rgba output.tiff

Or from a video:

ffmpeg -i input.mp4 -pix_fmt rgba out%05d.tiff

What's important is specifying the RGBA colorspace via -pix_fmt rgba. Keeping the YUV 4:2:0 colorspace from video (-pix_fmt yuv420p) would produce TIFF files that cannot be opened in most programs (even though the YCbCr* colorspace is allowed).

How to compress output

By default this produces uncompressed TIFF images. You can choose a different compression algorithm using the -compression_algo option:

ffmpeg -i input.jpeg -pix_fmt rgb24 -compression_algo lzw output.tiff

Valid options are packbits, raw, lzw and deflate (see ffmpeg -h encoder=tiff).

* YCbCr refers to what in video compression is usually known as YUV

slhck
  • 223,558
  • 70
  • 607
  • 592
  • Wow, amazing! That solve my problem! :) Thank you very much! – Tenaciousd93 Oct 20 '14 at 06:57
  • Using this method, I end up with TIFFs that are huge compared to outputting (say) PNG and then converting to TIFF using ImageMagick; something that 0.5MB vs 3MB. Do you know why that is? Presumably something to do with compression. How do I enable lossless compression on the TIFFs?\ – Ray Mar 06 '18 at 10:50
  • 1
    @Ray See updated answer, there are some options for specifying compression algorithms. – slhck Mar 06 '18 at 11:08
  • what is ```-pix_fmt```? can you please tell what command I need to run inorder to compress the image without change the file extension? – Mahesh Jamdade Apr 06 '21 at 09:04
  • @MaheshJamdade It's the color space/color format of the input. If you simply want to compress an image without changing extension, have a look at https://stackoverflow.com/questions/7261855/recommendation-for-compressing-jpg-files-with-imagemagick or similar. – slhck Apr 06 '21 at 10:58
  • @slhck thanks for the response but I am looking for a ffmpeg solution because I am using this https://github.com/tanersener/flutter-ffmpeg – Mahesh Jamdade Apr 06 '21 at 11:10