Create unique name for export output file.

With pause/resume functionality coming in, we need the output file
path to be different from the previous one.

PiperOrigin-RevId: 577175540
This commit is contained in:
sheenachhabra 2023-10-27 06:09:24 -07:00 committed by Copybara-Service
parent fed88cf6f5
commit 5b0be4e8b0
2 changed files with 7 additions and 2 deletions

View File

@ -56,6 +56,7 @@ import androidx.media3.common.audio.ChannelMixingAudioProcessor;
import androidx.media3.common.audio.ChannelMixingMatrix;
import androidx.media3.common.audio.SonicAudioProcessor;
import androidx.media3.common.util.BitmapLoader;
import androidx.media3.common.util.Clock;
import androidx.media3.common.util.Log;
import androidx.media3.datasource.DataSourceBitmapLoader;
import androidx.media3.effect.BitmapOverlay;
@ -220,7 +221,8 @@ public final class TransformerActivity extends AppCompatActivity {
Intent intent = getIntent();
Uri inputUri = checkNotNull(intent.getData());
try {
externalCacheFile = createExternalCacheFile("transformer-output.mp4");
externalCacheFile =
createExternalCacheFile("transformer-output-" + Clock.DEFAULT.elapsedRealtime() + ".mp4");
} catch (IOException e) {
throw new IllegalStateException(e);
}

View File

@ -28,6 +28,7 @@ import android.net.Uri;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
import androidx.media3.common.MediaItem;
import androidx.media3.common.util.Clock;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.NullableType;
import androidx.media3.common.util.SystemClock;
@ -339,7 +340,9 @@ public class TransformerAndroidTestRunner {
.build();
File outputVideoFile =
AndroidTestUtil.createExternalCacheFile(context, /* fileName= */ testId + "-output.mp4");
AndroidTestUtil.createExternalCacheFile(
context,
/* fileName= */ testId + "-" + Clock.DEFAULT.elapsedRealtime() + "-output.mp4");
InstrumentationRegistry.getInstrumentation()
.runOnMainSync(
() -> {