Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Audio not working #20

Open
mrglobal opened this issue Feb 9, 2014 · 20 comments
Open

Audio not working #20

mrglobal opened this issue Feb 9, 2014 · 20 comments

Comments

@mrglobal
Copy link

mrglobal commented Feb 9, 2014

Used your latest. Video works fine but Audio is scratchy and high pitched. Can you provide any guidance on this ?

Thanks

Sean

@mattip
Copy link

mattip commented Feb 15, 2014

Can you give more details? Which tutorial, using which movie, what platform?
tutorial06 and tutorial07 work fine for me...

@solarstrings
Copy link

Tutorial 07 sound is distorted on most video files downloaded from YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays distorted.

@mrglobal
Copy link
Author

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings notifications@github.comwrote:

Tutorial 07 sound is distorted on most video files downloaded from YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays distorted.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-35749622
.

@mpenkov
Copy link
Owner

mpenkov commented Feb 22, 2014

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays distorted.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-35787584
.

@mrglobal
Copy link
Author

mrglobal commented Mar 7, 2014

Sorry for delay in reply

04 on windows using MSVC2010 does not work for me (I just used the latest
code).

tut05 does not compile

Error 5 error C2440: '=' : cannot convert from 'int (__cdecl
*)(AVCodecContext *,AVFrame *)' to 'int (__cdecl *)(AVCodecContext
*,AVFrame *,int)' c:\users\seanyiu\ffmpeg\ffmpeg_tutorials\test5 -
copy\test5\test5.cpp 662 1 test5

Line is :
codecCtx->get_buffer2 = our_get_buffer;

get_buffer2 has 3 arguments to our_get_buffer's 2 arguments.

Be that as it may, I don't think 05 would work too (07 does not also).
Something more fundamental is happening here. Has any one gotten 04 or any
of the tutorials working on Windows ? What might be the problem ?

By the way, I use :

"#define rint ceil" as there is no rint in MSVC2010

Thanks

Sean

On Sat, Feb 22, 2014 at 1:46 AM, Michael Penkov notifications@github.comwrote:

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays distorted.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-35798939
.

@mpenkov
Copy link
Owner

mpenkov commented Mar 7, 2014

Which version of ffmeg are you using?
On Mar 7, 2014 10:49 AM, "mrglobal" notifications@github.com wrote:

Sorry for delay in reply

04 on windows using MSVC2010 does not work for me (I just used the latest
code).

tut05 does not compile

Error 5 error C2440: '=' : cannot convert from 'int (__cdecl
*)(AVCodecContext *,AVFrame *)' to 'int (__cdecl *)(AVCodecContext
*,AVFrame *,int)' c:\users\seanyiu\ffmpeg\ffmpeg_tutorials\test5 -
copy\test5\test5.cpp 662 1 test5

Line is :
codecCtx->get_buffer2 = our_get_buffer;

get_buffer2 has 3 arguments to our_get_buffer's 2 arguments.

Be that as it may, I don't think 05 would work too (07 does not also).
Something more fundamental is happening here. Has any one gotten 04 or any
of the tutorials working on Windows ? What might be the problem ?

By the way, I use :

"#define rint ceil" as there is no rint in MSVC2010

Thanks

Sean

On Sat, Feb 22, 2014 at 1:46 AM, Michael Penkov <notifications@github.com

wrote:

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <
notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays
distorted.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36960144
.

@mrglobal
Copy link
Author

mrglobal commented Mar 7, 2014

Zeranoe's

ffmpeg-20130706-git-63d7684-win32-dev

Sean

On Thu, Mar 6, 2014 at 6:33 PM, Michael Penkov notifications@github.comwrote:

Which version of ffmeg are you using?

On Mar 7, 2014 10:49 AM, "mrglobal" notifications@github.com wrote:

Sorry for delay in reply

04 on windows using MSVC2010 does not work for me (I just used the latest
code).

tut05 does not compile

Error 5 error C2440: '=' : cannot convert from 'int (__cdecl
*)(AVCodecContext *,AVFrame *)' to 'int (__cdecl *)(AVCodecContext
*,AVFrame *,int)' c:\users\seanyiu\ffmpeg\ffmpeg_tutorials\test5 -
copy\test5\test5.cpp 662 1 test5

