aws-samples / amazon-chime-sdk-recording-demo

Apache License 2.0
95 stars 65 forks source link

Corrupted mp4 recording #70

Closed TrierHealth closed 3 years ago

TrierHealth commented 3 years ago

Sometimes the recorded file is corrupted. We get the below message when tried to play the mp4

Choose something else to play. This item is in a format we don't support.

Is there any specific setting required other than the default code in the repo ?

Thanks, Ravi V.

TrierHealth commented 3 years ago

HI @anuranduttaroy, would you be able to help us? We have the below setting for Audio recording. When the mp4 files are downloaded, sometimes they come out well, sometimes they are corrupted. Please help.

const transcodeStreamToOutput = spawn('ffmpeg',[
    // '-hide_banner',
    '-loglevel', 'error',
    // disable interaction via stdin
    '-nostdin',
    // screen image size
    // '-s', `${BROWSER_SCREEN_WIDTH}x${BROWSER_SCREEN_HEIGHT}`,
    // video frame rate
    // '-r', `${VIDEO_FRAMERATE}`,
    // hides the mouse cursor from the resulting video
    // '-draw_mouse', '0',
    // grab the x11 display as video input
    // '-f', 'x11grab',
        // '-i', `${DISPLAY}`,
    // grab pulse as audio input
    '-f', 'pulse', 
        '-ac', '2',
        '-i', 'default',
    // codec video with libx264
    // '-c:v', 'libx264',
    //     '-pix_fmt', 'yuv420p',
    //     '-profile:v', 'main',
    //     '-preset', 'veryfast',
    //     '-x264opts', 'nal-hrd=cbr:no-scenecut',
    //     '-minrate', `${VIDEO_BITRATE}`,
    //     '-maxrate', `${VIDEO_BITRATE}`,
    //     '-g', `${VIDEO_GOP}`,
    // apply a fixed delay to the audio stream in order to synchronize it with the video stream
    // '-filter_complex', 'adelay=delays=1000|1000',
    // '-vn',
    // codec audio with aac
    '-c:a', 'aac',
        '-b:a', `${AUDIO_BITRATE}`,
        '-ac', `${AUDIO_CHANNELS}`,
        '-ar', `${AUDIO_SAMPLERATE}`,
    // adjust fragmentation to prevent seeking(resolve issue: muxer does not support non seekable output)
    '-movflags', 'frag_keyframe+empty_moov',
    // set output format to mp4 and output file to stdout
    '-f', 'mp4', '-'
    ]
);

Thanks, Ravi V.

TrierHealth commented 3 years ago

@ziyiz-amzn would you be able to help to understand and resolve why sometimes the recorded file in s3 is corrupted.

TrierHealth commented 3 years ago

As the issue is only when doing audio recording, for now fixed this by updating mp4 with wav as we only need audio recording. However, as the file size is heavy, this needs to be handled in a different way.