Opened 12 years ago
Closed 9 years ago
#3831 closed defect (fixed)
conversion to bgr8 does not work correctly for some resolutions
| Reported by: | Chillance | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | swscale |
| Version: | git-master | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | no |
Description
Well, basically I'm trying to convert a movie to an animated gif. I love that it's as easy as:
ffmpeg -i movie_to_be_animated.mp4 output.gif
However, using 1.x branch the colors aren't as good:
http://pastebin.com/qWkNPrKP - this works, but colors aren't as good. especially with fading, and the file is huge (17MB).
I prefer this:
http://pastebin.com/hrpaavJT
However, as you can see in the attatched file, there is a flickering going on on the right there. And this is what this ticket is about. Why is that happening?
Change History (7)
comment:1 by , 12 years ago
| Component: | undetermined → avcodec |
|---|---|
| Keywords: | gif added |
| Reproduced by developer: | set |
| Status: | new → open |
| Summary: | Slight right line flickering when converting to animated .gif → gif encoder uses uninitialized memory for some resolutions |
| Version: | 2.3 → git-master |
comment:2 by , 12 years ago
| Component: | avcodec → swscale |
|---|---|
| Keywords: | regression added |
| Priority: | normal → important |
| Summary: | gif encoder uses uninitialized memory for some resolutions → conversion to bgr8 does not work correctly for some resolutions |
Not gif related:
$ ffmpeg -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -s 214x214 -qscale 2 -an out.mov
$ ffmpeg -i out.mov -pix_fmt bgr8 -f rawvideo out
ffmpeg version N-65368-g7c73d21 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 7 2014 10:00:38 with gcc 4.7 (SUSE Linux)
configuration: --enable-gpl
libavutil 52. 98.100 / 52. 98.100
libavcodec 55. 73.100 / 55. 73.100
libavformat 55. 52.100 / 55. 52.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.102 / 4. 11.102
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
artist : Logan Kelsey
artist-eng : Logan Kelsey
title : Vertical Online SV3 Demo
title-eng : Vertical Online SV3 Demo
encoder : Lavf55.52.100
copyright : © Vertical Online 2001
copyright-eng : © Vertical Online 2001
Duration: 00:00:43.60, start: 0.000000, bitrate: 697 kb/s
Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 214x214 [SAR 1:1 DAR 1:1], 696 kb/s, 30 fps, 30 tbr, 15360 tbn, 30 tbc (default)
Metadata:
handler_name : DataHandler
encoder : Lavc55.73.100 mpeg4
[swscaler @ 0x3361520] No accelerated colorspace conversion found from yuv420p to bgr8.
Output #0, rawvideo, to 'out':
Metadata:
major_brand : qt
minor_version : 512
compatible_brands: qt
artist : Logan Kelsey
artist-eng : Logan Kelsey
title : Vertical Online SV3 Demo
title-eng : Vertical Online SV3 Demo
copyright-eng : © Vertical Online 2001
copyright : © Vertical Online 2001
encoder : Lavf55.52.100
Stream #0:0(eng): Video: rawvideo (BGR[8] / 0x8524742), bgr8, 214x214 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
handler_name : DataHandler
encoder : Lavc55.73.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame= 1308 fps=0.0 q=0.0 Lsize= 58497kB time=00:00:43.60 bitrate=10991.0kbits/s
video:58497kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Decoding the output file shows artefacts on the right border.
comment:3 by , 12 years ago
| Keywords: | regression removed |
|---|---|
| Priority: | important → normal |
Not really a regression, the border used to be initialized though.
comment:5 by , 12 years ago
[19:55] <Chillance> so, what is going on with https://trac.ffmpeg.org/ticket/3831 ?
Sorry, I wasn't aware you are searching for a workaround - in this case, it would have been better to report to the ffmpeg-user mailing list.
The issue is not reproducible if you actually scale, the following is an example command line, many others are possible:
$ ffmpeg -i movie_to_be_animated.mp4 -vf super2xsai,scale=w=iw/2:h=ih/2 out.gif
Note that if you look at my examples, it was always necessary to create an input video with the right resolution first because scaling "fixes" the issue.
comment:6 by , 12 years ago
Ok, so that works, but means I had to redo the mp4 file, so I could scale it down. But hey, it works! Thanks!
comment:7 by , 9 years ago
| Keywords: | gif removed |
|---|---|
| Resolution: | → fixed |
| Status: | open → closed |
Fixed in 3d00ba2688f69a55ed2832349b802997bef7f876, duplicate of ticket #2570.