Line is :
codecCtx->get_buffer2 = our_get_buffer;

get_buffer2 has 3 arguments to our_get_buffer's 2 arguments.

Be that as it may, I don't think 05 would work too (07 does not also).
Something more fundamental is happening here. Has any one gotten 04 or
any
of the tutorials working on Windows ? What might be the problem ?

By the way, I use :

"#define rint ceil" as there is no rint in MSVC2010

Thanks

Sean

On Sat, Feb 22, 2014 at 1:46 AM, Michael Penkov <
notifications@github.com

wrote:

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <
notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays
distorted.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36962444
.

@mpenkov
Copy link
Owner

mpenkov commented Mar 7, 2014

That looks a bit old. It could be a version compatibility issue. Could you
try a newer ffmpeg version? Alternatively, try an older version of the
tutorials.
On Mar 7, 2014 12:35 PM, "mrglobal" notifications@github.com wrote:

Zeranoe's

ffmpeg-20130706-git-63d7684-win32-dev

Sean

On Thu, Mar 6, 2014 at 6:33 PM, Michael Penkov <notifications@github.com

wrote:

Which version of ffmeg are you using?

On Mar 7, 2014 10:49 AM, "mrglobal" notifications@github.com wrote:

Sorry for delay in reply

04 on windows using MSVC2010 does not work for me (I just used the
latest
code).

tut05 does not compile

Error 5 error C2440: '=' : cannot convert from 'int (__cdecl
*)(AVCodecContext *,AVFrame *)' to 'int (__cdecl *)(AVCodecContext
*,AVFrame *,int)' c:\users\seanyiu\ffmpeg\ffmpeg_tutorials\test5 -
copy\test5\test5.cpp 662 1 test5

Line is :
codecCtx->get_buffer2 = our_get_buffer;

get_buffer2 has 3 arguments to our_get_buffer's 2 arguments.

Be that as it may, I don't think 05 would work too (07 does not also).
Something more fundamental is happening here. Has any one gotten 04 or
any
of the tutorials working on Windows ? What might be the problem ?

By the way, I use :

"#define rint ceil" as there is no rint in MSVC2010

Thanks

Sean

On Sat, Feb 22, 2014 at 1:46 AM, Michael Penkov <
notifications@github.com

wrote:

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com
wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <
notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded
from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays
distorted.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36965209
.

@edufelipe
Copy link

@mpenkov The issue is also happening here. All examples output a high pitched audio.

edufelipe$ ./test7 ~/video.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ' ~/video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2014-03-07 06:04:42
  Duration: 00:21:24.86, start: 0.000000, bitrate: 1050 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 720x404, 918 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2014-03-07 05:46:53
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2014-03-07 06:04:42

My ffmpeg:

ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar  2 2014 13:38:24 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100

@mrglobal
Copy link
Author

I had been using an earlier version of FFMPEG and kept moving to latest.
Granted it's a year dated now but I suspect it is in latest also.

Sean

On Thu, Mar 6, 2014 at 7:56 PM, Michael Penkov notifications@github.comwrote:

That looks a bit old. It could be a version compatibility issue. Could you
try a newer ffmpeg version? Alternatively, try an older version of the
tutorials.

On Mar 7, 2014 12:35 PM, "mrglobal" notifications@github.com wrote:

Zeranoe's

ffmpeg-20130706-git-63d7684-win32-dev

Sean

On Thu, Mar 6, 2014 at 6:33 PM, Michael Penkov <notifications@github.com

wrote:

Which version of ffmeg are you using?

On Mar 7, 2014 10:49 AM, "mrglobal" notifications@github.com wrote:

Sorry for delay in reply

04 on windows using MSVC2010 does not work for me (I just used the
latest
code).

tut05 does not compile

Error 5 error C2440: '=' : cannot convert from 'int (__cdecl
*)(AVCodecContext *,AVFrame *)' to 'int (__cdecl *)(AVCodecContext
*,AVFrame *,int)' c:\users\seanyiu\ffmpeg\ffmpeg_tutorials\test5 -
copy\test5\test5.cpp 662 1 test5

Line is :
codecCtx->get_buffer2 = our_get_buffer;

get_buffer2 has 3 arguments to our_get_buffer's 2 arguments.

