Command of FFMPEG to make a video from Image(JPEG) + Audio(.mp3) & Share video in Whatsapp












2















I am trying to create a video .mp4 file from .mp3 audio & .jpeg image.



I am able to create a video and able to play it in video players on Android devices.



But after creation of file when I tried to share that video in WhatsApp, at that time it shows a message "The file format not supported".



I am using below FFMPEG command:



"-loop 1 -r 1 -i " + imageFilePath + " -i " + audioFilePath + " -c:v libx264 -crf 27 -tune stillimage -c:a copy -pix_fmt yuv420p -preset ultrafast -shortest " + pathOutputVideo(sectionName);


And for sharing video, I am using code listed below:



  MediaScannerConnection.scanFile(ShareQuestionAudioActivity.this, new String{FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))));
startActivity(Intent.createChooser(shareIntent, "Share Question"));
}
});


I found here that I need to use H.264 + AAC. But I'm still not able to share video with supported file format.










share|improve this question

























  • what you used to convert images to Video?

    – Android User
    Nov 22 '18 at 5:37













  • I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

    – Neel Mevada
    Nov 22 '18 at 6:20













  • @NeelMevada can you share the mp4 file you created?

    – incBrain
    Nov 23 '18 at 2:59











  • @NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

    – incBrain
    Nov 23 '18 at 3:02






  • 1





    @incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

    – Neel Mevada
    Dec 3 '18 at 10:44
















2















I am trying to create a video .mp4 file from .mp3 audio & .jpeg image.



I am able to create a video and able to play it in video players on Android devices.



But after creation of file when I tried to share that video in WhatsApp, at that time it shows a message "The file format not supported".



I am using below FFMPEG command:



"-loop 1 -r 1 -i " + imageFilePath + " -i " + audioFilePath + " -c:v libx264 -crf 27 -tune stillimage -c:a copy -pix_fmt yuv420p -preset ultrafast -shortest " + pathOutputVideo(sectionName);


And for sharing video, I am using code listed below:



  MediaScannerConnection.scanFile(ShareQuestionAudioActivity.this, new String{FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))));
startActivity(Intent.createChooser(shareIntent, "Share Question"));
}
});


I found here that I need to use H.264 + AAC. But I'm still not able to share video with supported file format.










share|improve this question

























  • what you used to convert images to Video?

    – Android User
    Nov 22 '18 at 5:37













  • I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

    – Neel Mevada
    Nov 22 '18 at 6:20













  • @NeelMevada can you share the mp4 file you created?

    – incBrain
    Nov 23 '18 at 2:59











  • @NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

    – incBrain
    Nov 23 '18 at 3:02






  • 1





    @incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

    – Neel Mevada
    Dec 3 '18 at 10:44














2












2








2








I am trying to create a video .mp4 file from .mp3 audio & .jpeg image.



I am able to create a video and able to play it in video players on Android devices.



But after creation of file when I tried to share that video in WhatsApp, at that time it shows a message "The file format not supported".



I am using below FFMPEG command:



"-loop 1 -r 1 -i " + imageFilePath + " -i " + audioFilePath + " -c:v libx264 -crf 27 -tune stillimage -c:a copy -pix_fmt yuv420p -preset ultrafast -shortest " + pathOutputVideo(sectionName);


And for sharing video, I am using code listed below:



  MediaScannerConnection.scanFile(ShareQuestionAudioActivity.this, new String{FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))));
startActivity(Intent.createChooser(shareIntent, "Share Question"));
}
});


I found here that I need to use H.264 + AAC. But I'm still not able to share video with supported file format.










share|improve this question
















I am trying to create a video .mp4 file from .mp3 audio & .jpeg image.



I am able to create a video and able to play it in video players on Android devices.



But after creation of file when I tried to share that video in WhatsApp, at that time it shows a message "The file format not supported".



I am using below FFMPEG command:



"-loop 1 -r 1 -i " + imageFilePath + " -i " + audioFilePath + " -c:v libx264 -crf 27 -tune stillimage -c:a copy -pix_fmt yuv420p -preset ultrafast -shortest " + pathOutputVideo(sectionName);


