VideoHelp Forum


Try NordVPN to access Netflix or other streaming services from any country and also surf safe!
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Hi guys

    This post is related to both audio and video-conversion but I think that it’s most suitable in the audio-section and that’s why I’m posting it here.

    I have a bunch of lectures (largely talk-only) that I want to share on a website. Some of the lectures are in audio-only while some are video-recorded. In order to provide visitors with alternatives and accommodate for YouTube’s requirements on videos, I did the following:
    • Extracted the audio from the videos to create mp3 files with the following ffmpeg script
      Code:
      for %%a in (*.mp4) do ffmpeg -i "%%~a" -q:a 0 "output\%%~na.mp3"
    • Created mp4 duplicates of the audios with a static background picture with the following ffmpeg script
      Code:
      for /R %%g in ("*.mp3") do (
      ffmpeg -r 1.0 -loop 1 -i "Background.jpg" -i "%%g"^
       -map_metadata 1^
       -map_metadata:s:a 1:s:a^
       -strict -1 -c:a copy -c:v libx264 -preset superfast -tune stillimage^
       -shortest "%%~dpng.mp4"
      )

    So now I have an mp3 and an mp4 file of each lecture. This process took a lot of time and I have since spent a lot of time on adjusting the metadata of the files for consistency and convenience. However, I was advised to do the following in order to reduce file size and address bandwith:
    • Re-encode the audios so that the bitrate is 32 kbps and the channel is mono
    • Re-encode the audio in the videos so that the channel is mono

    Since I spent a lot of time extracting, converting and adjusting metadata, my first question is this:
    Does it matter much in terms of quality and size if I simply re-encode the existing files according to the above compared to if I would take the original files (before extracting audio/converting to mp4), re-encode them according to the above and then extract audio/convert to mp4?

    Second, what ffmpeg script do I need to use to do the above? I want to keep the metadata and the files are spread out in subfolders across a directory.
    Quote Quote  
  2. Does it matter much in terms of quality and size if I simply re-encode the existing files according to the above compared to if I would take the original files (before extracting audio/converting to mp4), re-encode them according to the above and then extract audio/convert to mp4?
    In terms of size it does not matter since size is strictly determined by bitrate.
    In terms of quality, with each transcoding generation you lose “some” quality. Whether it's noticeable / disturbing depends on many factors, but certainly, if you care at all about quality (if you didn't you wouldn't even bother asking the question ), you should convert from the best source available. Especially if the output is at such a low bitrate. Or maybe it's so low that it won't matter much... But at that low bitrate, MP3 will be quite lousy, whereas some other codecs can stay decent-sounding. Downmixing to mono may not reduce the bitrate requirement (and thus improve the quality at a fixed bitrate) compared with joint stereo, for that type of material (which usually has a lot of redundancy between left and right channels). Reducing the sampling rate to 22kHz may improve the subjective quality at a low bitrate, for talk-only content.
    Also, with the method you already used, you already transcoded audio twice to create those MP4 (AAC => MP3 => AAC – unless you preserved the MP3 audio into the MP4 with “c:a copy”, but it's not standard and might cause playback issues), whereas you could have saved a lot of transcoding time and retained quality by simply copying the audio from the source MP4 to the MP4 with static pictures.
    Quote Quote  
  3. Bitrate and quality will depend directly from spectral complexity of your audio, you can simplify spectral complexity by filtering unnecessary part of spectrum thus focus encoder on most important part of spectrum.
    Bellow ffmpeg example should provide downmixed to mono, band limited (150 .. 5500Hz) and equalized loudness audio signal from any even multichannel source.
    Code:
    -af "pan=mono|FC < FL+FR+1.414FC+0.25BL+0.25SL+0.25BR+0.25SR,firequalizer=gain='if(gte(f,150),0,-INF)+if(lte(f,5500),0,-INF)',dynaudnorm=p=1/sqrt(2):m=100:s=12,firequalizer=gain='if(gte(f,150),0,-INF)+if(lte(f,5500),0,-INF)',aresample=resampler=soxr:osr=16000:cutoff=0.990:dither_method=0"
    IMHO to achieve your goal quickly i would advise: first you should re-encode once again audio (process should be way faster than video encoding) - add above -af... to your first script and re-run script with mp4 audio sources.

    Code:
    for %%a in (*.mp4) do ffmpeg -i "%%~a" -af "pan=mono|FC < FL+FR+1.414FC+0.25BL+0.25SL+0.25BR+0.25SR,firequalizer=gain='if(gte(f,150),0,-INF)+if(lte(f,5500),0,-INF)',dynaudnorm=p=1/sqrt(2):m=100:s=12,firequalizer=gain='if(gte(f,150),0,-INF)+if(lte(f,5500),0,-INF)',aresample=resampler=soxr:osr=16000:cutoff=0.990:dither_method=0" -b:a 32k "output\%%~na.mp3"
    Next step is to use already encoded video and replace (muxing) old audio with new audio but without encoding video.
    To process files in folders... honestly - my DOS scripting knowledge is insufficient to do this in nice and elegant way and brute force method imply recreating folder structure and process file by file with full path separately or perform recursive processing to new folder and later moving files to desired recreated folder structure... both methods are like plenty of work, not elegant thus not recommended...

    You may wish to rencode video by using few tricks for still image video (like reduced framerate, infinite GOP etc)
    Last edited by pandy; 25th Dec 2018 at 10:17.
    Quote Quote  
  4. Your whole exercise is a waste of time as YouTube will reencode everything to meet their criteria. If the goal is to put everything on YouTube, you want to provide them with the best possible source for them to reencode. And, as mentioned, any reencode degrades the quality. If they are accepted by YouTube, I'd upload what I have without any reencoding at all. For the ones with no video, just mux a picture with the audio to MP4.

    Does it matter much in terms of quality and size if I simply re-encode the existing files according to the above compared to if I would take the original files (before extracting audio/converting to mp4), re-encode them according to the above and then extract audio/convert to mp4?
    If for YouTube, it certainly does make a difference. You want the audio quality of the lectures to be as good as possible when viewed on YouTube. You are just ruining it.
    Quote Quote  
  5. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by DennisO View Post
    However, I was advised to do the following in order to reduce file size and address bandwith:
    • Re-encode the audios so that the bitrate is 32 kbps and the channel is mono
    • Re-encode the audio in the videos so that the channel is mono
    Where did you get this lousy advice? (I hope it wasn't me! ) There is no reason to go to this trouble for the reduction in file size, especially since YouTube is your target. Your best workflow is to
    1. Create a video-only file with your static background at a duration longer than your longest audio file.
    2. In the loop, copy over each original audio and mate it with the static video. The shortest option will cut the video down to the length of the audio.
    3. Upload to YouTube, which will re-encode it all anyway.
    Quote Quote  
  6. Where did you get this lousy advice? (I hope it wasn't me! ) There is no reason to go to this trouble for the reduction in file size, especially since YouTube is your target.
    If I understood correctly, the website would also propose the files (MP3 audio & MP4 video) for direct download – otherwise there would be no bandwidth / storage constraint, and no point in keeping the metadata. YouTube would be an alternative option – and in this case would be the best quality-wise : even if YouTube re-encodes everything, the quality is better preserved than when drastically reducing the bitrate to 32kbps.
    Another option would be to rely on a convenient file-sharing website, thus removing the aforementioned constraints; one with no waiting time, no f##ing captchas, and a decent speed for unsubscribed users. Problem is, those websites keep appearing and disappearing like mushrooms, or changing their rules, so it's tricky to stick with one for the long term.

    Where did you get this lousy advice?
    Possibly from the webmaster of said website...
    Last edited by abolibibelot; 27th Dec 2018 at 20:57.
    Quote Quote  
  7. liten lägenhet 250/100


    Originally Posted by manono View Post
    Your whole exercise is a waste of time as YouTube will reencode everything to meet their criteria. If the goal is to put everything on YouTube, you want to provide them with the best possible source for them to reencode. And, as mentioned, any reencode degrades the quality. If they are accepted by YouTube, I'd upload what I have without any reencoding at all. For the ones with no video, just mux a picture with the audio to MP4.

    Does it matter much in terms of quality and size if I simply re-encode the existing files according to the above compared to if I would take the original files (before extracting audio/converting to mp4), re-encode them according to the above and then extract audio/convert to mp4?
    If for YouTube, it certainly does make a difference. You want the audio quality of the lectures to be as good as possible when viewed on YouTube. You are just ruining it.

    Originally Posted by JVRaines View Post
    Originally Posted by DennisO View Post
    However, I was advised to do the following in order to reduce file size and address bandwith:
    • Re-encode the audios so that the bitrate is 32 kbps and the channel is mono
    • Re-encode the audio in the videos so that the channel is mono
    Where did you get this lousy advice? (I hope it wasn't me! ) There is no reason to go to this trouble for the reduction in file size, especially since YouTube is your target. Your best workflow is to
    1. Create a video-only file with your static background at a duration longer than your longest audio file.
    2. In the loop, copy over each original audio and mate it with the static video. The shortest option will cut the video down to the length of the audio.
    3. Upload to YouTube, which will re-encode it all anyway.
    Originally Posted by abolibibelot View Post
    Where did you get this lousy advice? (I hope it wasn't me! ) There is no reason to go to this trouble for the reduction in file size, especially since YouTube is your target.
    If I understool correctly, the website would also propose the files (MP3 audio & MP4 video) for direct download – otherwise there would be no bandwidth / storage constraint, and no point in keeping the metadata. YouTube would be an alternative option – and in this case would be the best quality-wise : even if YouTube re-encodes everything, the quality is better preserved than when drastically reducing the bitrate to 32kbps.
    Another option would be to rely on a convenient file-sharing website, thus removing the aforementioned constraints; one with no waiting time, no f##ing captchas, and a decent speed for unsubscribed users. Problem is, those websites keep appearing and disappearing like mushrooms, or changing their rules, so it's tricky to stick with one for the long term.

    Where did you get this lousy advice?
    Possibly from the webmaster of said website...

    Thank you all for your replies. I really appreciate the help on this forum. I think I need to explain something though. The exercise is NOT for YouTube. It is true that I created the mp4-duplicates in order to upload to YouTube, but I was hoping to self-host all the content on said website with our own mediaplayer, hence bandwith tension etc


    As for the other advice, I will have to read it once again slowly later today as this is quite unfamiliar territory for me
    Quote Quote  
  8. So, you also want to create a lower quality version for hosting on your own website, as well as what you upload for YouTube? You could try this:

    Upload the best quality you can to YouTube. If you don't intend on making some public there, then keep those ones private. Then download the YouTube version after they get done reencoding it and use that for your website. The size should shrink dramatically. Doing it that way should keep you from having to figure out what you should do to keep the size down and it'll save you the time and effort of creating two different versions, one for YouTube and another for the website. Especially since you've freely admitted you don't know what you're doing and have received some very questionable advice.

    I see no benefit at all to uploading a crap version to YouTube because it'll just become even worse by the time they get dome with it.
    Quote Quote  



Similar Threads