Jump to content

Scheduled MP4 Conversion after recording is done


Go to solution Solved by gillmacca01,

Recommended Posts

wtploiqbn
Posted (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)

 

 

emby1.png

emby2.png

Edited by wtploiqbn
wtploiqbn
Posted

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
Posted (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 by gillmacca01
  • Thanks 2
wtploiqbn
Posted

thanks a lot @gillmacca01, yes there is a setting for new content to be automatically converted. Thank you!

  • Thanks 1
Posted

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.

  • 4 months later...
Posted
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!

Posted (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

image.png.44070f92aeee261bea279f53a0c8101b.png

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 by rbjtech
  • Thanks 2
Posted
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!

  • Thanks 1
Posted (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 by wtploiqbn
Posted

you need to add -c:v copy -c:a copy or you'll be be actually re-encoding with new x264 settings.

Posted
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!

Posted
"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 ... ;)

 

Posted

@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!

Posted
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 :)

Posted

@rbjtechtested the script, it's working like a charm, thank you!

  • Like 1
  • 1 month later...
Posted

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? 

Posted
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

 

  • Like 1
  • 3 weeks later...
Posted
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.

Posted
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.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...