leandromoreira / ffmpeg-libav-tutorial

FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more. Translations: πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡³ πŸ‡°πŸ‡· πŸ‡ͺπŸ‡Έ πŸ‡»πŸ‡³ πŸ‡§πŸ‡·
https://github.com/leandromoreira/ffmpeg-libav-tutorial
BSD 3-Clause "New" or "Revised" License
9.78k stars 937 forks source link

error in transcoding audio from mp3 to aac #123

Open EdsionYeh opened 1 year ago

EdsionYeh commented 1 year ago

I tried 3_transcoding.c to transcode audio.

  StreamingParams sp = {0};
  sp.copy_audio = 0;
  sp.copy_video = 0;
  sp.video_codec = "libx264";
  sp.codec_priv_key = "x264-params";
  sp.codec_priv_value = "keyint=60:min-keyint=60:scenecut=0:force-cfr=1";
  sp.audio_codec = "aac";

The format of the input video file is as below.

  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1280x720, 1718 kb/s, 30.20 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

when transcoding from mp3 to aac, I got the error msg

[aac @ 0x55e811fab600] nb_samples (1152) > frame_size (1024)
leandromoreira commented 1 year ago

@EdsionYeh the msg you're posting as an error message seems to be a warn only, what was the output?

EdsionYeh commented 1 year ago

with

  sp.copy_video = 1;

I got a bunch of such msgs and then Segmentation fault

[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
[aac @ 0x5633867f8a80] nb_samples (1152) > frame_size (1024)
Segmentation fault

The output file size looks reasonable, but it is not playable, It is very likely that av_write_trailer didn't get a chance to be called.

with

  sp.copy_video = 0;

I got

[aac @ 0x561f16315600] nb_samples (1152) > frame_size (1024)
[aac @ 0x561f16315600] nb_samples (1152) > frame_size (1024)
[aac @ 0x561f16315600] nb_samples (1152) > frame_size (1024)
[mp4 @ 0x561f15f32280] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 512 >= 0
LOG: Error -22 while receiving packet from decoder: Invalid argument

The output video file is only 48 bytes in size