VideoHelp Forum
+ Reply to Thread
Results 1 to 24 of 24
Thread
  1. No background meaning no images...just black.


    I'm using Windows and would prefer freeware. Recommendations?
    Quote Quote  
  2. Make yourself a small black png file then:

    Code:
    ffmpeg -loop 1 -r 1 -i black.png -i input.mp3 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p output.mkv
    Or put this in a batch file and you can drag/drop MP3 files onto it and it will produce an MKV video in the same folder.

    Code:
    ffmpeg -loop 1 -r 1 -i path\to\black.png -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Change path\to\black.png to reflect the location of the file on your computer.

    An hour long MP3 file and a 16x16 pixel black.png took about 1 minute to convert. The mp3 file was 54.8 MB and the resulting MKV file was 55.8 MB.

    If you put the BAT file in your SendTo folder, say, with the name MP3toMKV, you can right click on any MP3 file in Explorer and select Send To -> MP3toMKV.
    Last edited by jagabo; 13th Jun 2017 at 00:33.
    Quote Quote  
  3. PNG input can actually become a bottleneck, even with CPU encoding (pure black is very fast to encode, even with CPU libx264). If OP has suitable GPU ,NVEnc is very fast too although benefits are not as dramatic with pure black encoding

    ffmpeg actually has several internal signal generators. You can use YUV black . The benefit is much faster (no RGB=>YUV conversion) , lower CPU usage . For example , on a quick test for 1280x720 it was about 3-4 times faster just output to null with about 1/2 the CPU usage. On actual encoding , the looped PNG poses a bottleneck too, actual encoding speed is about 2-3x faster too .

    eg. for 1280x720, 30.0fps black YUV generation (everything else would be the same, like -shortest, -c:a copy etc...)
    Code:
    ffmpeg -f lavfi -i color=c=black:s=1280x720:r=30
    Not sure what dimensions, frame rate etc.. OP wanted
    Quote Quote  
  4. It's an audio file with talking (not music) so whatever is recommended. I WOULD like the output to be 720p for Youtube.
    Quote Quote  
  5. Also, I LOVE the idea of the BAT file!
    Quote Quote  
  6. Originally Posted by AshleyQuick View Post
    It's an audio file with talking (not music) so whatever is recommended. I WOULD like the output to be 720p for Youtube.
    Then use a 1280x720 black png image. Note that the above code produces a 1 fps video. I don't know what youtube will make of that. If Youtube doesn't like it you may have to change "-f 1" to "-f 30" or whatever fps youtube will accept.

    ffmpeg took about a minute and a half to convert a one hour MP3 file to a 1280x720 black video. The 54.8 MB MP3 file became a 55.9 MB MKV.

    Note that this code does not re-convert the MP3 audio. It just copies it to the MKV file.
    Last edited by jagabo; 13th Jun 2017 at 00:46.
    Quote Quote  
  7. Originally Posted by poisondeathray View Post
    ffmpeg actually has several internal signal generators. You can use YUV black . The benefit is much faster (no RGB=>YUV conversion) , lower CPU usage . For example , on a quick test for 1280x720 it was about 3-4 times faster just output to null with about 1/2 the CPU usage. On actual encoding , the looped PNG poses a bottleneck too, actual encoding speed is about 2-3x faster too.
    I didn't know ffmpeg could generate a black clip. I just tried your example using a 1280x720 1 fps video and it was a little faster than using a single PNG. Converting at about 55 fps vs. 45 fps. Generating the image also has the benefit of not having to keep a PNG image around and changing the BAT file to point to it.

    So my drag/drop BAT file now looks like:

    Code:
    ffmpeg -f lavfi -i color=c=black:s=1280x720:r=1 -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    The other code is worth keeping around for when you want to use a real image (cover art, static message, etc).
    Quote Quote  
  8. Originally Posted by jagabo View Post
    Originally Posted by poisondeathray View Post
    ffmpeg actually has several internal signal generators. You can use YUV black . The benefit is much faster (no RGB=>YUV conversion) , lower CPU usage . For example , on a quick test for 1280x720 it was about 3-4 times faster just output to null with about 1/2 the CPU usage. On actual encoding , the looped PNG poses a bottleneck too, actual encoding speed is about 2-3x faster too.
    I didn't know ffmpeg could generate a black clip. I just tried your example using a 1280x720 1 fps video and it was a little faster than using a single PNG. About 55 fps vs 45 fps. Generating the image also has the benefit of not having to keep a PNG image around and changing the BAT file to point to it.

    Something up with that fps ? 55? I'm just using -preset:v ultrafast on 1280x720. I tried quick test on an old laptop with a random 7min mp3 and it was almost 3x faster. 780fps vs 230fps
    Quote Quote  
  9. Originally Posted by poisondeathray View Post
    Something up with that fps ? 55?
    Ah, I was working on a network share (where I keep lots of ffmpeg samples for reference). Using a local MP3 on an SSD I get speeds like yours.
    Quote Quote  
  10. Originally Posted by jagabo View Post
    Then use a 1280x720 black png image. Note that the above code produces a 1 fps video. I don't know what youtube will make of that. If Youtube doesn't like it you may have to change "-f 1" to "-f 30" or whatever fps youtube will accept.

    ffmpeg took about a minute and a half to convert a one hour MP3 file to a 1280x720 black video. The 54.8 MB MP3 file became a 55.9 MB MKV.

    Note that this code does not re-convert the MP3 audio. It just copies it to the MKV file.
    The only setback is that I can only convert an MP3 if it's in the same DIR as the black.png

    Here's what I have in the BAT:
    Code:
    ffmpeg -loop 1 -r 1 -i C:\youtube-dl\black.png -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Otherwise, it works great and Youtube is good with it!
    Quote Quote  
  11. And you don't need a SSD to see the speed benefit, my test was on the same read/write 5400rpm clunky laptop drive . NVEnc is even faster. With an old maxwell card ~900FPS with -preset:v fast -c:v h264_nvenc . A pascal card should theoretically get around 1700-1800FPS in the absense of other bottlenecks (the signal generator wasn't that fast on this laptop, about 1200-1300fps max)

    --tune stillimage will slow encoding down slightly compared to no AQ or psy options (not that you would notice it when you're getting hundreds of FPS), but I would argue their use is questionable with "black" frames
    Quote Quote  
  12. Originally Posted by AshleyQuick View Post

    The only setback is that I can only convert an MP3 if it's in the same DIR as the black.png

    Here's what I have in the BAT:
    Code:
    ffmpeg -loop 1 -r 1 -i C:\youtube-dl\black.png -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Otherwise, it works great and Youtube is good with it!
    Use the png bat file if you want an image background

    Use the other bat file with the signal generator if you want black (or any other solid color) background. It's about 3x faster and you can convert anywhere without a png
    Quote Quote  
  13. I missed that post somehow. Well, hmmm...it works but the MP3 file has to reside in the same directory as ffmpeg

    Not a showstopper but if there's an easy fix, let me know? Thx!
    Quote Quote  
  14. add ffmpeg directory to system path (you can do this locally within batch)

    Code:
    @setlocal
    @set FFMPG=D:\Media\FF
    @set PATH=%PATH%;%FFMPG%
    @set FC_CONFIG_DIR=%FFMPG%\conf
    @set FONTCONFIG_FILE=%FFMPG%\conf\fonts.conf
    @set FONTCONFIG_PATH=%FFMPG%\conf
    
    @ffmpeg -y -i %1 ......."
    
    @endlocal
    @Pause
    tune like fastdecode shall speed up encoding significantly.
    Quote Quote  
  15. Or use the full path to ffmpeg.exe.

    Code:
    "G:\program files\ffmpeg\bin\ffmpeg.exe" -f lavfi -i color=c=black:s=1280x720:r=1 -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Change the path wherever ffmpeg.exe is on your computer.
    Quote Quote  
  16. Originally Posted by jagabo View Post
    Or use the full path to ffmpeg.exe.

    Code:
    "G:\program files\ffmpeg\bin\ffmpeg.exe" -f lavfi -i color=c=black:s=1280x720:r=1 -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Change the path wherever ffmpeg.exe is on your computer.
    Works great...such an efficient solution, thanks guys!
    Quote Quote  
  17. Member
    Join Date
    Dec 2005
    Location
    United States
    Search Comp PM
    Originally Posted by jagabo View Post
    Make yourself a small black png file then:

    Or put this in a batch file
    Sounds like what I need but I am not coding strong guys so I am sorry but I will need a little help to figure out the above instructions please?
    Quote Quote  
  18. Originally Posted by mikehende View Post
    Originally Posted by jagabo View Post
    Make yourself a small black png file then:

    Or put this in a batch file
    Sounds like what I need but I am not coding strong guys so I am sorry but I will need a little help to figure out the above instructions please?
    Start Notepad. Copy the text from the code block post #7 and paste it into Notepad. Change the initial "ffmpeg" to the full path or where you installed it on your computer, something like "C:\Program Files\ffmpeg\bin\ffmpeg.exe". Save the document to a convenient place (Desktop? Send To folder) with the extension ".BAT" rather than ".TXT". Then drag/drop any audio file onto the batch file to create a black video with that MP3 audio.
    Quote Quote  
  19. Member
    Join Date
    Dec 2005
    Location
    United States
    Search Comp PM
    Thanks, do you mean in notepad I should replace the word ffmpeg with this path C:\Program Files\ffmpeg\bin\ffmpeg.exe or whichever part of the HDD ffmpeg app is physically located?
    Quote Quote  
  20. Originally Posted by mikehende View Post
    Thanks, do you mean in notepad I should replace the word ffmpeg with this path C:\Program Files\ffmpeg\bin\ffmpeg.exe or whichever part of the HDD ffmpeg app is physically located?
    Yes. So your batch file will end up looking something like:

    Code:
    "C:\Program Files\ffmpeg\bin\ffmpeg.exe" -f lavfi -i color=c=black:s=1280x720:r=1 -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    If the path contains spaces it must be enclosed in quotes, as in the sample here.
    Quote Quote  
  21. Member
    Join Date
    Dec 2005
    Location
    United States
    Search Comp PM
    I am seeing 2 folders on the C drive with the name ffmpeg [FFMPEG Addon and FFmpeg for Audacity] so the path would be either C:\Program Files\FFMPEG Addon.exe or
    C:\Program Files\FFmpeg for Audacity.exe?
    Quote Quote  
  22. jagabo, so the code you posted has worked great but now, I think I want to switch from the black background to a jpg (bg.jpg) which would reside in the ffmpeg directory. How would the code be modified to use that? Here's what I have in the bat file:

    Code:
    "C:\dl\ffmpeg.exe" -f lavfi -i color=c=black:s=1280x720:r=1 -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Also, these are being uploaded to Youtube so, ideally, should the aspect ratio of the .jpg be 1280x720?
    Quote Quote  
  23. Something like:

    Code:
    "C:\dl\ffmpeg.exe" -loop 1 -r 1 -i "C:\dl\bg.jpg"  -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"
    Quote Quote  
  24. Originally Posted by jagabo View Post
    Something like:

    Code:
    "C:\dl\ffmpeg.exe" -loop 1 -r 1 -i "C:\dl\bg.jpg"  -i %1 -c:v libx264 -preset ultrafast -tune stillimage -crf 20  -c:a copy -shortest -pix_fmt yuv420p "%~n1.mkv"

    That works, thanks! It takes considerably longer to create now but I'm assuming it's because of the size of the .jpg (it's 813kb).
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!