Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recorded file's duration is zero [m4a format, aacLc] #253

Closed
arreshashikant opened this issue Dec 8, 2023 · 21 comments
Closed

Recorded file's duration is zero [m4a format, aacLc] #253

arreshashikant opened this issue Dec 8, 2023 · 21 comments
Labels

Comments

@arreshashikant
Copy link

Package version
record: ^5.0.1

Environment

  • OS: Android 10, Redmi Note 8

Describe the bug

Recording works fine. But, when we try to get the duration of recorded file (either through ffmpeg or audioplayers plugin), it returns Zero Duration.

RecordConfig - Default

  const RecordConfig({
    this.encoder = AudioEncoder.aacLc,
    this.bitRate = 128000,
    this.sampleRate = 44100,
    this.numChannels = 2,
    this.device,
    this.autoGain = false,
    this.echoCancel = false,
    this.noiseSuppress = false,
  });

To Reproduce

Steps to reproduce the behavior:
Sample repository -
https://github.com/arreshashikant/buggy_repo/tree/recordDurationZero
branch - recordDurationZero

Expected behavior
Return valid duration of the recorded file

Additional context
The recorded bytes returns valid duration if we start recording with startStream

@Hatemsla
Copy link

Same problem

@arsyad-revo
Copy link

I'm having the same issue too...
hopefully, it can be fixed soon...

@llfbandit llfbandit added bug Something isn't working Android labels Dec 14, 2023
@llfbandit
Copy link
Owner

llfbandit commented Dec 14, 2023

Released in record_android 1.0.4.
Sorry, this issue was closed for no reason...

@Evgentret
Copy link

Still have a problem with zero record duration, record_android 1.04

@llfbandit
Copy link
Owner

llfbandit commented Dec 20, 2023

This issue is very unclear to me. I don't reproduce any issue with the duration.
@arreshashikant Your reproducer is wrongly set, this is not how audioplayers works. You must rely on streams to get your info.

I updated the example in the repository to show the audio duration before playing it.

If other participants have more or other info to share, it is time before I close this.

@arreshashikant
Copy link
Author

I agree that we should rely on streams to get duration. But,
There's no issue with player when AudioPlayer.getDuration() call is made after setSource future is complete.

@llfbandit llfbandit removed the bug Something isn't working label Dec 21, 2023
@Evgentret
Copy link

Evgentret commented Jan 2, 2024

This issue is very unclear to me. I don't reproduce any issue with the duration. @arreshashikant Your reproducer is wrongly set, this is not how audioplayers works. You must rely on streams to get your info.

I updated the example in the repository to show the audio duration before playing it.

If other participants have more or other info to share, it is time before I close this.

When compile and build your example I've got duration 00:00:00.023 on Android real device in any way.
But when I run this example on iPhone - duration is correct.
Also, all audio recorded using iPhone had correct duration when playing in Android and all audio recorded in Android has near-the-zero duration in iPhone.
Another example, when I send recorded audio by your example to the Telegram, if audio from iPhone - it has correct duration, when I send recorded audio from Android - duration showed zero.

Flutter (Channel stable, 3.16.5, on macOS 13.6.1 22G313 darwin-x64)

Problem only with codecs aacLc, aacEld, aacHe
Opus on Android work well

Plugin output:

I/MediaCodec(11566): Codec shutdown complete
W/MPEG4Writer(11566): 0-duration samples found: 117
I/MPEG4Writer(11566): Received total/0-length (118/0) buffers and encoded 118 frames. - Audio
I/MPEG4Writer(11566): Audio track drift time: 0 us
I/MPEG4Writer(11566): Normal stop process
D/MPEG4Writer(11566): Audio track stopping. Stop source
D/MPEG4Writer(11566): Audio track source stopping
D/MPEG4Writer(11566): Audio track source stopped
D/MPEG4Writer(11566): Audio track stopped. Stop source
D/MPEG4Writer(11566): Stopping writer thread
D/MPEG4Writer(11566): 0 chunks are written in the last batch
D/MPEG4Writer(11566): Writer thread stopped
I/MPEG4Writer(11566): The mp4 file will not be streamable.
D/MPEG4Writer(11566): Audio track stopping. Stop source

@Allenxuxu
Copy link

I have the same issue.

@utkudenis
Copy link

We had similar issue with player new version 5.0.x
everyting is perfect 4.4.4
however, when we updated to 5.0.x there was unstable problem. although records can listen on the recorded phone. they were not working other devices.
An Example, recorder settings screenshot
image

We used ai to compare working and notworking voice record.
image

The problem was on the bitrate.

Summary, records on the android was problematic.
file extension was .m4a

@blok5025
Copy link

We had similar issue with player new version 5.0.x everyting is perfect 4.4.4 however, when we updated to 5.0.x there was unstable problem. although records can listen on the recorded phone. they were not working other devices. An Example, recorder settings screenshot image

We used ai to compare working and notworking voice record. image

The problem was on the bitrate.

Summary, records on the android was problematic. file extension was .m4a

Did you find a Solution?

I have an issue where files recorded on Android don't have an extension but can be listened on the device it was recorded but not on iOS

@utkudenis
Copy link

We had similar issue with player new version 5.0.x everyting is perfect 4.4.4 however, when we updated to 5.0.x there was unstable problem. although records can listen on the recorded phone. they were not working other devices. An Example, recorder settings screenshot image
We used ai to compare working and notworking voice record. image
The problem was on the bitrate.
Summary, records on the android was problematic. file extension was .m4a

Did you find a Solution?

I have an issue where files recorded on Android don't have an extension but can be listened on the device it was recorded but not on iOS

version 4.4.4.

@blok5025
Copy link

@llfbandit This is a major issue as it's linked to the default settings of the RecordConfig(). Android files are corrupted and unreadable from the backend.

@llfbandit
Copy link
Owner

llfbandit commented Feb 20, 2024

I can't reproduce this issue with the two devices I own.

Here's what I get when using default settings.
This is perfectly fine (at least it seems).

Format                      : MPEG-4
Format profile              : Base Media / Version 2
Codec ID                    : mp42 (isom/mp42)
File size                   : 54.3 KiB
Duration                    : 3 s 251 ms
Overall bit rate mode       : Constant
Overall bit rate            : 137 kb/s
Encoded date                : 2024-02-20 17:28:29 UTC
Tagged date                 : 2024-02-20 17:28:29 UTC
com.android.version         : 14

Audio
ID                          : 1
Format                      : AAC LC
Format/Info                 : Advanced Audio Codec Low Complexity
Codec ID                    : mp4a-40-2
Duration                    : 3 s 251 ms
Source duration             : 3 s 274 ms
Bit rate mode               : Constant
Bit rate                    : 128 kb/s
Channel(s)                  : 2 channels
Channel layout              : L R
Sampling rate               : 44.1 kHz

Can someone send me audio files for comparison?

@blok5025
Copy link

blok5025 commented Feb 20, 2024

@llfbandit

The Android file get recognized as a Video file. Perhaps that's why it's unreadable with an audio decoder

Try using the android Emulator to reproduce the issue.

@llfbandit
Copy link
Owner

Please, send me the files.

@blok5025
Copy link

To whomever is using this package and audioplayers while fetching data from Firebase Storage. I was able to fix this issue in ^5.0.4 by passing the metadata manually with the file because, for some unknown reason, Firebase is not able to understand the file format of the Android Encoded file and without a File extension, the files are unreadable on iOS. (See Troubleshoot)

@Shawn-sudo
Copy link

@llfbandit I have an example file here:
https://drive.google.com/file/d/1Upa2y9py4yeOgzehWXl1jzCZa0gu9pkV/view?usp=sharing

  • On Google Drive, you'll be able to play it, but the seek bar doesn't behave well
    • I noticed the exact same behavior on my Android S9
  • If you download the file on a macBook, you won't be able to play it
    • Same thing happens on my iPhone

@llfbandit
Copy link
Owner

Could someone test with current code of record_android on git?

@shichunlei
Copy link

I still have this problem in record: ^5.1.0. How did you solve it?

@utkudenis
Copy link

Hi everyone,
I'm still using record 4.4.4 because of the problem on this issue.

Is there any garantee for the 5.1.1

Because of the recording our app main feature, I cannot get risk to update package version.
However, I need to update record with new flutter version requirement and dependencies

@utkudenis
Copy link

@Shawn-sudo , @shichunlei , @llfbandit and @blok5025 can you share how is going on last version of the record package 5.1.2 ?
i need to update my package 4.4.4 to 5.1.2

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

No branches or pull requests

10 participants