Streaming Videos on anything (I think)
Posted: Sun Nov 04, 2012 9:40 pm
I searched long and hard and tried a lot of stuff before I came up with my solution to my transcoding woes and I wanted to impart my experiences to help others in case they were having the same difficulties. My Subsonic doesn't seem to want to transcode anything at all for me and even if it did, transcoding isn't supposed to work at all anyway when your client is a Roku which one of my major clients is. Every time I try to get Subsonic to transcode, it fails and tries to stream the original file and then the log file says that ffmpeg had a permissions problem. I have tried many times to fix this issue but finally decided to forget that since I needed to stream video to the Roku anyway. My solution was to re-encode all files on my Subsonic server to a format that will stream as-is. I settled on .mp4 format because it works on every client out there. You can stream it to web browsers, external players, androids, iphones, Roku... everything that I need.
The next problem I came up against was finding a good conversion software. I used Handbrake for a long time because it was recommended highly by a lot of people but I found that sometimes it would end up skewing the audio on longer files. I tweaked on it for a very long time thinking I could eventually figure out how to fix this but finally realized that Handbrake just didn't seem to know how to properly convert from AC3 to AAC without skewing. So then I started looking for another encoding product.
I tried a few and finally came up with XMedia Recode. It has some problems but it does a fine job when it works properly. Here are the problems I have encountered with it.
1. It doesn't work at all on some of my computers. When I load a file to be converted and go to the Filters/Preview tab, the preview is blank which tells me that the program has some sort of issue with video. On computers that have this issue, if I try to encode anyway, it creates a 0-length file and stops encoding immediately saying 'Done'. I've tried everything I could to fix this, codecs of all kinds, DirectDraw, older versions of the program.... nothing seems to help. This is only on some computers, though. I have 3 here currently and it works fine on 1 of the 3.
2. It crashes when it comes up against something it doesn't know what to do with. I tried to encode a DVD to .mp4 and every time I started the encoding, it would crash immediately. I finally realized I was trying to encode an audio-DVD and that was why it crashed.
3. The Author is german and though he says on his website if you need support, just email me.... he doesn't respond to emails. I've seen this reported on several other websites. Although he does read the emails I think because once I emailed him for a feature request and though he didn't respond to the email, there was soon a new version of the program out that had the feature I had requested so that was really cool...
So, even though it has some problems, when it works, it works brilliantly. XMedia Recode has never failed to recode the audio portion of a video properly. The audio and video is always perfectly synced after a recode (assuming it was synced before encoding). XMedia has a TON of options for encoding so I will tell you what has worked for me.
First of all, I found out that if you want to stream video, you can't just send any old .mp4. To stream video, you have to have an .mp4 that is properly encoded for streaming. In Handbrake that means you have to click 'Web Optimized'. XMedia recode didn't used to have the option to create a file made for streaming but soon after I emailed the author about this, the latest version came out (3.1.3.0 as of this writing) with the option on .mp4 to create a file with 'Fast Start'. This means that the 'moov' atom is set at the beginning of the file rather than the end which used to be the standard. Incidently, if you already have an .mp4 file you want to stream and it doesn't start quickly, you can fix this with either a dos program called qt-faststart.exe or there is a nice little windows utility called MP4 FastStart.exe (thank you DataGoRound for this). Works great... I'm certain I was not the only person to email the author of XMedia Recode about this feature but it seemed as though he was responding to me directly when it came out so quickly after my email. he he.
So, beginning with the Format tab set to MP4, mp4 file extension, codec H.264 and Audio Codec set to AAC, make sure you click the FastStart option to create a streamable file.
Next, the video section, I set Profile to Main, Level at 4.1, Preset to Medium, FrameRate to Keep Original, Rate Control to Constant Quality and Quality at 24.0. This gives me a nice-looking file that will still stream in most cases without jittering. Everything else on the Video tab I leave default.
On the Audio Tab, I set Modus to Convert, Codec to AAC, Sample Rate to 44100, Channels Stereo, Rate Control to Average bitrate, and bitrate to 128. MPEG version at MPEG-4, Object Type LC.
I leave the Subtitles section alone, and move on to Filters/Preview. In Resolution, I make some decisions. If the file I am converting is larger than 720 by anything then I change the Width down to 720 and leave the aspect ratio at Keep original in most cases. Unless I think the aspect ratio is incorrect in the original file in which case I try to fix it.
If the original file doesn't have any chapters and it is a long file like a movie or something, I will auto-add chapters at every 5 minutes and that is pretty much it. I click add job and then encode. XMedia may not be the fastest encoder out there. I have read people saying it is a bit slow but the final result is always very nice and streams well.
In subsonic, i pretty much don't have to do anything special. I just set the video file types to just .mp4 and it is happy to send those straight through. Even a long movie will begin streaming in less than 10 seconds over the internet.
I hope I have helped some of you struggling people. If you think there are improvements to be made to my directions here, I welcome your input. I will try to resond to questions as well. I would also like to thank Sindre for Subsonic. It's a wonderful product.
-dsplzion
The next problem I came up against was finding a good conversion software. I used Handbrake for a long time because it was recommended highly by a lot of people but I found that sometimes it would end up skewing the audio on longer files. I tweaked on it for a very long time thinking I could eventually figure out how to fix this but finally realized that Handbrake just didn't seem to know how to properly convert from AC3 to AAC without skewing. So then I started looking for another encoding product.
I tried a few and finally came up with XMedia Recode. It has some problems but it does a fine job when it works properly. Here are the problems I have encountered with it.
1. It doesn't work at all on some of my computers. When I load a file to be converted and go to the Filters/Preview tab, the preview is blank which tells me that the program has some sort of issue with video. On computers that have this issue, if I try to encode anyway, it creates a 0-length file and stops encoding immediately saying 'Done'. I've tried everything I could to fix this, codecs of all kinds, DirectDraw, older versions of the program.... nothing seems to help. This is only on some computers, though. I have 3 here currently and it works fine on 1 of the 3.
2. It crashes when it comes up against something it doesn't know what to do with. I tried to encode a DVD to .mp4 and every time I started the encoding, it would crash immediately. I finally realized I was trying to encode an audio-DVD and that was why it crashed.
3. The Author is german and though he says on his website if you need support, just email me.... he doesn't respond to emails. I've seen this reported on several other websites. Although he does read the emails I think because once I emailed him for a feature request and though he didn't respond to the email, there was soon a new version of the program out that had the feature I had requested so that was really cool...
So, even though it has some problems, when it works, it works brilliantly. XMedia Recode has never failed to recode the audio portion of a video properly. The audio and video is always perfectly synced after a recode (assuming it was synced before encoding). XMedia has a TON of options for encoding so I will tell you what has worked for me.
First of all, I found out that if you want to stream video, you can't just send any old .mp4. To stream video, you have to have an .mp4 that is properly encoded for streaming. In Handbrake that means you have to click 'Web Optimized'. XMedia recode didn't used to have the option to create a file made for streaming but soon after I emailed the author about this, the latest version came out (3.1.3.0 as of this writing) with the option on .mp4 to create a file with 'Fast Start'. This means that the 'moov' atom is set at the beginning of the file rather than the end which used to be the standard. Incidently, if you already have an .mp4 file you want to stream and it doesn't start quickly, you can fix this with either a dos program called qt-faststart.exe or there is a nice little windows utility called MP4 FastStart.exe (thank you DataGoRound for this). Works great... I'm certain I was not the only person to email the author of XMedia Recode about this feature but it seemed as though he was responding to me directly when it came out so quickly after my email. he he.
So, beginning with the Format tab set to MP4, mp4 file extension, codec H.264 and Audio Codec set to AAC, make sure you click the FastStart option to create a streamable file.
Next, the video section, I set Profile to Main, Level at 4.1, Preset to Medium, FrameRate to Keep Original, Rate Control to Constant Quality and Quality at 24.0. This gives me a nice-looking file that will still stream in most cases without jittering. Everything else on the Video tab I leave default.
On the Audio Tab, I set Modus to Convert, Codec to AAC, Sample Rate to 44100, Channels Stereo, Rate Control to Average bitrate, and bitrate to 128. MPEG version at MPEG-4, Object Type LC.
I leave the Subtitles section alone, and move on to Filters/Preview. In Resolution, I make some decisions. If the file I am converting is larger than 720 by anything then I change the Width down to 720 and leave the aspect ratio at Keep original in most cases. Unless I think the aspect ratio is incorrect in the original file in which case I try to fix it.
If the original file doesn't have any chapters and it is a long file like a movie or something, I will auto-add chapters at every 5 minutes and that is pretty much it. I click add job and then encode. XMedia may not be the fastest encoder out there. I have read people saying it is a bit slow but the final result is always very nice and streams well.
In subsonic, i pretty much don't have to do anything special. I just set the video file types to just .mp4 and it is happy to send those straight through. Even a long movie will begin streaming in less than 10 seconds over the internet.
I hope I have helped some of you struggling people. If you think there are improvements to be made to my directions here, I welcome your input. I will try to resond to questions as well. I would also like to thank Sindre for Subsonic. It's a wonderful product.
-dsplzion