Opened 5 years ago

Closed 5 years ago

#873 closed defect (fixed)

PCM signed big-endian encoding as unsigned

Reported by: Glinx Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: PCM signed big endian mov muxer
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Signed pcm sound codec (pcm_s16be) is encoded as unsigned and with 3ch audio instead of 6ch. After trying a few other pcm signed codecs they also came out as unsigned.

Archlinux bugtracker sent a new snapshot to try, with the same result.

Downgrading to a previous (November) release sorted this issue for me.

All command line output from FFmpeg suggested all was well and also signed.
I only noticed pcm audio (s16be) was infact unsigned and 3ch instead of 6ch when loading into the video editor (Cinelerra) and then re-checked again with the Mediainfo program.

The command I use; ffmpeg -i in.MTS -vcodec dnxhd -threads 4 -b:v 240M -pix_fmt yuv422p -acodec pcm_s16be -sn out.mov
(My .MTS files have PGS text stream).

Change History (21)

comment:1 Changed 5 years ago by cehoyos

Command line and complete, uncut console output missing.

And please test with a sample from http://samples.mplayerhq.hu/ - if this does not allow to reproduce the problem, please provide your input file.

comment:2 Changed 5 years ago by Glinx

SIGNED pcm_s16be

[gavin@gavin-desktop MTS_tests]$ ffmpeg -i 00000.MTS -vcodec dnxhd -threads 4 -b:v 240M -pix_fmt yuv422p -acodec pcm_s16be -sn out.mov
ffmpeg version N-35110-g0b9a69f, Copyright (c) 2000-2011 the FFmpeg developers

built on Nov 23 2011 12:55:01 with gcc 4.6.2
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-libgsm --enable-libspeex --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 26. 0 / 51. 26. 0
libavcodec 53. 37. 0 / 53. 37. 0
libavformat 53. 21. 0 / 53. 21. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 49. 0 / 2. 49. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0

[mpegts @ 0x1de7760] parser not found for codec hdmv_pgs_subtitle, packets or times may be invalid.
[h264 @ 0x1deb680] Increasing reorder buffer to 1
Input #0, mpegts, from '00000.MTS':

Duration: 00:00:04.81, start: 0.801678, bitrate: 27247 kb/s
Program 1

Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), s16, 384 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)

[buffer @ 0x1deeaa0] w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[buffersink @ 0x1de6fe0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0x1defc40] w:1920 h:1080 fmt:yuv420p -> w:1920 h:1080 fmt:yuv422p flags:0x4
Output #0, mov, to 'out.mov':

Metadata:

encoder : Lavf53.21.0
Stream #0:0: Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 240000 kb/s, 50 tbn, 50 tbc
Stream #0:1: Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 5.1(side), s16, 4608 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (h264 -> dnxhd)
Stream #0:1 -> #0:1 (ac3 -> pcm_s16be)

Press [q] to stop, ? for help
frame= 241 fps= 18 q=1.0 Lsize= 145393kB time=00:00:04.82 bitrate=247107.4kbits/s dup=1 drop=0
video:142672kB audio:2718kB global headers:0kB muxing overhead 0.001915%
[gavin@gavin-desktop MTS_tests]$

UNSIGNED pcm_s16be

[gavin@gavin-desktop MTS_tests]$ ffmpeg -i 00000.MTS -vcodec dnxhd -threads 4 -b:v 240M -pix_fmt yuv422p -acodec pcm_s16be -sn out.mov
ffmpeg version N-35681-g16abd68, Copyright (c) 2000-2011 the FFmpeg developers

built on Dec 11 2011 22:09:57 with gcc 4.6.2 20111125 (prerelease)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-libgsm --enable-libspeex --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-libpulse --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0

[h264 @ 0xbce680] Increasing reorder buffer to 1
Input #0, mpegts, from '00000.MTS':

Duration: 00:00:04.81, start: 0.801678, bitrate: 27247 kb/s
Program 1

Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), s16, 384 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)

[buffer @ 0xbd11a0] w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[buffersink @ 0xbd0060] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0xbca580] w:1920 h:1080 fmt:yuv420p -> w:1920 h:1080 fmt:yuv422p flags:0x4
Output #0, mov, to 'out.mov':

Metadata:

encoder : Lavf53.24.0
Stream #0:0: Video: dnxhd (AVdn / 0x6E645641), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 240000 kb/s, 50 tbn, 50 tbc
Stream #0:1: Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 5.1(side), s16, 4608 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (h264 -> dnxhd)
Stream #0:1 -> #0:1 (ac3 -> pcm_s16be)

