Laurent Nguyen
Forum Replies Created
-
Hi Andrea,
If you consider data to be your string containing the 16-bit image data (without the header), the “even” bytes will go to the first image while the “odd” bytes will go to the second image. It basically means that the first 8-bit image will contain one out of two bytes of the 16-bit image; similarly, the second image will contain the other half.
In python, the parsing looks like that:
msb_data = data[::2]
lsb_data = data[1::2]Where msb_data is the 8-bit image containing the “even” bytes and lsb_data the other 8-bit image.
Hope I was clear ;-). If needed, don’t hesitate to ask
Cheers,
Laurent
-
Hey Ryan,
I frankly don’t know why it does that. I am quite new to ffmpeg as well ;-). However, there might be some possible tricks:
1. Have you checked the values in your 3 x nx x ny matrix (decoded image) ? If they are all the same values, you could just use one plane.
2. You can also try using a pgm image format as output. I however don’t know if that makes a difference.
3. You can try to force the output format to be grayscale by adding -pix_fmt gray in the end of your call
I won’t say no to a beer 😉
Good luck !
Laurent
-
Hi Ryan,
if I understand your post correctly, you want to do lossless encoding of 8-bit grayscale images.
My call to ffmpeg for 8 bit images is:
ffmpeg -f rawvideo -r 25 -y -s vga -pix_fmt gray -i msb.pipe -an -vcodec ffv1 msb.movI am using a named pipe as input. If you are using images as input, it should look like:
ffmpeg -f image2 -s vga -pix_fmt gray -i im_folder/im%05d.pgm -an -vcodec ffv1 movie.movThe output pixel format will be yuv420p, but when you decode it, you’ll get 8bit grayscale images, and if you compare it to the original input image (image difference), you’ll get an image of value zero. The code for decoding:
ffmpeg -y -s vga -pix_fmt gray -i msb.mov -an temp/msb%05d.pgmHope it helps ! Cheers,
Laurent
-
Hi Michael,
I made the thing work ! I finally implemented the two stream solution. It works like a charm, with a framerate of ~60fps, all lossless.
Thank you very much for your valuable help and advice, it has been a pleasure. If you were around, I would pay you several beers !
Cheers,
Laurent
-
Hey Michael,
thanks for the feedback. Too bad it is not working directly. Let’s go for the 2 stream solution, then ;-). Do you by any chance know of a clean way to do the extraction of the 8bit images from the 16bit image ?
Cheers,
Laurent
-
Hi Michael,
Thanks for your response.
I guess the real question is, what are you trying to achieve by using this pixel format? Is it for delivery to viewers or an intermediary step?
I am trying to encode depth data from a kinect device. The depth images from the kinect are 11bit depth coded on 16bit greyscale images. I want to first record the data, then process them offline. As the sequences may be arbitrarily long, it is necessary for me to have compression. On the other hand, I don’t want to take the risk of using lossy compression as it will add artifacts to the data. So in short, yes, I am using ffmpeg as an intermediary step 😉
In your opinion, what are the other options (codec-wise) rather than using ffv1 ? I am not very keen on splitting the 16 bit image into two 8bit images and using two encoders, but if it’s the only option I’ll have to resign. But if you have another option, I’m buying !!!
Thanks for your time and efforts!
Laurent
-
Hi Michael,
Sorry for my numerous messages ! I got your point with the -vf options. However, I have problems with this option. When I type:
ffmpeg -filtersI get:
FFmpeg version 0.6.2, Copyright (c) 2000-2010 the FFmpeg developers
built on May 10 2011 13:12:12 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libvpx --enable-libspeex --mandir=/opt/local/share/man --enable-shared --enable-pthreads --disable-indevs --cc=/usr/bin/gcc-4.2 --arch=x86_64 --disable-mmx --disable-mmx2 --disable-sse --disable-ssse3 --disable-amd3dnow --disable-amd3dnowext
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 1.11. 0 / 1.11. 0
Filters:It seems that I cannot use filters… What do I need to install to be able to use it ? Is it libavfilter ?
Please forgive my ignorance, thanks !
Laurent
-
Hi Michael,
I installed and tried on version 0.6, still not working ;-). When I decode the outputted film, the images are 8-bit greyscale. I am considering splitting the 16bit image into two 8bit images and launch 2 ffmpeg processes. Do you have another option for lossless encoding ?
Thanks !
Laurent
FFmpeg version 0.6.2, Copyright (c) 2000-2010 the FFmpeg developers
built on May 10 2011 13:12:12 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avfilter-lavf --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libvpx --enable-libspeex --mandir=/opt/local/share/man --enable-shared --enable-pthreads --disable-indevs --cc=/usr/bin/gcc-4.2 --arch=x86_64 --disable-mmx --disable-mmx2 --disable-sse --disable-ssse3 --disable-amd3dnow --disable-amd3dnowext
libavutil 50.15. 1 / 50.15. 1
libavcodec 52.72. 2 / 52.72. 2
libavformat 52.64. 2 / 52.64. 2
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.19. 0 / 1.19. 0
libswscale 1.11. 0 / 1.11. 0
[rawvideo @ 0x12180c800]Estimating duration from bitrate, this may be inaccurate
Input #0, rawvideo, from 'fifo.pipe':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, gray16be, 640x480, 25 tbr, 25 tbn, 25 tbc
[mov @ 0x121832600]Warning, using MS style video codec tag, the file may be unplayable!
Output #0, mov, to 'depth.mov':
Metadata:
encoder : Lavf52.64.2
Stream #0.0: Video: ffv1, yuv420p, 640x480, q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 474 fps= 48 q=0.0 Lsize= 22219kB time=18.96 bitrate=9600.2kbits/s
video:22215kB audio:0kB global headers:0kB muxing overhead 0.020406% -
Hi,
thanks for replying. My version of ffmpeg is SVN-r0.5.1-4:0.5.1-1ubuntu1.1
The output I get is:
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --extra-version=4:0.5.1-1ubuntu1.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 1 / 52.20. 1
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libavfilter 0. 4. 0 / 0. 4. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Mar 31 2011 18:59:37, gcc: 4.4.3
Input #0, rawvideo, from 'fifo.pipe':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, gray16be, 640x480, 25 tbr, 25 tbn, 25 tbc
Output #0, mov, to 'depth.mov':
Stream #0.0: Video: ffv1, yuv420p, 640x480, q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
[mov @ 0xb829a0]Warning, using MS style video codec tag, the file may be unplayable!
Press [q] to stop encoding
frame= 474 fps= 89 q=0.0 Lsize= 22219kB time=18.96 bitrate=9600.2kbits/s
video:22215kB audio:0kB global headers:0kB muxing overhead 0.020406%
I am using a named pipe (called fifo.pipe) to send the frames to ffmpeg.
Thanks !
Laurent
-
Hi,
If I only put it AFTER, there are some encoding problems (ffmpeg does not recognizes the input pix format). When put BEFORE and AFTER, the movie is encoded as yuv420p.
I’m wondering why he’s doing this. I am going to try with 8bit grayscale images and see how ffmpeg behaves.