there is no Lossless JPEG cmpresstion in libjpeg if you are dealing with single images use mozjpeg[1]
[1] https://github.com/mozilla/mozjpeg On Thu, 3 Apr 2025 at 18:20, Gianluca Cannata <gcannat...@gmail.com> wrote: > > What is the right command to produce a Lossless JPEG file ? > > magick wizard: ppm:- | ffmpeg -v trace -i - -map 0:v -c:v ljpeg -b:v 1M > -pred median -f mjpeg -y wizard.jpg > ffmpeg version N-119135-g1722f08acf Copyright (c) 2000-2025 the FFmpeg > developers > built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04) > configuration: --prefix=/usr --disable-static --enable-shared > --enable-gpl --enable-version3 --disable-doc --disable-avdevice > --enable-swresample --disable-swscale --disable-postproc --disable-network > --disable-everything --enable-protocol='fd, file, subfile, pipe' > --enable-demuxer='image_jpeg_pipe, mjpeg, mpjpeg, smjpeg, image_ppm_pipe' > --enable-muxer='mjpeg, mpjpeg, smjpeg' --enable-decoder='mjpeg, ppm' > --enable-encoder='ljpeg, mjpeg, ppm' --disable-ffplay > libavutil 60. 0.100 / 60. 0.100 > libavcodec 62. 0.101 / 62. 0.101 > libavformat 62. 0.100 / 62. 0.100 > libavfilter 11. 0.100 / 11. 0.100 > libswresample 6. 0.100 / 6. 0.100 > Splitting the commandline. > Reading option '-v' ... matched as option 'v' (set logging level) with > argument 'trace'. > Reading option '-i' ... matched as input url with argument '-'. > Reading option '-map' ... matched as option 'map' (set input stream > mapping) with argument '0:v'. > Reading option '-c:v' ... matched as option 'c' (select encoder/decoder > ('copy' to copy stream without reencoding)) with argument 'ljpeg'. > Reading option '-b:v' ... matched as option 'b' (video bitrate (please use > -b:v)) with argument '1M'. > Reading option '-pred' ... matched as AVOption 'pred' with argument > 'median'. > Reading option '-f' ... matched as option 'f' (force container format > (auto-detected otherwise)) with argument 'mjpeg'. > Reading option '-y' ... matched as option 'y' (overwrite output files) with > argument '1'. > Reading option 'wizard.jpg' ... matched as output url. > Finished splitting the commandline. > Parsing a group of options: global . > Applying option v (set logging level) with argument trace. > Applying option y (overwrite output files) with argument 1. > Successfully parsed a group of options. > Parsing a group of options: input url -. > Successfully parsed a group of options. > Opening an input file: -. > [AVFormatContext @ 0x5ea397c38a40] Opening 'fd:' for reading > [fd @ 0x5ea397c39200] Setting default whitelist 'crypto,data' > Probing ppm_pipe score:52 size:2048 > [ppm_pipe @ 0x5ea397c38a40] Format ppm_pipe probed with size=2048 and > score=52 > [ppm_pipe @ 0x5ea397c38a40] Before avformat_find_stream_info() pos: 0 bytes > read:16384 seeks:0 nb_streams:1 > [ppm_pipe @ 0x5ea397c38a40] parser not found for codec ppm, packets or > times may be invalid. > [ppm_pipe @ 0x5ea397c38a40] stream 0: start_time: NOPTS duration: NOPTS > [ppm_pipe @ 0x5ea397c38a40] format: start_time: NOPTS duration: NOPTS > (estimate from bit rate) bitrate=0 kb/s > [ppm_pipe @ 0x5ea397c38a40] Could not find codec parameters for stream 0 > (Video: ppm, 1 reference frame, none): unspecified size > Consider increasing the value for the 'analyzeduration' (0) and 'probesize' > (5000000) options > [ppm_pipe @ 0x5ea397c38a40] After avformat_find_stream_info() pos: 0 bytes > read:16384 seeks:0 frames:0 > Input #0, ppm_pipe, from 'fd:': > Duration: N/A, bitrate: N/A > Stream #0:0, 0, 1/25: Video: ppm, 1 reference frame, none, 25 fps, 25 > tbr, 25 tbn > Successfully opened the file. > Parsing a group of options: output url wizard.jpg. > Applying option map (set input stream mapping) with argument 0:v. > Parsing stream specifier: v > Parsed media type: video; remainder: > Applying option c:v (select encoder/decoder ('copy' to copy stream without > reencoding)) with argument ljpeg. > Parsing stream specifier: v > Parsed media type: video; remainder: > Applying option b:v (video bitrate (please use -b:v)) with argument 1M. > Applying option f (force container format (auto-detected otherwise)) with > argument mjpeg. > Successfully parsed a group of options. > Opening an output file: wizard.jpg. > [out#0/mjpeg @ 0x5ea397c3b5c0] Adding streams from explicit maps... > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] Created video stream from input stream 0:0 > Parsing stream specifier: v > Parsed media type: video; remainder: > [file @ 0x5ea397c48040] Setting default whitelist 'file,crypto,data' > Successfully opened the file. > Stream mapping: > Stream #0:0 -> #0:0 (ppm (native) -> ljpeg (native)) > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] Starting thread... > [vf#0:0 @ 0x5ea397c3d680] Starting thread... > [vist#0:0/ppm @ 0x5ea397c3ae40] [dec:ppm @ 0x5ea397c43880] Starting > thread... > [in#0/ppm_pipe @ 0x5ea397c386c0] Starting thread... > [in#0/ppm_pipe @ 0x5ea397c386c0] EOF while reading input > [in#0/ppm_pipe @ 0x5ea397c386c0] Terminating thread with return code 0 > (success) > [vist#0:0/ppm @ 0x5ea397c3ae40] [dec:ppm @ 0x5ea397c43880] Decoder thread > received EOF packet > [vist#0:0/ppm @ 0x5ea397c3ae40] [dec:ppm @ 0x5ea397c43880] Decoder returned > EOF, finishing > [vist#0:0/ppm @ 0x5ea397c3ae40] [dec:ppm @ 0x5ea397c43880] Terminating > thread with return code 0 (success) > [vf#0:0 @ 0x5ea397c3d680] Cannot determine format of input 0:0 after EOF > [vf#0:0 @ 0x5ea397c3d680] Task finished with error code: -1094995529 > (Invalid data found when processing input) > [vf#0:0 @ 0x5ea397c3d680] Terminating thread with return code -1094995529 > (Invalid data found when processing input) > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] [enc:ljpeg @ 0x5ea397c3cb00] Encoder > thread received EOF > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] [enc:ljpeg @ 0x5ea397c3cb00] Could not > open encoder before EOF > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] Task finished with error code: -22 > (Invalid argument) > [vost#0:0/ljpeg @ 0x5ea397c3c0c0] Terminating thread with return code -22 > (Invalid argument) > [out#0/mjpeg @ 0x5ea397c3b5c0] Nothing was written into output file, > because at least one of its streams received no packets. > frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A > > [AVIOContext @ 0x5ea397c47f00] Statistics: 0 bytes written, 0 seeks, 0 > writeouts > [in#0/ppm_pipe @ 0x5ea397c386c0] Input file #0 (fd:): > [in#0/ppm_pipe @ 0x5ea397c386c0] Input stream #0:0 (video): 0 packets > read (0 bytes); 0 frames decoded; 0 decode errors; > [in#0/ppm_pipe @ 0x5ea397c386c0] Total: 0 packets (0 bytes) demuxed > [AVIOContext @ 0x5ea397c495c0] Statistics: 16384 bytes read, 0 seeks > Conversion failed! > > Gianluca > _______________________________________________ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".