Be that as it may, I don't think 05 would work too (07 does not
also).
Something more fundamental is happening here. Has any one gotten 04
or
any
of the tutorials working on Windows ? What might be the problem ?

By the way, I use :

"#define rint ceil" as there is no rint in MSVC2010

Thanks

Sean

On Sat, Feb 22, 2014 at 1:46 AM, Michael Penkov <
notifications@github.com

wrote:

What about tutorials 5 and 6? Do they work?

On 22 February 2014 09:19, mrglobal notifications@github.com
wrote:

Same for me for Tutorial 07 and 04.

Sean

On Fri, Feb 21, 2014 at 8:56 AM, solarstrings <
notifications@github.com

wrote:

Tutorial 07 sound is distorted on most video files downloaded
from
YouTube.
Those encoded with mp3 audio seems to work though.

The sound plays ok in linux, but in Windows the sound plays
distorted.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<

#20 (comment)

.

Reply to this email directly or view it on GitHub<
#20 (comment)

.

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36966048
.

@mpenkov
Copy link
Owner

mpenkov commented Mar 11, 2014

@edufelipe Can you provide a sample video that people can use to reproduce this behavior?

@anarsoul
Copy link

anarsoul commented Jun 5, 2014

I've debugged it a bit, and it looks like only stereo audio is affected. For some reason avcoded_decode_audio4() puts garbage in 2nd half of the buffer for files with stereo audio.

Use this youtube video (download it with youtube-dl) as a sample: https://www.youtube.com/watch?v=FKJXtXvl-HQ

@anarsoul
Copy link

anarsoul commented Jun 5, 2014

On 2nd thought it looks like smaller buffer is allocated somewhere in ffmpeg internals for frame->data[0]. Insert a memset(frame.data[0], 0, data_size) after memcpy() in audio_decode_frame() and you'll get a segfault.

@anarsoul
Copy link

anarsoul commented Jun 6, 2014

Got it: code can't deal neither with planar audio formats nor with sample format mismatch.

@Aman5692
Copy link

@chelyaev i got the same high pitch problem. @edufelipe was your problem solved?

my output is :

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/hemant/Videos/Burn.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2014-11-28 15:25:11
Duration: 00:03:58.12, start: 0.000000, bitrate: 1589 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 1395 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, fltp, 191 kb/s
Metadata:
creation_time : 2014-11-28 15:25:13

my ffmpeg version is :

ffmpeg version 2.6.3 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100

@fugokidi
Copy link

@Aman5692, have you resolved the audio problem? I've the same problem with the audio.

My ffmpeg version is:

ffmpeg version N-73365-g72cad80 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
configuration: --enable-libmp3lame --enable-shared --disable-mmx --enable-libfaac --enable-nonfree --enable-demuxer=mov
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 46.100 / 56. 46.100
libavformat 56. 40.100 / 56. 40.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 19.100 / 5. 19.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100

@anarsoul
Copy link

@fugokidi
Copy link

@anarsoul Thank you very much. I shall go through yours.
Well, your library is a little bit big for me. I'm still in tutorial03. My goal is I'm trying to understand synchronisation part practically in details. I'm stuck at tutorial03 for now.

I tried @pprahul (his fix) is to change sample format.

if (aCodecCtx->sample_fmt == AV_SAMPLE_FMT_S16P) {
        aCodecCtx->request_sample_fmt = AV_SAMPLE_FMT_S16;
    }

It works for mp2 audio even though it is stereo channel.
But it doesn't work for aac audio, it's giving me the sound like radio tuning.

@anarsoul Can you please guide me a bit of how I can fix tutorial03 to work with h264+aac in mp4 container?

@MilaCridlig
Copy link

Was able to play a mp4 video with audio whose codecs appear below. Based on http://dranger.com/ffmpeg/ and updates from https://github.com/illuusio/ffmpeg-tutorial, it runs Windows x64, Visual Studio 2015, SDL2, ffmpeg 4.0 and C++.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘crawl.mp4’:
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
Duration: 00:00:29.00, start: 0.000000, bitrate: 689 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1344x680, 612 kb/s, 10 fps, 10 tbr, 10 tbn, 20 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 75 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
screen final size: 1344x680

@mattip
Copy link

mattip commented Jul 10, 2018

@MilaCridlig it seems that is expected since you used mono audio. From this comment above it is related to stereo audio

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants