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

No Audio Upon Export? #1075

Closed
JamesClark1991 opened this issue Mar 15, 2022 · 12 comments
Closed

No Audio Upon Export? #1075

JamesClark1991 opened this issue Mar 15, 2022 · 12 comments

Comments

@JamesClark1991
Copy link

When exporting Sony A7C 4K video there is no sync audio on the MP4 file upon export. However if I choose to render the audio track seperately as a standalone file it works fine. There is audio playback within the app itself when trimming.

Note: states unsupported file type on import but claims to have full audio on export which it doesn't?

https://imgur.com/a/nwd7GAb

MACOS 12.1 (M1 Pro)

@JamesClark1991
Copy link
Author

Note: Keeping everything the same but exporting as .MKV retains the audio within the file, but this option is no good for my workflow :-(

@mifi
Copy link
Owner

mifi commented Mar 15, 2022

hi. would be nice if you could add a report from the help menu. i assume you cannot share a file that can reproduce the problem

@mifi
Copy link
Owner

mifi commented Mar 15, 2022

and I assumed you tried the suggestions like changing to .mov

@JamesClark1991
Copy link
Author

hi. would be nice if you could add a report from the help menu. i assume you cannot share a file that can reproduce the problem

I've sent a report on the original video file I was using with this issue. I've also sent another report using a different video file from the same camera with the same issue.

Here's a link to an unmodified video file with the issue - https://www.dropbox.com/s/hwchic8gx2dreci/20220223_C0131.MP4?dl=0

@JamesClark1991
Copy link
Author

JamesClark1991 commented Mar 15, 2022

and I assumed you tried the suggestions like changing to .mov

Correct, .mov was my first export choice (detected) and that's the file export that contains no sync audio.

@mifi
Copy link
Owner

mifi commented Mar 15, 2022

thanks.

I've sent a report on the original video file I was using with this issue. I've also sent another report using a different video file from the same camera with the same issue.

Oh, I didn't receive any. which email did you send to?

@JamesClark1991
Copy link
Author

thanks.

I've sent a report on the original video file I was using with this issue. I've also sent another report using a different video file from the same camera with the same issue.

Oh, I didn't receive any. which email did you send to?

Oops! my bad here is the report using the Dropbox linked file above:

No error

{
"state": {
"filePath": "/Users/jamesmacbookpro14/Dropbox/Videos/VIDEO TEMP/LosslessCut Test/20220223_C0131.MP4",
"fileFormat": "mov",
"mainStreams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 3840,
"height": 2160,
"coded_width": 3840,
"coded_height": 2160,
"closed_captions": 0,
"has_b_frames": 1,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuv420p",
"level": 51,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "25/1",
"avg_frame_rate": "25/1",
"time_base": "1/25000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 492000,
"duration": "19.680000",
"bit_rate": "96231705",
"bits_per_raw_sample": "8",
"nb_frames": "492",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2022-02-23T17:42:16.000000Z",
"language": "und",
"handler_name": "Video Media Handler",
"vendor_id": "[0][0][0][0]",
"encoder": "AVC Coding"
}
},
{
"index": 1,
"codec_name": "pcm_s16be",
"codec_long_name": "PCM signed 16-bit big-endian",
"codec_type": "audio",
"codec_tag_string": "twos",
"codec_tag": "0x736f7774",
"sample_fmt": "s16",
"sample_rate": "48000",
"channels": 2,
"bits_per_sample": 16,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 944640,
"duration": "19.680000",
"bit_rate": "1536000",
"nb_frames": "944640",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2022-02-23T17:42:16.000000Z",
"language": "und",
"handler_name": "Sound Media Handler",
"vendor_id": "[0][0][0][0]"
}
},
{
"index": 2,
"codec_type": "data",
"codec_tag_string": "rtmd",
"codec_tag": "0x646d7472",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/25000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 492000,
"duration": "19.680000",
"bit_rate": "1024000",
"nb_frames": "492",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2022-02-23T17:42:16.000000Z",
"language": "und",
"handler_name": "Timed Metadata Media Handler",
"timecode": "02:12:31:05"
}
}
],
"copyStreamIdsByFile": {
"/Users/jamesmacbookpro14/Dropbox/Videos/VIDEO TEMP/LosslessCut Test/20220223_C0131.MP4": {
"0": true,
"1": true,
"2": false
}
},
"cutSegments": [
{}
],
"mainFileFormatData": {
"filename": "/Users/jamesmacbookpro14/Dropbox/Videos/VIDEO TEMP/LosslessCut Test/20220223_C0131.MP4",
"nb_streams": 3,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "19.680000",
"size": "243278885",
"bit_rate": "98893855",
"probe_score": 100,
"tags": {
"major_brand": "XAVC",
"minor_version": "16785407",
"compatible_brands": "XAVCmp42iso2",
"creation_time": "2022-02-23T17:42:16.000000Z"
}
},
"rotation": 360,
"shortestFlag": false
},
"platform": "darwin",
"version": "3.44.0"
}