Press [q] to stop, ? for help
frame= 241 fps= 18 q=1.0 Lsize= 145394kB time=00:00:04.82 bitrate=247109.4kbits/s dup=1 drop=0
video:142672kB audio:2718kB global headers:0kB muxing overhead 0.002705%
[gavin@gavin-desktop MTS_tests]$

I tried some dnxhd 1080p 50/25 fps s16be footage I found, they came out as u16be as well.
Regards
Gavin

comment:3 Changed 5 years ago by cehoyos

Does the problem depend on -vcodec dnxhd or is it also reproducible with
ffmpeg -i 00000.MTS -vn -sn -acodec pcm_s16be out.mov ?

The version you are testing is ~800 changes behind git master, please either test a current snapshot or 0.9.1, see http://ffmpeg.org/download.html

Why do you think your output is not signed 16bit? Please add the output of ffmpeg -i out.mov.

$ ffmpeg -i first-3_MiB-panasonic-busker-video.MTS -vn -sn -acodec pcm_s16be out.mov
ffmpeg version N-36492-g7f83db3, Copyright (c) 2000-2012 the FFmpeg developers
  built on Jan  5 2012 06:49:27 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil      51. 34.100 / 51. 34.100
  libavcodec     53. 53.100 / 53. 53.100
  libavformat    53. 29.100 / 53. 29.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 57.101 /  2. 57.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  5.100 /  0.  5.100
Input #0, mpegts, from 'first-3_MiB-panasonic-busker-video.MTS':
  Duration: 00:00:01.68, start: 0.888889, bitrate: 14979 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25.62 fps, 25 tbr, 90k tbn, 100 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, s16, 192 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
Output #0, mov, to 'out.mov':
  Metadata:
    encoder         : Lavf53.29.100
    Stream #0:0: Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (ac3 -> pcm_s16be)
Press [q] to stop, [?] for help
size=     319kB time=00:00:01.69 bitrate=1539.3kbits/s
video:0kB audio:318kB global headers:0kB muxing overhead 0.214352%

$ ffmpeg -i out.mov
ffmpeg version N-36492-g7f83db3, Copyright (c) 2000-2012 the FFmpeg developers
  built on Jan  5 2012 06:49:27 with gcc 4.5.3
  configuration: --cc=/usr/local/gcc-4.5.3/bin/gcc
  libavutil      51. 34.100 / 51. 34.100
  libavcodec     53. 53.100 / 53. 53.100
  libavformat    53. 29.100 / 53. 29.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 57.101 /  2. 57.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  5.100 /  0.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.29.100
  Duration: 00:00:01.69, start: 0.000000, bitrate: 1539 kb/s
    Stream #0:0(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, 2 channels, s16, 1536 kb/s
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    :
                        DataHandler
At least one output file must be specified

Note that FFmpeg reports the audio as 16bit signed big-endian, and both MPlayer and ffplay (and ffmpeg -i out.mov out.wav) correctly decode the sample. (None of them supports u16.)

comment:4 Changed 5 years ago by Glinx

Strange eh.
Cinelerra and Mediainfo report them as u16 (well, Cinelerra as 3ch lpcm and cant load the file on the timeline). png's attached.
I first reported this to Arch linux https://bugs.archlinux.org/task/27818 the new snapshot they sent over didnt work either. Using the Arch Linux old November release pkg resolved the issue again.

comment:5 Changed 5 years ago by cehoyos

Please provide the output of ffmpeg -i out.mov and please test ffplay out.mov (and / or mplayer out.mov).

And of course please test out.mov with QuickTime?, I believe it is the only relevant application for mov ...

Changed 5 years ago by Glinx

comment:6 Changed 5 years ago by Glinx

mplayer output

[gavin@gavin-desktop MTS_tests]$ mplayer out.mov
MPlayer2 2.0-379-ge3f5043 (C) 2000-2011 MPlayer Team
162 audio & 361 video codecs

Playing out.mov.
Detected file format: QuickTime?/MPEG-4/Motion JPEG 2000 format (libavformat)
[lavf] stream 0: audio (pcm_s16be), -aid 0, -alang eng
Clip info:

major_brand: qt
minor_version: 512
compatible_brands: qt
creation_time: 1970-01-01 00:00:00
encoder: Lavf53.24.0

Load subtitles in .
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 48000 Hz, 6 ch, s16be, 0.0 kbit/0.00% (ratio: 0->576000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
AO: [alsa] 48000Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback...
A: 4.4 (04.3) of 4.8 (04.8) 0.5%

Exiting... (End of file)
[gavin@gavin-desktop MTS_tests]$

..and ffplay -i out.mov

[gavin@gavin-desktop MTS_tests]$ ffplay -i out.mov
ffplay version N-35110-g0b9a69f, Copyright (c) 2003-2011 the FFmpeg developers

built on Nov 23 2011 12:55:01 with gcc 4.6.2
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-libgsm --enable-libspeex --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 26. 0 / 51. 26. 0
libavcodec 53. 37. 0 / 53. 37. 0
libavformat 53. 21. 0 / 53. 21. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 49. 0 / 2. 49. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mov':

Metadata:

major_brand : qt
minor_version : 512
compatible_brands: qt
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.24.0

Duration: 00:00:04.83, start: 0.000000, bitrate: 4609 kb/s

Stream #0:0(eng): Audio: pcm_s16be (lpcm / 0x6D63706C), 48000 Hz, 6 channels, s16, 4608 kb/s
Metadata:

creation_time : 1970-01-01 00:00:00
handler_name :

DataHandler?

28.94 A-V: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Seek to 5% ( 0:00:00) of total duration ( 0:00:04) B f=0/0

1.72 A-V: 0.000 fd= 0 aq= 314KB vq= 0KB sq= 0B f=0/0

[gavin@gavin-desktop MTS_tests]$

I havnt a quicktime player - Cinelerra (uses quicktime for linux) loads previous versions but not this one.

These two both suggest s16...

I remembered I have PiTiVi? VE loaded. The unsigned culprit wouldnt load the sound track in this VE either (screenshot attached)...

comment:7 Changed 5 years ago by cehoyos

Since I do not see any indication for a bug in FFmpeg, please try to find the version introducing the "regression" with git bisect.

comment:8 Changed 5 years ago by Glinx

I understand that there is a “regression” in code between 23-Nov-11 and 11-Dec-11 that I have to find and looking through the ffmpeg git web pages there seems to be 4 or 5 commits relating to pcm during these dates. However, I'm afraid this is getting beyond my knowledge base. If you can give me a step by step guide how to do this I will certainly give it a try.

comment:9 Changed 5 years ago by cehoyos

  • Component changed from FFmpeg to undetermined

A commit before 23-Nov-11: 7876f14f
A commit after 11-Dec-11: 7fad19a63

$ cd ffmpeg
$ make distclean
$ git bisect start
$ git bisect good 7876f14f
$ git bisect bad 7fad19a63
$ ./configure && make

Test the resulting ffmpeg binary and repeat the following two lines until a responsible revision is shown ("good" if the executable runs as you expect, "bad" if it the output file does not work):

$ make distclean && git bisect good / bad
$ ./configure && make

When the revision is found, post it here and run

$ make distclean && git bisect reset

comment:10 Changed 5 years ago by Glinx

git bisect output;

c59b80c8d3e46f176172d582f27c14d772e306fc is the first bad commit

comment:11 follow-up: Changed 5 years ago by Glinx

....do I need to do anything else?

comment:12 in reply to: ↑ 11 Changed 5 years ago by cehoyos

Replying to Glinx:

....do I need to do anything else?

Yes.
Please give me more than 24 hours to react in my free time to an issue that I cannot reproduce.

comment:13 Changed 5 years ago by michael

Where can i find a source file with which this issue has been confirmed to occur ?
i dont want to randomly pick a file and assume it might be within the set of affected input files ...
thanks

comment:14 Changed 5 years ago by Glinx

Hello Michael. Thank you for assisting.
Ive uploaded a couple of my smallest files to Dropbox.
http://dl.dropbox.com/u/10440533/00003.MTS 7.5mb
http://dl.dropbox.com/u/10440533/00002.MTS 44mb

comment:15 Changed 5 years ago by michael

You made a mistake during bisect, 4c386333529dd773e673e1366d1f6243d2c5af92 shows unsigned too
and it is a ancestor of c59b80c8d3e46f176172d582f27c14d772e306fc
Audio
ID : 1
Format : PCM
Format settings, Endianness : Big
Format settings, Sign : Unsigned
Codec ID : lpcm


Thus c59b80c8d3e46f176172d582f27c14d772e306fc is not the commit introducing the problem.

comment:16 Changed 5 years ago by michael

Regression since 8e8c51318c1fe4ae61de578f0823b88aa3fe8222
Author: Justin Ruggles <justin.ruggles@gmail.com>
Date: Fri Dec 2 15:51:52 2011 -0500

movenc: simplify handling of pcm vs. adpcm vs. other compressed codecs


Use Sound Sample Description Version 2 for all MOV files.
Updated FATE references accordingly.
Note that ADPCM is treated as compressed audio in version 2.

comment:17 Changed 5 years ago by Glinx

Thank you.
Todays Arch linux package update confirms all is well again.

comment:18 Changed 5 years ago by michael

  • Component changed from undetermined to avformat
  • Keywords mov muxer added
  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from new to closed

Thanks for confirming, issue closed

Note: See TracTickets for help on using tickets.