For future tickets:
Please test current FFmpeg git head before reporting problems, always provide the
ffmpegcommand line that allows to reproduce the issue together with the complete uncut console output, do not use external resources except for large files, do not attach output files unless explicitely asked to and please do not attach compressed files (unless necessary).$ valgrind ./ffmpeg_g -i lena.mov out.gif ==6659== Memcheck, a memory error detector ==6659== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==6659== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==6659== Command: ./ffmpeg_g -i lena.mov out.gif ==6659== ffmpeg version N-65350-g40a820d Copyright (c) 2000-2014 the FFmpeg developers built on Aug 6 2014 21:37:45 with gcc 4.7 (SUSE Linux) configuration: --enable-gpl libavutil 52. 98.100 / 52. 98.100 libavcodec 55. 72.102 / 55. 72.102 libavformat 55. 51.101 / 55. 51.101 libavdevice 55. 13.102 / 55. 13.102 libavfilter 4. 11.102 / 4. 11.102 libswscale 2. 6.100 / 2. 6.100 libswresample 0. 19.100 / 0. 19.100 libpostproc 52. 3.100 / 52. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'lena.mov': Metadata: major_brand : qt minor_version : 512 compatible_brands: qt encoder : Lavf55.51.101 Duration: 00:00:10.00, start: 0.000000, bitrate: 261 kb/s Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 214x214 [SAR 1:1 DAR 1:1], 259 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default) Metadata: handler_name : DataHandler encoder : Lavc55.72.102 mpeg4 ==6659== Invalid read of size 8 ==6659== at 0x6D2659F: __GI___strncasecmp_l (in /lib64/libc-2.15.so) ==6659== by 0x6CDA8A5: ____strtod_l_internal (in /lib64/libc-2.15.so) ==6659== by 0xE2C33E: av_strtod (eval.c:99) ==6659== by 0xE2CB84: parse_primary (eval.c:332) ==6659== by 0xE2D630: parse_factor (eval.c:492) ==6659== by 0xE2D82B: parse_term (eval.c:541) ==6659== by 0xE2C8CE: parse_expr (eval.c:565) ==6659== by 0xE2DA2C: av_expr_parse (eval.c:683) ==6659== by 0xE2DB73: av_expr_parse_and_eval (eval.c:720) ==6659== by 0x4E23E6: config_props (vf_scale.c:262) ==6659== by 0x495DBC: avfilter_config_links (avfilter.c:254) ==6659== by 0x495D9F: avfilter_config_links (avfilter.c:243) ==6659== Address 0xaff2900 is 0 bytes inside a block of size 3 alloc'd ==6659== at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0xE35729: av_malloc (mem.c:95) ==6659== by 0xE2D975: av_expr_parse (eval.c:660) ==6659== by 0xE2DB73: av_expr_parse_and_eval (eval.c:720) ==6659== by 0x4E23E6: config_props (vf_scale.c:262) ==6659== by 0x495DBC: avfilter_config_links (avfilter.c:254) ==6659== by 0x495D9F: avfilter_config_links (avfilter.c:243) ==6659== by 0x49A1A8: avfilter_graph_config (avfiltergraph.c:275) ==6659== by 0x47BE17: configure_filtergraph (ffmpeg_filter.c:912) ==6659== by 0x4801F9: transcode_init (ffmpeg.c:2686) ==6659== by 0x46B593: main (ffmpeg.c:3641) ==6659== ==6659== Invalid read of size 8 ==6659== at 0x6D265A7: __GI___strncasecmp_l (in /lib64/libc-2.15.so) ==6659== by 0x6CDA8A5: ____strtod_l_internal (in /lib64/libc-2.15.so) ==6659== by 0xE2C33E: av_strtod (eval.c:99) ==6659== by 0xE2CB84: parse_primary (eval.c:332) ==6659== by 0xE2D630: parse_factor (eval.c:492) ==6659== by 0xE2D82B: parse_term (eval.c:541) ==6659== by 0xE2C8CE: parse_expr (eval.c:565) ==6659== by 0xE2DA2C: av_expr_parse (eval.c:683) ==6659== by 0xE2DB73: av_expr_parse_and_eval (eval.c:720) ==6659== by 0x4E23E6: config_props (vf_scale.c:262) ==6659== by 0x495DBC: avfilter_config_links (avfilter.c:254) ==6659== by 0x495D9F: avfilter_config_links (avfilter.c:243) ==6659== Address 0xaff2908 is 5 bytes after a block of size 3 alloc'd ==6659== at 0x4C290FE: memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0x4C291A7: posix_memalign (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0xE35729: av_malloc (mem.c:95) ==6659== by 0xE2D975: av_expr_parse (eval.c:660) ==6659== by 0xE2DB73: av_expr_parse_and_eval (eval.c:720) ==6659== by 0x4E23E6: config_props (vf_scale.c:262) ==6659== by 0x495DBC: avfilter_config_links (avfilter.c:254) ==6659== by 0x495D9F: avfilter_config_links (avfilter.c:243) ==6659== by 0x49A1A8: avfilter_graph_config (avfiltergraph.c:275) ==6659== by 0x47BE17: configure_filtergraph (ffmpeg_filter.c:912) ==6659== by 0x4801F9: transcode_init (ffmpeg.c:2686) ==6659== by 0x46B593: main (ffmpeg.c:3641) ==6659== [swscaler @ 0xaff3080] No accelerated colorspace conversion found from yuv420p to bgr8. Output #0, gif, to 'out.gif': Metadata: major_brand : qt minor_version : 512 compatible_brands: qt encoder : Lavf55.51.101 Stream #0:0(eng): Video: gif, bgr8, 214x214 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 25 fps, 100 tbn, 25 tbc (default) Metadata: handler_name : DataHandler encoder : Lavc55.72.102 gif Stream mapping: Stream #0:0 -> #0:0 (mpeg4 (native) -> gif (native)) Press [q] to stop, [?] for help ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x8FC128: ff_lzw_encode (lzwenc.c:105) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Use of uninitialised value of size 8 ==6659== at 0x8FC150: ff_lzw_encode (lzwenc.c:132) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Use of uninitialised value of size 8 ==6659== at 0x8FC20D: ff_lzw_encode (lzwenc.c:152) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Use of uninitialised value of size 8 ==6659== at 0x8FC173: ff_lzw_encode (lzwenc.c:246) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Use of uninitialised value of size 8 ==6659== at 0x8FC15D: ff_lzw_encode (lzwenc.c:133) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x8FC161: ff_lzw_encode (lzwenc.c:133) ==6659== by 0x6F06F1: gif_encode_frame (gif.c:190) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x4C2D0E3: bcmp (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0x6F0C92: gif_encode_frame (gif.c:99) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x6F0F6A: gif_encode_frame (gif.c:121) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x6F0F9F: gif_encode_frame (gif.c:121) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== ==6659== Conditional jump or move depends on uninitialised value(s) ==6659== at 0x4C2D0E3: bcmp (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6659== by 0x6F0B9E: gif_encode_frame (gif.c:94) ==6659== by 0xA977D3: avcodec_encode_video2 (utils.c:2034) ==6659== by 0x4838B1: reap_filters (ffmpeg.c:1045) ==6659== by 0x46BB34: main (ffmpeg.c:3627) ==6659== frame= 250 fps= 69 q=0.0 Lsize= 68kB time=00:00:10.00 bitrate= 55.7kbits/s video:317kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown ==6659== ==6659== HEAP SUMMARY: ==6659== in use at exit: 128 bytes in 3 blocks ==6659== total heap usage: 42,002 allocs, 41,999 frees, 23,477,624 bytes allocated ==6659== ==6659== LEAK SUMMARY: ==6659== definitely lost: 0 bytes in 0 blocks ==6659== indirectly lost: 0 bytes in 0 blocks ==6659== possibly lost: 0 bytes in 0 blocks ==6659== still reachable: 128 bytes in 3 blocks ==6659== suppressed: 0 bytes in 0 blocks ==6659== Rerun with --leak-check=full to see details of leaked memory ==6659== ==6659== For counts of detected and suppressed errors, rerun with: -v ==6659== Use --track-origins=yes to see where uninitialised values come from ==6659== ERROR SUMMARY: 325417 errors from 12 contexts (suppressed: 2 from 2)out.gif looks ugly.