And for sharing video, I am using code listed below:



  MediaScannerConnection.scanFile(ShareQuestionAudioActivity.this, new String{FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("video/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FfmpegController.pathOutputVideo(qModel.getSectionName().toUpperCase().replaceAll(" ", "_"))));
startActivity(Intent.createChooser(shareIntent, "Share Question"));
}
});


I found here that I need to use H.264 + AAC. But I'm still not able to share video with supported file format.







android video android-ffmpeg






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 6:50









incBrain

2,25931125




2,25931125










asked Nov 22 '18 at 4:50









Neel MevadaNeel Mevada

223




223













  • what you used to convert images to Video?

    – Android User
    Nov 22 '18 at 5:37













  • I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

    – Neel Mevada
    Nov 22 '18 at 6:20













  • @NeelMevada can you share the mp4 file you created?

    – incBrain
    Nov 23 '18 at 2:59











  • @NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

    – incBrain
    Nov 23 '18 at 3:02






  • 1





    @incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

    – Neel Mevada
    Dec 3 '18 at 10:44



















  • what you used to convert images to Video?

    – Android User
    Nov 22 '18 at 5:37













  • I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

    – Neel Mevada
    Nov 22 '18 at 6:20













  • @NeelMevada can you share the mp4 file you created?

    – incBrain
    Nov 23 '18 at 2:59











  • @NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

    – incBrain
    Nov 23 '18 at 3:02






  • 1





    @incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

    – Neel Mevada
    Dec 3 '18 at 10:44

















what you used to convert images to Video?

– Android User
Nov 22 '18 at 5:37







what you used to convert images to Video?

– Android User
Nov 22 '18 at 5:37















I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

– Neel Mevada
Nov 22 '18 at 6:20







I am using FFMPEG only to combine Image + Audio to get Video [.mp4] output. @AndroidUser

– Neel Mevada
Nov 22 '18 at 6:20















@NeelMevada can you share the mp4 file you created?

– incBrain
Nov 23 '18 at 2:59





@NeelMevada can you share the mp4 file you created?

– incBrain
Nov 23 '18 at 2:59













@NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

– incBrain
Nov 23 '18 at 3:02





@NeelMevada another question, why didn't you set shareIntent.setType("video/mp4"); for mp4 file?

– incBrain
Nov 23 '18 at 3:02




1




1





@incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

– Neel Mevada
Dec 3 '18 at 10:44





@incBrain Thank you for your support. This is been resolved with using AAC audio codec in this command. now i am using -c:a aac and it runs well.

– Neel Mevada
Dec 3 '18 at 10:44












1 Answer
1






active

oldest

votes


















1














As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy was used on mp3 audio files.



The solution to this is to tell ffmpeg to re-encode audio stream to AAC using -c:a aac.
More examples on how to encode AAC can also be found here.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424073%2fcommand-of-ffmpeg-to-make-a-video-from-imagejpeg-audio-mp3-share-video-i%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy was used on mp3 audio files.



    The solution to this is to tell ffmpeg to re-encode audio stream to AAC using -c:a aac.
    More examples on how to encode AAC can also be found here.






    share|improve this answer




























      1














      As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy was used on mp3 audio files.



      The solution to this is to tell ffmpeg to re-encode audio stream to AAC using -c:a aac.
      More examples on how to encode AAC can also be found here.






      share|improve this answer


























        1












        1








        1







        As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy was used on mp3 audio files.



        The solution to this is to tell ffmpeg to re-encode audio stream to AAC using -c:a aac.
        More examples on how to encode AAC can also be found here.






        share|improve this answer













        As already discussed in the comments the problem occurs due to the audio not to be encoded using AAC codec since -c:a copy was used on mp3 audio files.



        The solution to this is to tell ffmpeg to re-encode audio stream to AAC using -c:a aac.
        More examples on how to encode AAC can also be found here.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 3 '18 at 11:00









        incBrainincBrain

        2,25931125




        2,25931125
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424073%2fcommand-of-ffmpeg-to-make-a-video-from-imagejpeg-audio-mp3-share-video-i%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            Npm cannot find a required file even through it is in the searched directory