Opened 20 months ago

Last modified 19 months ago

#8352 new defect

error when encoding dv @ 32kHz

Reported by: dave rice Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: dvvideo
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

DV25 supports audio at 48, 44.1 and 32 kHz, but when I use 44100 or 32000 I get an error.

How to reproduce:

ffmpeg -y -f lavfi -i mandelbrot=r=30000/1001:s=720x480 -f lavfi -i sine -map 0 -map 1 -pix_fmt yuv411p -c:v dvvideo -aspect 4/3  -t 3 -ac 2 -ar 32000 ntsc_4-3_2ch_32k_mandelbrot_sine.dv
ffmpeg version git-2019-10-22-ec5d385 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-ec5d385_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 35.101 / 56. 35.101
  libavcodec     58. 59.102 / 58. 59.102
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 64.100 /  7. 64.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'mandelbrot=r=30000/1001:s=720x480':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[0] / 0x424752), rgb0, 720x480 [SAR 1:1 DAR 3:2], 29.97 tbr, 29.97 tbn, 29.97 tbc
Input #1, lavfi, from 'sine':
  Duration: N/A, start: 0.000000, bitrate: 705 kb/s
    Stream #1:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> dvvideo (native))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[dv @ 0x7fea9a802400] Can't initialize DV format!
Make sure that you supply exactly two streams:
     video: 25fps or 29.97fps, audio: 2ch/48|44|32kHz/PCM
     (50Mbps allows an optional second audio stream)
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Error initializing output stream 0:1 -- 
Conversion failed!

I've reviewed dvenc.c but am uncertain if I'm doing something wrong. If I switch from -ar 32000 to -ar 48000, then it works as expected.

Change History (7)

comment:1 by richardpl, 20 months ago

Because your channel layout is mono.

comment:2 by dave rice, 20 months ago

I tried with a stereo source and -channel_layout stereo but same error:

ffmpeg -y -f lavfi -i mandelbrot=r=30000/1001:s=720x480 -f lavfi -i aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t):c=stereo" -map 0 -map 1 -pix_fmt yuv411p -c:v dvvideo -aspect 4/3  -t 3 -ac 2 -channel_layout stereo -ar 32000 ntsc_4-3_2ch_32k_mandelbrot_sine.dv
ffmpeg version git-2019-10-22-ec5d385 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-ec5d385_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 35.101 / 56. 35.101
  libavcodec     58. 59.102 / 58. 59.102
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 64.100 /  7. 64.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'mandelbrot=r=30000/1001:s=720x480':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[0] / 0x424752), rgb0, 720x480 [SAR 1:1 DAR 3:2], 29.97 tbr, 29.97 tbn, 29.97 tbc
Input #1, lavfi, from 'aevalsrc=0.1*sin(2*PI*(360-2.5/2)*t) | 0.1*sin(2*PI*(360+2.5/2)*t):c=stereo':
  Duration: N/A, start: 0.000000, bitrate: 5644 kb/s
    Stream #1:0: Audio: pcm_f64le, 44100 Hz, stereo, dbl, 5644 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> dvvideo (native))
  Stream #1:0 -> #0:1 (pcm_f64le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[dv @ 0x7fab2301c000] Can't initialize DV format!
Make sure that you supply exactly two streams:
     video: 25fps or 29.97fps, audio: 2ch/48|44|32kHz/PCM
     (50Mbps allows an optional second audio stream)
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Error initializing output stream 0:1 -- 
Conversion failed!

comment:3 by richardpl, 20 months ago

48000 sample rate works only with that profile you set.
32000 works only with another frame rate / time base and video size.
Look at libavcodec/dv_profile.c

comment:4 by dave rice, 20 months ago

I am trying to use the profile described in https://github.com/FFmpeg/FFmpeg/blob/a0ac49e38ee1d1011c394d7be67d0f08b2281526/libavcodec/dv_profile.c#L74-L90. The comment notes support for 32kHz with 720x480 30000/10001 4:1:1 video so I'm uncertain how I'm not using this profile.

comment:5 by richardpl, 20 months ago

Because timebase is not 1/25 or 1/50, and in that case only 48khz works.
You could remove relevant line that checks timebase and try if decoder can decode output.

comment:6 by dave rice, 19 months ago

32000 Hz is allowed with 30000/1001 dv. There is a sample like this at http://samples.ffmpeg.org/archive/container/dv/dv+dvvideo+pcm_s16le++imovie_dv_file_with_dup_audio_streams_segfaults_libfaac.dv. There a table on the last page of http://web.archive.org/web/20060927044735/http://www.smpte.org/smpte_store/standards/pdf/s314m.pdf that summarizes the options for dv defined by smpte 314m and iec 61834.

comment:7 by richardpl, 19 months ago

Than change code, test it, and send patch.

Note: See TracTickets for help on using tickets.