wtploiqbn 6 Posted May 26, 2023 Posted May 26, 2023 (edited) Every time after I record a live channel, I have to go to Convert > Container > mp4 > Convert. Is there any way for me to setup a scheduling so that after a Recording is completed successfully, for Emby Server to also automatically Convert that recording to mp4 and save it in the same "Original media folder, next to original files"? (as the current settings, without me having to manually press the Convert button as in the screenshots) Edited May 26, 2023 by wtploiqbn
wtploiqbn 6 Posted May 26, 2023 Author Posted May 26, 2023 PS: I have the recording setup on Schedule, i.e. it records a specific channel every day between specific hours. So I am looking to also convert the recording to MP4 once it has successfully completed the recording
Solution gillmacca01 211 Posted May 27, 2023 Solution Posted May 27, 2023 (edited) If you bring up the menu on the main recordings folder (not show level) and select convert, there is an option to automatically convert all new content. I don't think it converts straight away, but creates a scheduled task, which you can change how often it converts Edited May 27, 2023 by gillmacca01 2
wtploiqbn 6 Posted May 28, 2023 Author Posted May 28, 2023 thanks a lot @gillmacca01, yes there is a setting for new content to be automatically converted. Thank you! 1
serpi 82 Posted May 28, 2023 Posted May 28, 2023 I'm using a script to automatically convert recorded tv using ffmpeg after recording has finished. You can set this in the setting in LiveTV.
wtploiqbn 6 Posted October 12, 2023 Author Posted October 12, 2023 On 29/05/2023 at 00:14, serpi said: I'm using a script to automatically convert recorded tv using ffmpeg after recording has finished. You can set this in the setting in LiveTV. Cool, i did not know I can do this. Whereabouts in Settings in LiveTV? I see LiveTV > Settings > and 3 tabs Setup/Channels/Advanced Can't see where I could add ffmpeg. Thank you!
rbjtech 5284 Posted October 12, 2023 Posted October 12, 2023 (edited) 13 minutes ago, wtploiqbn said: Cool, i did not know I can do this. Whereabouts in Settings in LiveTV? I see LiveTV > Settings > and 3 tabs Setup/Channels/Advanced Can't see where I could add ffmpeg. Thank you! In Live TV > Advanced You just need to write a small script to do this (in my case just a windows batch file) Mine creates a mkv using mkvmerge - but you can replace that with ffmpeg if you like to create an MP4 using the same logic. example batch file - this removes the original .TS recording if there is a sucessfully created MKV of the same name. @echo off set logfile="c:\batch\emby_tv_recordings_log.txt" echo Emby TV Post Processing echo. echo [%date% %time:~0,8%] Info EmbyTV Processing : "%~d1%~p1%~n1.ts" >> %logfile% "C:\mkvtoolnix\mkvmerge.exe" -o "%~d1%~p1%~n1.mkv" --audio-tracks eng --no-buttons --no-attachments --no-global-tags --no-track-tags "%~d1%~p1%~n1.ts" if %errorlevel% equ 0 ( echo [%date% %time:~0,8%] Info EmbyTV Processed : "%~d1%~p1%~n1.mkv" >> %logfile% if exist "%~d1%~p1%~n1.mkv" del "%~d1%~p1%~n1.ts" ) else ( echo [%date% %time:~0,8%] Error EmbyTV File Not Processed : "%~d1%~p1%~n1.ts" >> %logfile% ) Edited October 12, 2023 by rbjtech 2
wtploiqbn 6 Posted October 13, 2023 Author Posted October 13, 2023 On 12/10/2023 at 22:55, rbjtech said: You just need to write a small script to do this (in my case just a windows batch file) Mine creates a mkv using mkvmerge - but you can replace that with ffmpeg if you like to create an MP4 using the same logic. example batch file - this removes the original .TS recording if there is a sucessfully created MKV of the same name. Thx a lot buddy @rbjtech , appreciate sharing this! I will be testing this for sure. This is an alternate solution to the one above, I think i might prefer this more as I get more control. I've been using ffmpeg on Win and it's working great, I'll tweak the script to convert to mp4. One thing that I noticed is that MP4 are much much easier to play, rewind, pause, etc in a normal video player compared to mkv file; thus that's why I always convert mkv to mp4, also their size gets reduced too : ) luv ffmpeeg : ) thx once again! 1
wtploiqbn 6 Posted October 20, 2023 Author Posted October 20, 2023 (edited) @rbjtechthis is what I am using currently for ffmpeg to convert all .ts files to mp4: for i in *.ts; do ffmpeg -i "$i" -c:v libx264 -c:a aac "${i%.*}.mp4"; done I tried tweaking the script from you using the one above but without success. Do you mind advising what the bat script should look like using the ffmpeg above? That'd be amazing !!! PS: Also I wanted to ask you: once you have the bat file added in Settings, you have to re-start Emby right? so that the script kicks in? Thank you! Edited October 20, 2023 by wtploiqbn
rbjtech 5284 Posted October 21, 2023 Posted October 21, 2023 you need to add -c:v copy -c:a copy or you'll be be actually re-encoding with new x264 settings.
wtploiqbn 6 Posted October 23, 2023 Author Posted October 23, 2023 On 21/10/2023 at 19:26, rbjtech said: you need to add -c:v copy -c:a copy or you'll be be actually re-encoding with new x264 settings. @rbjtechwould you say this script below is correct to convert the .ts to .mp4 across all the sub directories and files in the Emby output folder? @echo off set logfile="c:\batch\emby_tv_recordings_log.txt" echo Emby TV Post Processing echo. echo [%date% %time:~0,8%] Info EmbyTV Processing : "%~d1%~p1%~n1.ts" >> %logfile% "C:\ffmpeg\bin\ffmpeg.exe" -i "%~d1%~p1%~n1.ts" -c:v copy libx264 -c:a copy aac "%~d1%~p1%~n1.mp4" if %errorlevel% equ 0 ( echo [%date% %time:~0,8%] Info EmbyTV Processed : "%~d1%~p1%~n1.mp4" >> %logfile% if exist "%~d1%~p1%~n1.mp4" del "%~d1%~p1%~n1.ts" ) else ( echo [%date% %time:~0,8%] Error EmbyTV File Not Processed : "%~d1%~p1%~n1.ts" >> %logfile% ) Thank you!
rbjtech 5284 Posted October 23, 2023 Posted October 23, 2023 "C:\ffmpeg\bin\ffmpeg.exe" -i "%~d1%~p1%~n1.ts" -c:v copy -c:a copy "%~d1%~p1%~n1.mp4" The copy command will literally copy what is within the TS and put it in an MP4 container. so if the TS contains AVC(h264) and AAC - then that's what will be in the MP4. if it contains MPEG2 and MP2 audio, then again, that's what will be in the MP4. The library used (libx264) and the audio codec (aac) is only used if you are actually converting something. so if you DO want to actually change it to h264/AAC - THEN you would use the following - "C:\ffmpeg\bin\ffmpeg.exe" -i "%~d1%~p1%~n1.ts" -c:v libx264 -c:a aac "%~d1%~p1%~n1.mp4" but there are a load of other settings you would use - such as quality, bitrate, channels etc etc - far too much to comtemplate here. Use the 1st option above - and see if it works out for you ...
wtploiqbn 6 Posted October 31, 2023 Author Posted October 31, 2023 cool @rbjtech I'll try it out, thank you!
wtploiqbn 6 Posted October 31, 2023 Author Posted October 31, 2023 @rbjtechthx a bunch, so far it is working. I'll keep testing it for a bit. This is the code I am using now: @echo off set logfile="c:\batch\emby_tv_recordings_log.txt" echo Emby TV Post Processing echo. echo [%date% %time:~0,8%] Info EmbyTV Processing : "%~d1%~p1%~n1.ts" >> %logfile% "C:\ffmpeg\bin\ffmpeg.exe" -i "%~d1%~p1%~n1.ts" -c:v copy -c:a copy "%~d1%~p1%~n1.mp4" if %errorlevel% equ 0 ( echo [%date% %time:~0,8%] Info EmbyTV Processed : "%~d1%~p1%~n1.mp4" >> %logfile% if exist "%~d1%~p1%~n1.mp4" del "%~d1%~p1%~n1.ts" ) else ( echo [%date% %time:~0,8%] Error EmbyTV File Not Processed : "%~d1%~p1%~n1.ts" >> %logfile% ) @rbjtechIf I want to keep the original .ts file in case the script fails, do I just use this script only (removed the last part)? @echo off set logfile="c:\batch\emby_tv_recordings_log.txt" echo Emby TV Post Processing echo. echo [%date% %time:~0,8%] Info EmbyTV Processing : "%~d1%~p1%~n1.ts" >> %logfile% "C:\ffmpeg\bin\ffmpeg.exe" -i "%~d1%~p1%~n1.ts" -c:v copy -c:a copy "%~d1%~p1%~n1.mp4" Thank you!
rbjtech 5284 Posted October 31, 2023 Posted October 31, 2023 2 hours ago, wtploiqbn said: @rbjtechIf I want to keep the original .ts file in case the script fails, do I just use this script only (removed the last part)? Correct
wtploiqbn 6 Posted November 2, 2023 Author Posted November 2, 2023 @rbjtechtested the script, it's working like a charm, thank you! 1
akaufman 2 Posted December 11, 2023 Posted December 11, 2023 Thank you to everyone for your input on this, I have found it very helpful. Is it possible to run this batch process on existing recordings?
rbjtech 5284 Posted December 11, 2023 Posted December 11, 2023 1 hour ago, akaufman said: Thank you to everyone for your input on this, I have found it very helpful. Is it possible to run this batch process on existing recordings? Yes - just pass it the folder where all your existing recordings are - and it will convert them all. This hasn't been tested - but assuming your working post processing scipt is called 'script.bat' - then the script below just finds any .TS file in all files and folders below it - and runs the script.bat on that file... As always, test before using .. @echo off setlocal ENABLEDELAYEDEXPANSION FOR /F "delims=" %%x in ('dir /a-s /b /s *.ts') DO ( call script.bat "%%x" ) pause 1
akaufman 2 Posted December 27, 2023 Posted December 27, 2023 On 12/11/2023 at 11:44 AM, rbjtech said: Yes - just pass it the folder where all your existing recordings are - and it will convert them all. This hasn't been tested - but assuming your working post processing scipt is called 'script.bat' - then the script below just finds any .TS file in all files and folders below it - and runs the script.bat on that file... As always, test before using .. @echo off setlocal ENABLEDELAYEDEXPANSION FOR /F "delims=" %%x in ('dir /a-s /b /s *.ts') DO ( call script.bat "%%x" ) pause Thank you. One last question. Is it possible to run this based on the TV source? For example I am using NextPVR as an IPTV source and I would like to run the conversion just in this source and not the OTA tuner sources.
rbjtech 5284 Posted December 27, 2023 Posted December 27, 2023 2 hours ago, akaufman said: Thank you. One last question. Is it possible to run this based on the TV source? For example I am using NextPVR as an IPTV source and I would like to run the conversion just in this source and not the OTA tuner sources. If the source is held in a different folder then yes, just specify that folder. If they are all put in one folder then it's more difficult - you may be able to prefix the filename or something with the source in the name and differentiate that way. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now