VideoHelp Forum

+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 39
Thread
  1. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Simple Problem with not so simple solution i think..

    I got 50 mp3 files (more coming up next month) and all of them have embedded album art pic within them. Now i want to batch convert them to video (mp4 preferably). My only need is that i want the album art pic to appear in the video automatically (just like a slide show video but with one still image only) I dont want to go through all 50 files one by one so kindly tell me any software which can batch process all of these in one click. Thanx in advance.
    Last edited by Love; 21st Dec 2018 at 13:08.
    Quote Quote  
  2. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Look below, there seem to be several Similar Threads with the same issue already.

    I believe one can use ffmpeg to loop a still image to a video with the duration of the audio track. And alternatively, in AviSynth it will certainly work...
    Quote Quote  
  3. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Thanx for response.. there are 2 issues in it
    1. all mp3 have different embedded images in them.. so FFMPEG cant work am afriad.
    2. even when attempting online, they ask one image per mp3 separately..
    so its tuf to first extract images from all mp3 and then put them back one by one for online websites.. Risk of mixing them all
    Last edited by Love; 21st Dec 2018 at 13:07.
    Quote Quote  
  4. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Oh, your point is making a video stream out of the embedded cover art? ... No, here I can't help you with confidence. Extracting them right before the conversion could be automated with a batch file, I believe, but tinkering that is an elaborate task.
    Quote Quote  
  5. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Yes i want an automated script which should at first extract cover art from an mp3 and then make a video slide show featuring that cover art only in it as a still pic.
    Quote Quote  
  6. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    FFmpeg can indeed extract a cover image from an MP3 file. (See here.) You could put two calls to FFmpeg in a for loop: the first to extract the image and the second to turn it into a video with the MP3 audio.
    Quote Quote  
  7. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Thanx
    From the command line, you can apparently do this:
    Step 1

    ffmpeg -i input.mp3 -an -vcodec copy cover.jpg
    Last edited by Love; 22nd Dec 2018 at 04:56.
    Quote Quote  
  8. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    what should be the 2nd call to FFmpeg ?
    Last edited by Love; 22nd Dec 2018 at 05:14.
    Quote Quote  
  9. Originally Posted by Love View Post
    what should be the 2nd call to FFmpeg ?
    You should be able to figure that out from your other thread.
    https://forum.videohelp.com/threads/391449-Need-Help-to-Convert-600-mp3-to-mp4-with-ju...c-in-it-for-YT
    Quote Quote  
  10. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by jagabo View Post
    Originally Posted by Love View Post
    what should be the 2nd call to FFmpeg ?
    You should be able to figure that out from your other thread.
    https://forum.videohelp.com/threads/391449-Need-Help-to-Convert-600-mp3-to-mp4-with-ju...c-in-it-for-YT
    Thanx a lot for responding... Yes thats my thread too though different purpose which got solved by help from you and others there.. But here am stuck. once all pics are extracted.. how to get them back to their own related mp3 .. because all pics are different and should be combined to their own specific related mp3 In the thread you are referring there was just one pic and it was easy to make a dummy mp4 of that pic and remux with mp3 audios.. Here in this thread there shall be as many pics as many are their mp3 files so a second or third call to FFmpeg may be needed which being a totally noob i have no clue.. just started reading commands of FFmpeg yesterday
    Quote Quote  
  11. You just extracted an image called cover.jpg. The other script used an image called my_image.jpg. Isn't obvious what change you should make?
    Quote Quote  
  12. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by jagabo View Post
    You just extracted an image called cover.jpg. The other script used an image called my_image.jpg. Isn't obvious what change you should make?
    haha.. Luv the way you are encouraging me to learn just on the basis of my common sense. I understand that this way i can extract an image from one file and in the next call FFmpeg shall render that image alongwith its associated mp3 into an mp4 .. Upto this i can manage because it is a single file to operate upon. Problem is arising where loops will be involved. How shall FFmpeag differentiate between which image belongs to which mp3 ?

    common sense says .. isnt the way out should be to assign a unique ID to every image when it is extracted which relates to its parent mp3 so that in 2nd call FFmpeg can recognise which image is to be combined to which mp3 .. this is where a layman like me is standing with hands raised above shoulder
    Quote Quote  
  13. Originally Posted by Love View Post
    Upto this i can manage because it is a single file to operate upon. Problem is arising where loops will be involved. How shall FFmpeag differentiate between which image belongs to which mp3 ?
    If you encode one file at a time there is only one image file. You use the first call to ffmpeg to extract the image, the second to create the video with the image and the mp3 file.

    Code:
    for %%F in (*.mp3) do (
    ffmpeg -y -i "%%F" -an -vcodec copy cover.jpg
    ffmpeg.exe -y -loop 1 -i cover.jpg -i "%%F" -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
    )
    Quote Quote  
  14. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    thats great (Y) Here is the feedback..
    i placed 2 mp3 there. names 001.mp3 and 002.mp3
    Both mp3 had different cover art pics embedded.
    script ran at the speed of 3.36 .. it did produce 2 mp4 files in say 5 minutes.
    Names were correct too. 001.mp4 and 002.mp4
    It also produced just 1 jpg (that of 002.mp3) with name of cover.jpg
    (i want it to produce 2 JPGs with names 001.jpg and 002.jpg as given in their mp3)

    Also plz note that File 002.mp4 is okay but File 001.mp4 is of zero byte
    Quote Quote  
  15. If you want to keep the jpg for each video use:

    Code:
    for %%F in (*.mp3) do (
    ffmpeg -y -i "%%F" -an -vcodec copy "%%~nF.jpg"
    ffmpeg.exe -y -loop 1 -i "%%~nF.jpg" -i "%%F" -vf "scale=ceil(iw/2)*2:ceil(ih/2)*2" -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
    )
    
    pause
    That also will keep the process from failing if the cover art has odd dimensions.
    Last edited by jagabo; 22nd Dec 2018 at 12:12.
    Quote Quote  
  16. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Thanx... ok i checked both cover art images in mp3.. the one which successfully completed in mp4 had image with 800x930 pixels in it .. while the other one which failed had image with 100x100 pixels .. so this turned out to be opposite to what we expected. Even image failed and Odd imaged passed.

    Also another experiment in which i input 2 mp3 files with SAME image embedded in both files.. now this time both mp4 were successfully playing..

    So by these two findings where exactly the error lies Sir?
    Quote Quote  
  17. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by jagabo View Post
    If you want to keep the jpg for each video use:

    Code:
    for %%F in (*.mp3) do (
    ffmpeg -y -i "%%F" -an -vcodec copy "%%~nF.jpg"
    ffmpeg.exe -y -loop 1 -i "%%~nF.jpg" -i "%%F" -vf "scale=ceil(iw/2)*2:ceil(ih/2)*2" -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
    )
    
    pause
    That also will keep the process from failing if the cover art has odd dimensions.
    Thanx .. but NO ..i dont want to keep the same image for these mp4.. these mp3 have different singers pics embedded so i want each of the pic to be different as they are originally. Also each pic should be produced in folder with its name same as its parent mp3 name ... 001.jpg, 002.jpg and onwards.
    This script however can be useful where i'll need one pic for all mp4 .. but since it will take too much time in that case so i'll be adding a dummy mp4 file in that case and the shortest command..to save time.
    Quote Quote  
  18. Originally Posted by Love View Post
    Originally Posted by jagabo View Post
    If you want to keep the jpg for each video use:

    Code:
    for %%F in (*.mp3) do (
    ffmpeg -y -i "%%F" -an -vcodec copy "%%~nF.jpg"
    ffmpeg.exe -y -loop 1 -i "%%~nF.jpg" -i "%%F" -vf "scale=ceil(iw/2)*2:ceil(ih/2)*2" -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
    )
    
    pause
    That also will keep the process from failing if the cover art has odd dimensions.
    Thanx .. but NO ..i dont want to keep the same image for these mp4.. these mp3 have different singers pics embedded so i want each of the pic to be different as they are originally. Also each pic should be produced in folder with its name same as its parent mp3 name ... 001.jpg, 002.jpg and onwards.
    That's what the script does. Did you even bother to try it?

    And, of course it's slow. We're back to the problem of ffmpeg's loop and encoding being slow. A possible solution to that is to use a very low frame rate, like 1 fps, so there are fewer frames to encode. I don't know how well youtube will deal with that though.
    Quote Quote  
  19. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Yessss.... its perfect now (Y) (Y) (Y) thank you so much.. so now we can change mp3 to mp4 with their original cover art pics.. Just want to ask where does FFmpeg take the video bit rate.. does it get from the pic size? or Duration of mp3 or some other parameter ??? it is less than 100kbps in both output.
    Quote Quote  
  20. ffmpeg defaults to x264's CRF encoding, with a CRF value of 23. Still images and small frame sizes require very little bitrate. You can get slightly better image quality (and higher bitrate) using a lower CRF value. For example, add "-crf 12" to the x264 options. If you want to try faster encoding change the frame rate to something low like 1.0 fps. Add "-r 1.0" to the command line. I don't know how youtube will handle that though. Try a test and see what happens.
    Quote Quote  
  21. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Thanx for the info about bit rate.. yes frame rate i have already checked.. 15 is the minimum default acceptance for youtube.. and 25 for dailymotion .. I am highly obliged for not only the guidance but also bearing a novice with great patience .. i was stick in these huge stock of mp3 with me.. being a collector i got above 30,000 mp3 songs and in this old age i just wanted to share as many as i can to youtube etc ..before i die and my relative throw my library out of home as no one is interested now in 1930s, 40s aur 50s music. Also thankful to the admins of this website for providing such a kind n helpful platform where i got answers to all my queries within the span of some 72 hours. Hats off to experts like you and others. Stay blessed and Happy Xmas to those celebrating (Y) Adios.
    Quote Quote  
  22. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by Love View Post
    Thanx... ok i checked both cover art images in mp3.. the one which successfully completed in mp4 had image with 800x930 pixels in it .. while the other one which failed had image with 100x100 pixels .. so this turned out to be opposite to what we expected. Even image failed and Odd imaged passed.
    What you mean is that the rectangular image passed and the square image failed. Both 800 and 930 are even numbers. That's what jagabo was talking about.
    Quote Quote  
  23. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Just tested this script saved as a .CMD file in a folder with MP3's with cover art as well as the FFMpeg file. It produces an image with the MP3 file name in it and also creates a
    larger 800x800 image in case you wanted it larger with same resolution. These lines can be stripped/changed as required but it does produce the MP4 with audio and cover art.


    Code:
    setlocal enabledelayedexpansion
    ::echo off
    for %%a in (*.mp3) Do (
    set /a count=0
    cd %%~dpa
    set /a Number=0
    ffmpeg.exe -i "%%a" -an -vcodec copy "%%~na_image.jpg"
    ffmpeg.exe -i "%%~na_image.jpg" -f image2 -vf scale=800:-1 "%%~na_image800.jpg"
    ffmpeg -loop 1 -f image2 -i "%%~na_image800.jpg"^
     -i "%%a" -map 0:0 -map 1:0 -acodec copy -vcodec libx264 -r 30 -shortest  -pix_fmt yuv420p^
     "%%~na_AudioVideo.MP4"
    set /a count+=1
    )
    echo !count! files converted
    
    pause
    Image
    [Attachment 47573 - Click to enlarge]
    Quote Quote  
  24. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by JVRaines View Post
    Originally Posted by Love View Post
    Thanx... ok i checked both cover art images in mp3.. the one which successfully completed in mp4 had image with 800x930 pixels in it .. while the other one which failed had image with 100x100 pixels .. so this turned out to be opposite to what we expected. Even image failed and Odd imaged passed.
    What you mean is that the rectangular image passed and the square image failed. Both 800 and 930 are even numbers. That's what jagabo was talking about.
    Yes you are right (Y)
    Quote Quote  
  25. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by Budman1 View Post
    Just tested this script saved as a .CMD file in a folder with MP3's with cover art as well as the FFMpeg file. It produces an image with the MP3 file name in it and also creates a
    larger 800x800 image in case you wanted it larger with same resolution. These lines can be stripped/changed as required but it does produce the MP4 with audio and cover art.


    Code:
    setlocal enabledelayedexpansion
    ::echo off
    for %%a in (*.mp3) Do (
    set /a count=0
    cd %%~dpa
    set /a Number=0
    ffmpeg.exe -i "%%a" -an -vcodec copy "%%~na_image.jpg"
    ffmpeg.exe -i "%%~na_image.jpg" -f image2 -vf scale=800:-1 "%%~na_image800.jpg"
    ffmpeg -loop 1 -f image2 -i "%%~na_image800.jpg"^
     -i "%%a" -map 0:0 -map 1:0 -acodec copy -vcodec libx264 -r 30 -shortest  -pix_fmt yuv420p^
     "%%~na_AudioVideo.MP4"
    set /a count+=1
    )
    echo !count! files converted
    
    pause
    Image
    [Attachment 47573 - Click to enlarge]
    Now thats excellent work too.. just 2 glitches. fps is 30 which is more than enough for a video with just one still pic.. and secondly the last command COUNT .. it counted 1 though it converted 2 mp3 files I kept in that folder. I see so many people who upload audios on youtube. In the absence of any such software.. so if this script can get some GUI with proper input options like which screen size, which bit-rate (video and audio) and fps so that person using it can get various results then may be it can bring some bucks for the programmer too
    Quote Quote  
  26. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    silly me!!! Kept resetting Count to 0. Moved it

    Code:
    setlocal enabledelayedexpansion
    ::echo off
    set /a count=0
    for %%a in (*.mp3) Do (
    cd %%~dpa
    set /a Number=0
    ffmpeg.exe -i "%%a" -an -vcodec copy "%%~na_image.jpg"
    ffmpeg.exe -i "%%~na_image.jpg" -f image2 -vf scale=800:-1 "%%~na_image800.jpg"
    ffmpeg -loop 1 -f image2 -i "%%~na_image800.jpg"^
     -i "%%a" -map 0:0 -map 1:0 -acodec copy -vcodec libx264 -r 30 -shortest  -pix_fmt yuv420p^
     "%%~na_AudioVideo.MP4"
    set /a count+=1
    )
    echo !count! files converted
    
    pause
    Quote Quote  
  27. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Is there a need for an image2video or possibly image(S)2video with maybe transitions between them?

    Image
    [Attachment 47607 - Click to enlarge]


    Image
    [Attachment 47608 - Click to enlarge]
    Quote Quote  
  28. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by Budman1 View Post
    silly me!!! Kept resetting Count to 0. Moved it

    Code:
    setlocal enabledelayedexpansion
    ::echo off
    set /a count=0
    for %%a in (*.mp3) Do (
    cd %%~dpa
    set /a Number=0
    ffmpeg.exe -i "%%a" -an -vcodec copy "%%~na_image.jpg"
    ffmpeg.exe -i "%%~na_image.jpg" -f image2 -vf scale=800:-1 "%%~na_image800.jpg"
    ffmpeg -loop 1 -f image2 -i "%%~na_image800.jpg"^
     -i "%%a" -map 0:0 -map 1:0 -acodec copy -vcodec libx264 -r 30 -shortest  -pix_fmt yuv420p^
     "%%~na_AudioVideo.MP4"
    set /a count+=1
    )
    echo !count! files converted
    
    pause
    thats nice.. i set -r 1 ..and youtube still accepts it conversion becomes fast too.. however dailymotion is accepting it only when fps is 41 or above.. what if we want to change it to some codec other than x264? what other options are available?
    Quote Quote  
  29. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Originally Posted by Budman1 View Post
    Is there a need for an image2video or possibly image(S)2video with maybe transitions between them?

    Image
    [Attachment 47607 - Click to enlarge]


    Image
    [Attachment 47608 - Click to enlarge]
    Yess.. this looks cool.. Hope there is also a switch of Transition On/Off ..and also Random Transitions check box on top of effects list.
    Also Video Screen Size and FPS are a must requirement to include..
    Among Audios .. the options should not be limited to mp3 only because professionally WAV and FLAC are used preferably.
    Last edited by Love; 24th Dec 2018 at 03:35.
    Quote Quote  
  30. Member
    Join Date
    Dec 2018
    Location
    Pakistan
    Search Comp PM
    Also your script is generating 2 images.. i think only one album art is enough with original size as embedded in mp3 .. the other one referred to image800 here is not needed by the user. If it is needed by the script for video frame size then after conversion ask the script to delete it.. it is unwanted. One jpg is sufficient if one has to build it as a separate photo album. For that you can also give user a choice of.. Original, 320x240, 640x480, 800x600 and 1024 etc.
    Quote Quote  



Similar Threads