@mifi
Copy link
Owner

mifi commented Mar 17, 2022

Thanks!
I was able to reproduce the problem. Actually the audio is still there in the output file, but Apple software like Preview and Quicktime cannot play it back. VLC can however.
Seems like something is wrong with the way ffmpeg is re-packaging the pcm_s16be audio stream into the output MOV.

MediaInfo shows:

Format                                   : PCM
Format settings                          : Big / Signed
Codec ID                                 : twos
Duration                                 : 19 s 680 ms
Bit rate mode                            : Constant
Bit rate                                 : 1 536 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits

and quicktime: Linear PCM, 16 bit big-endian signed integer, 48000 Hz
So pcm_s16be seems to be correct.

I found something similar: https://ffmpeg-user.ffmpeg.narkive.com/spzNH1AL/ffmpeg-detects-audio-as-pcm-s16be-but-it-seems-to-be-32bit
But that one is quite old and I don't think it's the same problem, because your file is indeed 16 bit.

Interestingly I tried this, to re-encode the audio:

ffmpeg -hide_banner -i 20220223_C0131.MP4 -map 0:0 -c:v copy -map 0:1 -c:a pcm_s16be out.mov
# outputs:
# Stream #0:1: Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, stereo, s16, 1536 kb/s (default)

Output file audio is still not playable.

Then I tried pcm_s32be:

ffmpeg -hide_banner -i 20220223_C0131.MP4 -map 0:0 -c:v copy -map 0:1 -c:a pcm_s32be out.mov
# outputs:
# Stream #0:1: Audio: pcm_s32be (in32 / 0x32336E69), 48000 Hz, stereo, s32, 3072 kb/s (default)

Notice audio tag changed to in32.

Output file audio is now playable!

Also tested:

  • pcm_s16le, pcm_s8 does not work
  • pcm_s24be, pcm_s24be works

This leads me to believe there is some bug in ffmpeg that it cannot copy this stream type into MOV correctly.

I think a workaround could be to always encode pcm_s16be to pcm_s32be (or pcm_s24be, lower size) when the target is MOV, because pcm is already lossless so it theoretically won't give any loss in quality even though a "re-encode" is involved.

@mifi
Copy link
Owner

mifi commented Mar 17, 2022

I just tested this in losslesscut too and it seems to work, also with cutting, so I think we can go with that.

@JamesClark1991
Copy link
Author

I just tested this in losslesscut too and it seems to work, also with cutting, so I think we can go with that.

Pardon my ignorance as I am but a mere peasent... but in lamens terms does that mean LosslessCut will be getting a software update to fix this? Or do I need to change a setting on my end?

Cheers :-)

@mifi
Copy link
Owner

mifi commented Mar 18, 2022

Ok this is getting stranger. I did some more testing, and it seems that re-encoding the pcm audio is not really necessary.

I found out that renaming the .mp4 output file to .mov makes the audio re-appear in quicklook/quicktime!

So it seems like there is some strange logic somewhere in Apple QuickLook/QuickTime that checks only the file's extension. If the extension is .mp4 it will only play the video, but no audio, but the exact same file instead with the extension .mov will also play the audio!

So a workaround for you should be to simply rename the output file to .mov
I'm thinking about how to best solve this.

@mifi
Copy link
Owner

mifi commented Sep 3, 2024

So it seems like there is some strange logic somewhere in Apple QuickLook/QuickTime that checks only the file's extension. If the extension is .mp4 it will only play the video, but no audio, but the exact same file instead with the extension .mov will also play the audio!

I have a report which kind of is the opposite of this problem:

Someone trying to cut a RAW .mp4 file (from a Sony a6400 camera) and then export it as an .mp4, but ffmpeg cannot mux pcm into mp4 (only mov), so losslesscut auto suggests mov (as expected). Premiere Pro cannot seem open files with the .mov extension for this person.

When the person kept the mov export format but removed the ${EXT} from the template and added '.mp4' and that seems to have worked (the file successfully imports into Premiere Pro.)

video:

  • codec h264
  • codec_tag_string avc1
  • codec_tag 0x31637661

audio:

  • codec pcm_s16be
  • codec_tag_string twos
  • codec_tag: 0x736f7774

mifi added a commit that referenced this issue Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants