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.
+ Reply to Thread
Results 1 to 8 of 8
-
-
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 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. -
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"
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"
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.
-
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? -
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
- Create a video-only file with your static background at a duration longer than your longest audio file.
- 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.
- Upload to YouTube, which will re-encode it all anyway.
-
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.
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?Last edited by abolibibelot; 27th Dec 2018 at 20:57.
-
liten lägenhet 250/100
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 -
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.
Similar Threads
-
Is there an Avisynth Lossless Video Codec that uses lower bitrate for 720p?
By VideoFanatic in forum Video ConversionReplies: 7Last Post: 17th Apr 2018, 19:44 -
How to turn off automatic 2-channel mono?
By JVRaines in forum Capturing and VCRReplies: 0Last Post: 7th Oct 2017, 21:32 -
Converting an AAC Mono file to AAC Stereo, higher audio bitrate?
By brightmademedia in forum AudioReplies: 2Last Post: 17th Jun 2017, 09:41 -
Reencoding video to a lower bitrate: downsample first?
By pachura in forum Video ConversionReplies: 3Last Post: 31st Mar 2017, 12:14 -
Direct Stream Video - But Keep Audio Codec & Change Bitrate in an MKV file
By TheRandomOne in forum Video ConversionReplies: 1Last Post: 4th Jan 2016, 22:00